Spaces:
Sleeping
Sleeping
Commit ·
abdcaec
1
Parent(s): 31fe64f
update
Browse files- server/__pycache__/main.cpython-310.pyc +0 -0
- server/main.py +17 -0
server/__pycache__/main.cpython-310.pyc
CHANGED
|
Binary files a/server/__pycache__/main.cpython-310.pyc and b/server/__pycache__/main.cpython-310.pyc differ
|
|
|
server/main.py
CHANGED
|
@@ -23,6 +23,8 @@ from utils.GeneralAdvice import handle_general_advice
|
|
| 23 |
from utils.RouteQuery import route_query
|
| 24 |
from utils.RAGAdvanced import rag_advanced
|
| 25 |
import threading
|
|
|
|
|
|
|
| 26 |
|
| 27 |
load_dotenv()
|
| 28 |
|
|
@@ -154,6 +156,21 @@ def chat_endpoint(request:ChatRequest,fastapi_request:Request, background_tasks:
|
|
| 154 |
|
| 155 |
return ChatResponse(reply= result)
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
# Mount the frontend client directory to serve static assets at /
|
| 158 |
CLIENT_DIR = Path(__file__).resolve().parent.parent / "client"
|
| 159 |
app.mount("/", StaticFiles(directory=CLIENT_DIR, html=True), name="static")
|
|
|
|
| 23 |
from utils.RouteQuery import route_query
|
| 24 |
from utils.RAGAdvanced import rag_advanced
|
| 25 |
import threading
|
| 26 |
+
from fastapi.responses import FileResponse
|
| 27 |
+
from fastapi import HTTPException
|
| 28 |
|
| 29 |
load_dotenv()
|
| 30 |
|
|
|
|
| 156 |
|
| 157 |
return ChatResponse(reply= result)
|
| 158 |
|
| 159 |
+
@app.get("/download-logs")
|
| 160 |
+
def download_logs(key: str = None):
|
| 161 |
+
# Verify access using your groq key as the password
|
| 162 |
+
if not key or key != os.getenv("groq_api_key"):
|
| 163 |
+
raise HTTPException(status_code=401, detail="Unauthorized")
|
| 164 |
+
|
| 165 |
+
if not LOGS_FILE.exists():
|
| 166 |
+
raise HTTPException(status_code=404, detail="No logs found yet.")
|
| 167 |
+
|
| 168 |
+
return FileResponse(
|
| 169 |
+
path=LOGS_FILE,
|
| 170 |
+
filename="all_chats.csv",
|
| 171 |
+
media_type="text/csv"
|
| 172 |
+
)
|
| 173 |
+
|
| 174 |
# Mount the frontend client directory to serve static assets at /
|
| 175 |
CLIENT_DIR = Path(__file__).resolve().parent.parent / "client"
|
| 176 |
app.mount("/", StaticFiles(directory=CLIENT_DIR, html=True), name="static")
|