Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Commit

Permalink
Merge branch 'feature/ZC/protect-prod-app'
Browse files Browse the repository at this point in the history
  • Loading branch information
zenocode-org committed May 22, 2023
2 parents 883cd77 + ec486ca commit e20c577
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 0 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"${workspaceFolder}\\log.ini",
"--reload-dir",
"${workspaceFolder}\\templates"


],
"envFile": "${workspaceFolder}/.env",
"jinja": true,
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.PHONY: start
start:
uvicorn main:app --reload --port 9000
uvicorn main:app --reload --port 9000 --log-config log.ini

.PHONY: format
format:
Expand Down
7 changes: 6 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Main entrypoint for the app."""
import logging
import os
import pickle
from pathlib import Path
from typing import Optional
Expand Down Expand Up @@ -36,15 +37,19 @@ async def get(request: Request):
@app.websocket("/chat/{client_id}")
async def websocket_endpoint(websocket: WebSocket, client_id: str):
await websocket.accept()

if client_id not in os.environ.get("AUTHORIZED_CLIENT_IDS", []):
return

course_manager = CourseManager(client_id)
logging.info(f"[{client_id}] - Connection authorized.")
question_handler = QuestionGenCallbackHandler(websocket, client_id)
stream_handler = StreamingLLMCallbackHandler(websocket, client_id)
chat_history = []
qa_chain = get_chain(vectorstore, question_handler, stream_handler)
# Use the below line instead of the above line to enable tracing
# Ensure `langchain-server` is running
# qa_chain = get_chain(vectorstore, question_handler, stream_handler, tracing=True)
logging.error(client_id)
while True:
try:
# Receive and send back the client message
Expand Down

0 comments on commit e20c577

Please sign in to comment.