@@ -68,12 +68,18 @@ def get_compass():
6868
6969 if compass is None :
7070 try :
71- compass = Compass ()
71+ compass = Compass (
72+ compass_api_url = Settings ().compass .api_url ,
73+ compass_parser_url = Settings ().compass .parser_url ,
74+ compass_username = Settings ().compass .username ,
75+ compass_password = Settings ().compass .password ,
76+ )
7277 except Exception as e :
7378 logger .error (
7479 event = f"[Compass File Service] Error initializing Compass: { e } "
7580 )
7681 raise e
82+
7783 return compass
7884
7985
@@ -157,7 +163,7 @@ async def create_agent_files(
157163 Since agents are created after the files are upload we index files into dummy indices first
158164 We later consolidate them in consolidate_agent_files_in_compass() to a singular index when an agent is created.
159165 """
160- uploaded_files = await insert_files_in_compass (files , ctx , user_id )
166+ uploaded_files = await insert_files_in_compass (files , user_id , ctx )
161167 else :
162168 uploaded_files = await insert_files_in_db (session , files , user_id )
163169
@@ -459,12 +465,21 @@ async def consolidate_agent_files_in_compass(
459465 compass = get_compass ()
460466
461467 try :
462- compass .invoke (
468+ logger .info (
469+ event = "[Compass File Service] Creating index for agent files" ,
470+ agent_id = agent_id
471+ )
472+ response = compass .invoke (
463473 action = Compass .ValidActions .CREATE_INDEX ,
464474 parameters = {
465475 "index" : agent_id ,
466476 },
467477 )
478+ logger .info (
479+ event = "[Compass File Service] Finished creating index for agent files" ,
480+ agent_id = agent_id ,
481+ response = response
482+ )
468483 except Exception as e :
469484 logger .Error (
470485 event = f"[Compass File Service] Error creating index for agent files: { agent_id } , error: { e } "
@@ -480,13 +495,13 @@ async def consolidate_agent_files_in_compass(
480495 action = Compass .ValidActions .GET_DOCUMENT ,
481496 parameters = {"index" : file_id , "file_id" : file_id },
482497 ).result ["doc" ]["content" ]
483- compass () .invoke (
498+ compass .invoke (
484499 action = Compass .ValidActions .CREATE ,
485500 parameters = {
486501 "index" : agent_id ,
487502 "file_id" : file_id ,
488503 "file_bytes" : fetched_doc ["text" ],
489- "filename " : fetched_doc ["file_name" ],
504+ "file_extension " : get_file_extension ( fetched_doc ["file_name" ]) ,
490505 "custom_context" : {
491506 "file_id" : file_id ,
492507 "file_name" : fetched_doc ["file_name" ],
@@ -506,7 +521,7 @@ async def consolidate_agent_files_in_compass(
506521 )
507522 # Remove the temporary file index entry
508523 compass .invoke (
509- action = Compass .ValidActions .DELETE_INDEX , parameters = {"index" : agent_id }
524+ action = Compass .ValidActions .DELETE_INDEX , parameters = {"index" : file_id }
510525 )
511526 except Exception as e :
512527 logger .error (
@@ -568,7 +583,7 @@ async def insert_files_in_compass(
568583 "index" : new_file_id if index is None else index ,
569584 "file_id" : new_file_id ,
570585 "file_bytes" : file_bytes ,
571- "filename " : filename ,
586+ "file_extension " : get_file_extension ( filename ) ,
572587 "custom_context" : {
573588 "file_id" : new_file_id ,
574589 "file_name" : filename ,
0 commit comments