Closed dannygar closed 3 days ago
@aacebo could we discuss the fix for this in our next team meeting?
@dannygar for reference, could you provide a version of the raw data from Azure AI Search, and if there are relevant places where the data still exists before it gets removed?
@corinagum, per your request, here is the request
object sent to Azure OpenAI API after the embeddings have already been added to the user's prompt:
And the response res
object looks like the following:
Note that it doesn't contain the context
object within, which usually holding the citations generated by LLM.
Here is the resulting message sent to the user:
In comparison, below are the same objects after I've added a custom data source (second) after the one used to extract the embeddings from the Azure AI Search:
request:
response:
And the resulting message sent to the user is:
Hi @dannygar, thanks for the extra info! As it turns out, it's recommended you update your sample to use server-side datasources instead of implementing client side. It will lead to less code, which is a plus. Using data_source
in our library is not deprecated, but there is more overhead and is unneeded for Azure AI search.
The sample you likely used was this: https://github.com/microsoft/teams-ai/tree/main/js/samples/04.ai-apps/g.datasource-azureAISearch
The sample we recommend looking at to implement is: https://github.com/microsoft/teams-ai/blob/main/js/samples/04.ai-apps/h.datasource-azureOpenAI
Some notes:
config.ts
data_source
(see config.ts
section below)___DataSource.ts
fileconfig.ts
client secret example for data_source
"data_sources": [
{
"type": "azure_search",
"parameters": {
"endpoint": "",
"authentication": {
"type": "api_key",
"key": ""
}
}
}
]
Managed identity example (using secrets in ts)
(prompt.config.completion as any).data_sources = [{
type: 'azure_search',
parameters: {
endpoint: process.env.AZURE_SEARCH_ENDPOINT,
index_name: process.env.AZURE_SEARCH_INDEX,
// other settings
// ...
authentication: {
type: 'system_assigned_managed_identity' // or 'api_key'
}
}
}];
}
FYI I already filed a new issue to update the AI Search sample to match the On Your Data sample implementation
Language
Javascript/Typescript
Version
latest
Description
When using
data_sources
augmentation with Azure AI Search, that custom data source is getting removed from the prompt's data sources, thus causing the citations not being returned from the chat completion API call.The reason is that this data source gets removed from the prompts immediately after the
renderData()
is executed.The workaround: Add the second data source through the
data_sources
custom property of thecompletion
property in the prompt's config. A sample of such workaround config.json:Reproduction Steps