Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
duwenxin99 committed Jan 5, 2024
1 parent d27da79 commit e62dd42
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions langchain_tools_demo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def chat_handler(request: Request, prompt: str = Body(embed=True)):
# Add user message to chat history
request.session["messages"] += [{"role": "user", "content": prompt}]

user_agent = user_agents[(request.session["uuid"])]
user_agent = user_agents[request.session["uuid"]]
try:
# Send prompt to LLM
response = await user_agent.agent.ainvoke({"input": prompt})
Expand All @@ -96,11 +96,12 @@ async def reset(request: Request):
"""Reset agent"""
global user_agents
uuid = request.session["uuid"]
if uuid in user_agents.keys():
await user_agents[uuid].client.close()
del user_agents[uuid]
else:

if uuid not in user_agents.keys():
raise HTTPException(status_code=500, detail=f"Current agent not found")

await user_agents[uuid].client.close()
del user_agents[uuid]
request.session.clear()


Expand Down

0 comments on commit e62dd42

Please sign in to comment.