@@ -77,33 +77,6 @@ async def lifespan(app: fastapi.FastAPI):
77
77
app .state .ai_client = ai_client
78
78
app .state .agent = agent
79
79
80
-
81
- file_map : Dict [str , Dict [str , str ]] = {}
82
-
83
- logger .info (f"Creating UPLOADED_FILE_MAP" )
84
- folder_path = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' , 'files' ))
85
- if agent .tool_resources and agent .tool_resources .file_search :
86
- for vector_store_id in agent .tool_resources .file_search .vector_store_ids :
87
- after : Optional [str ] = None
88
- has_more = True
89
- while has_more :
90
- files = await ai_client .agents .list_vector_store_files (vector_store_id , after = after )
91
- has_more = files .has_more
92
- after = files .last_id
93
- for file in files .data :
94
- openAI_file = await ai_client .agents .get_file (file .id )
95
- logger .info (f"Retrieved file, file ID: { openAI_file .filename } " )
96
- file_name = openAI_file .filename
97
- file_path = os .path .join (folder_path , file_name )
98
-
99
- if not os .path .exists (file_path ):
100
- logger .warning (f"File path does not exist: { file_path } " )
101
- continue
102
-
103
- # Store both file id and the file path using the file name as key.
104
- file_map [file_name ] = {"id" : file .id , "path" : file_path }
105
- app .state .upload_file_map = file_map
106
- logger .info (f"Set UPLOADED_FILE_MAP { file_map } " )
107
80
yield
108
81
109
82
except Exception as e :
0 commit comments