File tree 1 file changed +12
-1
lines changed
src/llama_stack_client/lib/agents
1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -257,7 +257,18 @@ def create_turn(
257
257
chunks = [x for x in self ._create_turn_streaming (messages , session_id , toolgroups , documents )]
258
258
if not chunks :
259
259
raise Exception ("Turn did not complete" )
260
- return chunks [- 1 ].event .payload .turn
260
+
261
+ last_chunk = chunks [- 1 ]
262
+ try :
263
+ return last_chunk .event .payload .turn
264
+ except Exception as e :
265
+ if getattr (last_chunk , "error" , None ):
266
+ if getattr (last_chunk .error , "message" , None ):
267
+ raise RuntimeError (f"Turn did not complete. Error: { last_chunk .error .message } " ) from None
268
+ else :
269
+ raise RuntimeError (f"Turn did not complete. Error: { last_chunk .error } " ) from None
270
+ else :
271
+ raise RuntimeError (f"Turn did not complete with output: { last_chunk } " ) from None
261
272
262
273
def _create_turn_streaming (
263
274
self ,
You can’t perform that action at this time.
0 commit comments