@@ -190,7 +190,7 @@ def create_search_index():
190190 connection_string = f"DRIVER={ driver } ;SERVER={ SQL_SERVER } ;DATABASE={ SQL_DATABASE } ;"
191191 conn = pyodbc .connect (connection_string , attrs_before = {SQL_COPT_SS_ACCESS_TOKEN : token_struct })
192192 cursor = conn .cursor ()
193- except :
193+ except Exception : # Fall back to ODBC Driver 17
194194 driver = "{ODBC Driver 17 for SQL Server}"
195195 token_bytes = credential .get_token ("https://database.windows.net/.default" ).token .encode ("utf-16-LE" )
196196 token_struct = struct .pack (f"<I{ len (token_bytes )} s" , len (token_bytes ), token_bytes )
@@ -435,10 +435,10 @@ async def process_files():
435435
436436 docs .extend (await prepare_search_doc (content , conversation_id , path .name , embeddings_client ))
437437 counter += 1
438- except Exception :
438+ except Exception : # Skip files that fail processing
439439 pass
440440 if docs != [] and counter % 10 == 0 :
441- result = search_client .upload_documents (documents = docs )
441+ search_client .upload_documents (documents = docs )
442442 docs = []
443443 if docs :
444444 search_client .upload_documents (documents = docs )
@@ -469,7 +469,6 @@ async def process_files():
469469 conversation_id = file_name .split ('convo_' , 1 )[1 ].split ('_' )[0 ]
470470 conversationIds .append (conversation_id )
471471
472- duration = int (result ['result' ]['contents' ][0 ]['fields' ]['Duration' ]['valueString' ])
473472 fields = result ['result' ]['contents' ][0 ]['fields' ]
474473 duration_str = get_field_value (fields , 'Duration' , '0' )
475474 try :
@@ -507,9 +506,9 @@ async def process_files():
507506 docs .extend (await prepare_search_doc (content , document_id , path .name , embeddings_client ))
508507 counter += 1
509508 except Exception :
510- pass
509+ pass # Skip files that fail to process
511510 if docs != [] and counter % 10 == 0 :
512- result = search_client .upload_documents (documents = docs )
511+ search_client .upload_documents (documents = docs )
513512 docs = []
514513
515514 # upload the last batch
@@ -620,8 +619,6 @@ async def call_topic_mining_agent(topics_str1):
620619 res = res .replace ("```json" , '' ).replace ("```" , '' ).strip ()
621620 return json .loads (res )
622621
623- MAX_TOKENS = 3096
624-
625622 res = asyncio .run (call_topic_mining_agent (topics_str ))
626623 for object1 in res ['topics' ]:
627624 cursor .execute ("INSERT INTO km_mined_topics (label, description) VALUES (?,?)" , (object1 ['label' ], object1 ['description' ]))
@@ -632,7 +629,6 @@ async def call_topic_mining_agent(topics_str1):
632629 column_names = [i [0 ] for i in cursor .description ]
633630 df_topics = pd .DataFrame (rows , columns = column_names )
634631 mined_topics_list = df_topics ['label' ].tolist ()
635- mined_topics = ", " .join (mined_topics_list )
636632 print (f"✓ Mined { len (mined_topics_list )} topics" )
637633
638634 async def call_topic_mapping_agent (agent , input_text , list_of_topics ):
0 commit comments