How to pass custom fields from AI Search index to OpenAI chat completions citation object?

Joshua Brumpton 0 Reputation points
2024-12-02T15:37:28.5933333+00:00

When calling the chat completion through the python SDK:

completion = await client.chat.completions.create(...)

I use an Azure AI Search index as a data source. The fields mapping available strictly cover only this set:
https://learn.microsoft.com/en-us/azure/ai-services/openai/references/azure-search?tabs=python#fields-mapping-options

However, I want the ability to retrieve custom fields without having to assign them to a FieldMappingOptions value. I have the "filepath" option mapped to the chunk filepath in blob storage. I also have a "source_filepath" which maps the source document filepath in blob storage. So ideally I would be able to add the following custom field mapping:

"source_filepath": "source_filepath"

And then I can use that from the response by the Azure OpenAI service in the citation object.

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,098 questions
Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
3,361 questions
{count} votes

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.