diff --git a/README.md b/README.md index c5d885f..38001d6 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/docker_overlay/etc/neon/diana.yaml b/docker_overlay/etc/neon/diana.yaml index 14110bf..c8fa873 100644 --- a/docker_overlay/etc/neon/diana.yaml +++ b/docker_overlay/etc/neon/diana.yaml @@ -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 \ No newline at end of file + tts_max_words: 128 + enable_email: False \ No newline at end of file diff --git a/neon_hana/mq_service_api.py b/neon_hana/mq_service_api.py index 1d43fd6..e7c71ae 100644 --- a/neon_hana/mq_service_api.py +++ b/neon_hana/mq_service_api.py @@ -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 @@ -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: @@ -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,