MSUSAzureAccelerators / Azure-Cognitive-Search-Azure-OpenAI-Accelerator

Virtual Assistant - GPT Smart Search Engine - Bot Framework + Azure OpenAI + Azure AI Search + Azure SQL + Bing API + Azure Document Intelligence + LangChain + CosmosDB
https://gptsmartsearchapp.azurewebsites.net
MIT License
333 stars 549 forks source link

03-Quering-AOpenAI.ipynb cell 6: Code fails if there are no answers #50

Closed vykhand closed 6 months ago

vykhand commented 9 months ago

Needs to be changed to

display(HTML('<h4>Top Answers</h4>'))

for index,search_results in agg_search_results.items():
    if '@search_answers' in search_results:
        for result in search_results['@search.answers']:
            if result['score'] > 0.5: # Show answers that are at least 50% of the max possible score=1
                display(HTML('<h5>' + 'Answer - score: ' + str(round(result['score'],2)) + '</h5>'))
                display(HTML(result['text']))
pablomarin commented 7 months ago

this should be fixed now