Skip to content

Commit

Permalink
Default disable email service with note in docs explaining rationale (#4
Browse files Browse the repository at this point in the history
)

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Jan 22, 2024
1 parent 8296229 commit da05c86
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ hana:
disable_auth: True
stt_max_length_encoded: 500000 # Arbitrary limit that is larger than any expected voice command
tts_max_words: 128 # Arbitrary limit that is longer than any default LLM token limit
enable_email: True # Disabled by default; anyone with access to the API will be able to send emails from the configured address

```
It is recommended to generate unique values for configured tokens, these are 32
bytes in hexadecimal representation.
Expand Down
3 changes: 2 additions & 1 deletion docker_overlay/etc/neon/diana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ hana:
fastapi_title: "Hana"
fastapi_summary: "HANA (HTTP API for Neon Applications) is the HTTP component of the Device Independent API for Neon Applications (DIANA)"
stt_max_length_encoded: 500000
tts_max_words: 128
tts_max_words: 128
enable_email: False
4 changes: 3 additions & 1 deletion neon_hana/mq_service_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import json

from tempfile import mkdtemp
from time import time
from typing import Optional, Dict, Any, List
from uuid import uuid4
Expand All @@ -48,6 +47,7 @@ def __init__(self, config: dict):
self.mq_cliend_id = config.get('mq_client_id') or str(uuid4())
self.stt_max_length = config.get('stt_max_length_encoded') or 500000
self.tts_max_words = config.get('tts_max_words') or 128
self.email_enabled = config.get('enable_email')

def _validate_api_proxy_response(self, response: dict):
if response['status_code'] == 200:
Expand Down Expand Up @@ -88,6 +88,8 @@ def query_llm(self, llm_name: str, query: str, history: List[tuple]):

def send_email(self, recipient: str, subject: str, body: str,
attachments: Optional[Dict[str, str]]):
if not self.email_enabled:
raise APIError(status_code=503, detail="Email service disabled")
request_data = {"recipient": recipient,
"subject": subject,
"body": body,
Expand Down

0 comments on commit da05c86

Please sign in to comment.