Separate Cognitive Search query from ChatGPT interaction without losing citations

116 Views Asked by At

Azure's OpenAI service allows you to pass in an AzureChatExtensionConfiguration and have it run a cognitive search query against your data, passing the results to ChatGPT for 'context'.

Is it possible to separate these two steps? I want to run the cognitive search part, get x number of results, then pass that to ChatGPT and have it use that context. However, I want the chat results to have the same citations / references that the first approach does.

i.e. With the first approach, I can use the result JSON to get the citations like so: Choices[0].Message.AzureExtensionsContext.Messages[0].Content

This gives me a list of Citation objects:

private class Citation
{
    public string Id { get; set; }
    public string Title { get; set; }
    public string FilePath { get; set; }
    public string Url { get; set; }
    public string Content { get; set; }
}

Additionally, within the message content itself (i.e. Choices[0].Message.Content), there will be citation links in the format [doc1], [doc2], etc...

I don't want to lose this functionality, but I do want to insert a bit more logic into the gap between the cognitive search and the ChatGPT call - e.g., checking the list of results and if they're no sufficient, taking some other action.

Is this possible, or is the structure of response from the GetChatCompletionsAsync with the AzureChatExtensionsOptions some proprietary internal feature to the Azure OpenAI?

0

There are 0 best solutions below