Skip to content

Commit

Permalink
Enforce no anonymous users
Browse files Browse the repository at this point in the history
  • Loading branch information
VVoruganti committed Dec 13, 2023
1 parent ecfa537 commit a433d95
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ async def get_messages(user_id: str, conversation_id: str):

@app.post("/api/chat")
async def chat(inp: ConversationInput):
if inp.user_id.startswith("anon_"):
return HTTPException(status_code=401, detail="unauthorized please sign in")
async with LOCK:
conversation = Conversation(MEDIATOR, user_id=inp.user_id, conversation_id=inp.conversation_id)
conversation_data = MEDIATOR.conversation(session_id=inp.conversation_id)
Expand All @@ -134,6 +136,8 @@ async def chat(inp: ConversationInput):
@app.post("/api/stream")
async def stream(inp: ConversationInput):
"""Stream the response too the user, currently only used by the Web UI and has integration to be able to use Honcho is not anonymous"""
if inp.user_id.startswith("anon_"):
return HTTPException(status_code=401, detail="unauthorized please sign in")
async with LOCK:
conversation = Conversation(MEDIATOR, user_id=inp.user_id, conversation_id=inp.conversation_id)
conversation_data = MEDIATOR.conversation(session_id=inp.conversation_id)
Expand Down

0 comments on commit a433d95

Please sign in to comment.