@@ -876,18 +876,17 @@ async def create_run(
876876 model = create_run_request .model
877877 # TODO: implement support for ChatCompletionToolChoiceOption
878878 assistant = await get_assistant_obj (assistant_id = create_run_request .assistant_id , astradb = astradb )
879+ if assistant is None :
880+ raise HTTPException (status_code = 404 , detail = "Assistant not found" )
881+ tool_resources = assistant .tool_resources
879882
880883 if tools is None :
881884 tools = []
882885 if assistant .tools is not None :
883886 tools = assistant .tools
884887
885- tool_resources = []
886888 if model is None :
887- if assistant is None :
888- raise HTTPException (status_code = 404 , detail = "Assistant not found" )
889889 model = assistant .model
890- tool_resources = assistant .tool_resources
891890
892891 messages = get_messages_by_thread (astradb , thread_id , order = "asc" )
893892
@@ -1274,7 +1273,7 @@ async def process_rag(
12741273 message_attachment_file_ids .append (attachment .file_id )
12751274
12761275 file_ids = []
1277- if tool_resources .file_search is not None :
1276+ if tool_resources is not None and tool_resources .file_search is not None :
12781277 if tool_resources .file_search .vector_store_ids is not None :
12791278 for vector_store_id in tool_resources .file_search .vector_store_ids :
12801279 vector_store_files = await read_vsf (vector_store_id = vector_store_id , astradb = astradb )
@@ -1395,7 +1394,8 @@ async def process_rag(
13951394 logger .error ("process_rag cancelled" )
13961395 raise RuntimeError ("process_rag cancelled" )
13971396 except Exception as e :
1398- logger .error (f"process_rag failed, dbid: { astradb .dbid } , error: { e } " )
1397+ trace = traceback .format_exc ()
1398+ logger .error (f"process_rag failed, dbid: { astradb .dbid } \n Error: { e } \n Trace: { trace } " )
13991399 # TODO maybe do a cancelled run step with more details?
14001400 await update_run_status (thread_id = thread_id , id = run_id , status = "failed" , astradb = astradb )
14011401 logger .error ("process_rag cancelled" )
0 commit comments