Error during search: RestError: The parameter 'semanticConfiguration' must not be empty.
I honestly have no idea what I'm doing wrong at this point, I've searched any and all forums to try and solve it but no luck.
Anyways, I have a teams-bot that is using Azure AI Search to be helpful, when using normal vector search everything works fine, but switching ofer to semantic I just get the following error:
[onTurnError] unhandled error: RestError: The parameter 'semanticConfiguration' must not be empty. Alternatively, set a default semantic configuration for this index.
Parameter name: semanticConfiguration
Now to preface this I can assure you that I have a search index with a semantic configuration named semantic-config
as seen below, and obviously semantic ranking is is enabled for the search resource (basic, not free).
Below is the code I'm running:
const { AzureKeyCredential, SearchClient } = require("@azure/search-documents");
class AzureAISearchDataSource {
constructor(options) {
this.name = options.name;
this.options = options;
this.searchClient = new SearchClient(
options.azureAISearchEndpoint,
options.indexName,
new AzureKeyCredential(options.azureAISearchApiKey),
{}
);
}
async renderData(context, memory, tokenizer, maxTokens) {
const query = memory.getValue("temp.input");
if(!query) {
return { output: "", length: 0, tooLong: false };
}
const selectedFields = [
"docId",
"docTitle",
"description"
];
const searchResults = await this.searchClient.search(query, {
searchFields: ["docTitle", "description"],
select: selectedFields,
top: 50,
queryType: 'semantic',
semanticConfiguration: 'semantic-config',
queryLanguage: 'sv-SE',
captions: 'extractive',
answers: 'extractive|count-3',
speller: 'lexicon'
});
if (!searchResults.results) {
return { output: "", length: 0, tooLong: false };
}
let usedTokens = 0;
let doc = "";
for await (const result of searchResults.results) {
const formattedResult = this.formatDocument(result.document, result.captions, result.answers);
const tokens = tokenizer.encode(formattedResult).length;
if (usedTokens + tokens > maxTokens) {
break;
}
doc += formattedResult;
usedTokens += tokens;
}
return { output: doc, length: usedTokens, tooLong: usedTokens > maxTokens };
}
formatDocument(document, captions, answers) {
let formattedDoc = `<context>
Title: ${document.docTitle}
Description: ${document.description}`;
if (captions && captions.length > 0) {
formattedDoc += `\nRelevant Excerpt: ${captions[0].text}`;
}
if (answers && answers.length > 0) {
formattedDoc += `\nPotential Answers:`;
answers.forEach((answer, index) => {
formattedDoc += `\n ${index + 1}. ${answer.text}`;
});
}
formattedDoc += `\n</context>\n\n`;
return formattedDoc;
}
}
module.exports = {
AzureAISearchDataSource,
};
I'd be super appreciative if anyone could help me get my head around this.
Thanks!