Error during search: RestError: The parameter 'semanticConfiguration' must not be empty.

J 0 Reputation points
2024-08-09T15:55:46.4933333+00:00

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).
User's image

User's image

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!

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,231 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,678 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.