Passing searching results from Bing Search API to AOAI assistants

Mohamed Hussein 490 Reputation points
2024-12-13T12:26:45.6966667+00:00

Good Day,

Appreciate your all efforts,

I was trying to follow guidelines here to pass the search result from Bing to Azure OpenAi Assistants,

Sometimes it works, sometimes it does not. There's no clear error, check attachments

Image 11

I just copy the output from Postman as it is, and pass it through the UI

As i far got, the function itself is not hosted at Assistants, and the search function is manually triggered. Finally, search results are passed to the assistant to be further processed.

My questions

  1. Should i pass the results as it's. Something like below
  2. To avoid delayed response, which is faster, A: trigger Azure Logic App (consumption plan) which have risk of Cold start Or B: Manually pass search results and keep monitrong run_status when requires_action
  3. When defining the function scheme to the assistants, where the output is defined
       {
           "_type": "SearchResponse",
           "queryContext": {
               "originalQuery": "Our AI future: promise and peril, CNN article"
           },
           "webPages": {
               "webSearchUrl": "https://www.bing.com/search?q=Our+AI+future%3a+promise+and+peril%2c+CNN+article",
               "totalEstimatedMatches": 24200,
               "value": [
                   {
                       "id": "https://api.bing.microsoft.com/api/v7/#WebPages.0",
                       "name": "Our AI future: promise and peril - CNN",
                       "url": "https://www.cnn.com/opinions/our-ai-future-promise-and-peril",
                       "isFamilyFriendly": true,
                       "displayUrl": "https://www.cnn.com/opinions/our-ai-future-promise-and-peril",
                       "snippet": "With advancements in artificial intelligence, deepfake pornography is becoming increasingly common — and it almost exclusively targets women, write Sophie Compton and Reuben Hamlyn. In 1959,...",
                       "deepLinks": [
                           {
                               "name": "Opinion: We’ve reached a turning point with AI, expert says - CNN",
                               "url": "https://www.cnn.com/2023/05/31/opinions/artificial-intelligence-stuart-russell/index.html",
                               "snippet": "“Our AI future: promise and peril” will explore how AI will affect our lives, the way we work and how we understand ourselves. Ever since ChatGPT was released last November, artificial..."
                           }
                       ],
                       "dateLastCrawled": "2024-12-06T21:06:00.0000000Z",
                       "language": "en",
                       "isNavigational": true,
                       "noCache": false,
                       "siteName": "CNN"
                   },
                   {
                       "id": "https://api.bing.microsoft.com/api/v7/#WebPages.1",
                       "name": "Opinion: We’ve reached a turning point with AI, expert says - CNN",
                       "url": "https://www.cnn.com/2023/05/31/opinions/artificial-intelligence-stuart-russell/index.html",
                       "isFamilyFriendly": true,
                       "displayUrl": "https://www.cnn.com/2023/05/31/opinions/artificial-intelligence-stuart-russell",
                       "snippet": "“Our AI future: promise and peril” will explore how AI will affect our lives, the way we work and how we understand ourselves. Ever since ChatGPT was released last November, artificial...",
                       "dateLastCrawled": "2024-12-11T20:12:00.0000000Z",
                       "language": "en",
                       "isNavigational": false,
                       "noCache": false,
                       "siteName": "CNN"
                   },
                   {
                       "id": "https://api.bing.microsoft.com/api/v7/#WebPages.2",
                       "name": "Opinion: Here are the jobs AI will impact most | CNN",
                       "url": "https://edition.cnn.com/2023/09/05/opinions/artificial-intelligence-jobs-labor-market/index.html",
                       "isFamilyFriendly": true,
                       "displayUrl": "https://edition.cnn.com/2023/09/05/opinions/artificial-intelligence-jobs-labor-market/...",
                       "snippet": "“Our AI future: promise and peril” explores how AI will affect our lives, the way we work and how we understand ourselves.",
                       "dateLastCrawled": "2024-12-09T10:21:00.0000000Z",
                       "language": "en",
                       "isNavigational": false,
                       "noCache": false,
                       "siteName": "CNN"
                   }
               ]
           },
           "rankingResponse": {
               "mainline": {
                   "items": [
                       {
                           "answerType": "WebPages",
                           "resultIndex": 0,
                           "value": {
                               "id": "https://api.bing.microsoft.com/api/v7/#WebPages.0"
                           }
                       },
                       {
                           "answerType": "WebPages",
                           "resultIndex": 1,
                           "value": {
                               "id": "https://api.bing.microsoft.com/api/v7/#WebPages.1"
                           }
                       },
                       {
                           "answerType": "WebPages",
                           "resultIndex": 2,
                           "value": {
                               "id": "https://api.bing.microsoft.com/api/v7/#WebPages.2"
                           }
                       }
                   ]
               }
           }
       }
    
Bing Web Search
Bing Web Search
A Bing service that gives you enhanced search details from billions of web documents.
165 questions
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,449 questions
{count} votes

Accepted answer
  1. santoshkc 11,450 Reputation points Microsoft Vendor
    2024-12-16T08:50:15.6966667+00:00

    Hi @Mohamed Hussein,

    Here is the response to your queries:

    • You can pass the results directly in the format you mentioned, but ensure that the response is structured correctly, typically as a JSON object containing the necessary fields like titles, URLs, and snippets.
    • Manually passing the search results and monitoring the run_status when requires_action is generally faster. This avoids the potential cold start latency associated with Azure Logic Apps on a consumption plan, where the first request after idle time can be delayed. By manually passing the data, you control the timing and execution, potentially improving response time.
    • In the function schema, the output is typically not explicitly defined. Instead, the schema provides a guide for how the assistant should expect to interact with the function and what data the function should return. The actual output is determined when the function is executed. For custom functions, you define the function logic and output externally, and the assistant uses this structure when interacting with the function.

    Thank you.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.