File tree Expand file tree Collapse file tree 1 file changed +14
-20
lines changed Expand file tree Collapse file tree 1 file changed +14
-20
lines changed Original file line number Diff line number Diff line change @@ -298,26 +298,20 @@ async def run_agentic_retrieval(
298
298
)
299
299
300
300
results = []
301
- grounding_text = response .response [0 ].content [0 ].text
302
- if response and grounding_text :
303
- grounding_response = json .loads (grounding_text )
304
- for grounding_reference in grounding_response :
305
- ref_id = grounding_reference .get ("ref_id" )
306
- if ref_id is not None :
307
- ref_id = str (ref_id )
308
- for reference in response .references :
309
- if isinstance (reference , KnowledgeAgentAzureSearchDocReference ) and reference .id == ref_id and reference .source_data :
310
- results .append (
311
- Document (
312
- id = reference .doc_key ,
313
- content = reference .source_data ["content" ],
314
- sourcepage = reference .source_data ["sourcepage" ],
315
- search_agent_query = activity_mapping [reference .activity_source ],
316
- )
317
- )
318
- break
319
- if top and len (results ) == top :
320
- break
301
+ if response and response .references :
302
+ references = sorted (response .references , key = lambda reference : int (reference .id ))
303
+ for reference in references :
304
+ if isinstance (reference , KnowledgeAgentAzureSearchDocReference ) and reference .source_data :
305
+ results .append (
306
+ Document (
307
+ id = reference .doc_key ,
308
+ content = reference .source_data ["content" ],
309
+ sourcepage = reference .source_data ["sourcepage" ],
310
+ search_agent_query = activity_mapping [reference .activity_source ],
311
+ )
312
+ )
313
+ if top and len (results ) == top :
314
+ break
321
315
322
316
return response , results
323
317
You can’t perform that action at this time.
0 commit comments