From bb3d1ae46a25a0a9f0f08bd8e227f4ddf6cba380 Mon Sep 17 00:00:00 2001 From: tcsenpai Date: Fri, 2 May 2025 10:30:12 +0200 Subject: [PATCH] added configurable backend port through dotenv --- .env.example | 3 ++- api.py | 5 ++++- requirements.txt | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 1f342b1..084297d 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,4 @@ SEARXNG_BASE_URL="http://127.0.0.1:8080" OPENAI_API_KEY='xxxxx' -DEEPSEEK_API_KEY='xxxxx' \ No newline at end of file +DEEPSEEK_API_KEY='xxxxx' +BACKEND_PORT=8000 \ No newline at end of file diff --git a/api.py b/api.py index 18b971b..ce80df9 100755 --- a/api.py +++ b/api.py @@ -22,6 +22,9 @@ from sources.utility import pretty_print from sources.logger import Logger from sources.schemas import QueryRequest, QueryResponse +from dotenv import load_dotenv + +load_dotenv() from celery import Celery @@ -234,4 +237,4 @@ async def process_query(request: QueryRequest): interaction.save_session() if __name__ == "__main__": - uvicorn.run(api, host="0.0.0.0", port=8000) \ No newline at end of file + uvicorn.run(api, host="0.0.0.0", port=os.getenv("BACKEND_PORT") or 8000) diff --git a/requirements.txt b/requirements.txt index 715523f..638b085 100644 --- a/requirements.txt +++ b/requirements.txt @@ -42,6 +42,7 @@ sentencepiece>=0.2.0 openai sniffio tqdm>4 +python-dotenv>=1.0.0 # if use chinese ordered_set pypinyin