AzureCognitiveSearchChatExtensionConfiguration help

James Petras 0 Reputation points
2023-11-16T15:28:22.0866667+00:00

Hi guys

I'm trying to setup AzureCognitiveSearchChatExtensionConfiguration for hybrid search (vector + semantic) but I can't make it work

Here is my code

        var search=new AzureCognitiveSearchChatExtensionConfiguration()
        {
            SearchEndpoint = new Uri(_configuration.GetSection("AppSettings")["SearchEndPoint"]),
            IndexName = "ai"
           
        };
        search.SetSearchKey(_configuration.GetSection("AppSettings")["SearchKey"]);
        search.SemanticConfiguration="ai-semantic-config";
        search.QueryType= AzureCognitiveSearchQueryType.VectorSemanticHybrid;
        search.EmbeddingEndpoint =new Uri(_configuration.GetSection("AppSettings")["AiEndPoint"]);///openai/deployments/{deployment-id}/embeddings?api-version={api-version}
        search.SetEmbeddingKey(_configuration.GetSection("AppSettings")["AiKey"]);
        search.FieldMappingOptions = new AzureCognitiveSearchIndexFieldMappingOptions()
        {
            UrlFieldName="Url",
            TitleFieldName="Title",
        }
    ;
        search.FieldMappingOptions.ContentFieldNames.Add("Content");
        search.FieldMappingOptions.ContentFieldNames.Add("Subtitle");
        search.FieldMappingOptions.ContentFieldNames.Add("Authors");
        //search.FieldMappingOptions.VectorFieldNames.Add("TitleVector");
        search.FieldMappingOptions.VectorFieldNames.Add("ContentVector");
       

        ChatCompletionsOptions chatCompletionsOptions = new()
        {
            DeploymentName = modelName,
            Messages =
{
    new ChatMessage(
        ChatRole.System,
        "You are a helpful assistant "),
    new ChatMessage(ChatRole.User, question)
},

            AzureExtensionsOptions = new AzureChatExtensionsOptions()
            {
                Extensions =
    {
        search
    }
            }
        };






        try
        {
            Response<ChatCompletions> response = await _client.GetChatCompletionsAsync(chatCompletionsOptions);
            ChatMessage message = response.Value.Choices[0].Message;
            return message.Content;

        }

The message I'm getting is

Service request failed. Status: 400 (Bad Request) Content: {"error": {"requestid": "90ef3895-27ce-458f-a6d2-ba0fe165345f", "code": 400, "message": "An error occurred when calling Azure Cognitive Search: Azure Search: Please assign a proper column/field for vector search. It should be of type Collection(Edm.Single)"}} Headers: x-envoy-upstream-service-time: REDACTED apim-request-id: REDACTED x-ms-client-request-id: e87d8134-efc6-4e6f-8195-dc51be1a712f Strict-Transport-Security: REDACTED X-Content-Type-Options: REDACTED x-ms-region: REDACTED Date: Thu, 16 Nov 2023 15:15:24 GMT Content-Length: 259 Content-Type: application/json; charset=UTF-8 ss

Although I have passed the correct vector filed

Thanks

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
1,412 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jaime Velasco 0 Reputation points
    2023-11-22T12:51:56.3666667+00:00

    Good morning,

    I am having the same problem. Have you found any solution?

    Thank you!

    0 comments No comments