lucebert commited on
Commit
7908478
·
1 Parent(s): 3d03c3d

add try catch on langggraph client

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -12,11 +12,18 @@ async def on_start():
12
  langraph_client = get_client(
13
  url=LANGGRAPH_DEPLOYMENT
14
  )
15
- assistants = await langraph_client.assistants.search(
16
- graph_id="simple_rag", metadata={"created_by": "system"}
17
- )
18
-
19
- thread = await langraph_client.threads.create()
 
 
 
 
 
 
 
20
 
21
  cl.user_session.set("langraph_client", langraph_client)
22
  cl.user_session.set("assistant_id", assistants[0]["assistant_id"])
 
12
  langraph_client = get_client(
13
  url=LANGGRAPH_DEPLOYMENT
14
  )
15
+
16
+ try:
17
+ assistants = await langraph_client.assistants.search(
18
+ graph_id="simple_rag", metadata={"created_by": "system"}
19
+ )
20
+
21
+ thread = await langraph_client.threads.create()
22
+ except Exception as e:
23
+ print(f"Error occurred while creating assistant or thread: {str(e)}")
24
+ # You might want to handle the error appropriately here
25
+ # For example, you could raise a custom error or return a default value
26
+ raise
27
 
28
  cl.user_session.set("langraph_client", langraph_client)
29
  cl.user_session.set("assistant_id", assistants[0]["assistant_id"])