最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Additional headers are not being sent to the Azure OpenAI through Weaviate SDK - Stack Overflow

programmeradmin5浏览0评论

I am using the Python SDK to connect to Weaviate. Additionally, I am create collection that is able to send requests to Azure OpenAI, using text2vec-azure-openai module. To use that, I am sending X-Azure-Api-Key as it is mentioned in the documentation here: .

The embedding of the texts through Azure OpenAI is working correctly. However, I want to include some additional headers that are passed directly to Azure OpenAI calls. I tried the following:

 self._client = WeaviateClient(
      connection_params=ConnectionParams(
          http=ProtocolParams(host=host, port=port, secure=False),
          grpc=ProtocolParams(host=host, port=grpc_port, secure=False),
      ),
      additional_headers={
          "X-Azure-Api-Key": ...,
          "some_additional_custom_header": "value",
          },
      skip_init_checks=True,
  )
  self._client.connect()

Sadly, this option is not working and my additional headers are not sent to Azure OpenAI. Do I miss something or maybe it is not possible to pass some custom headers to Azure OpenAI through Weaviate? Thanks in advance for the response.

I am using the Python SDK to connect to Weaviate. Additionally, I am create collection that is able to send requests to Azure OpenAI, using text2vec-azure-openai module. To use that, I am sending X-Azure-Api-Key as it is mentioned in the documentation here: https://weaviate.io/developers/weaviate/model-providers/openai/embeddings.

The embedding of the texts through Azure OpenAI is working correctly. However, I want to include some additional headers that are passed directly to Azure OpenAI calls. I tried the following:

 self._client = WeaviateClient(
      connection_params=ConnectionParams(
          http=ProtocolParams(host=host, port=port, secure=False),
          grpc=ProtocolParams(host=host, port=grpc_port, secure=False),
      ),
      additional_headers={
          "X-Azure-Api-Key": ...,
          "some_additional_custom_header": "value",
          },
      skip_init_checks=True,
  )
  self._client.connect()

Sadly, this option is not working and my additional headers are not sent to Azure OpenAI. Do I miss something or maybe it is not possible to pass some custom headers to Azure OpenAI through Weaviate? Thanks in advance for the response.

Share Improve this question asked Mar 24 at 6:58 user30039021user30039021 1 4
  • Set custom headers in moduleConfig.text2vec-azure-openai.headers within the Weaviate schema instead of additional_headers in the client. – Dasari Kamali Commented Mar 24 at 7:13
  • Hi! What is the additional custom header you want to pass? Those are specific headers that are passed from the client to the Server and then to the vectorizer server. Also, note that you are using our python client v3. This is deprecated. You will want to use the python v4 as documented here: weaviate.io/developers/weaviate/client-libraries/python/… – Duda Nogueira Commented Mar 26 at 12:11
  • Hi, I am using v4 client for that. For the additional custom headers, I wanted to include just some debugging headers that are not specific for the Azure OpenAI. For example, I wanted to have some identifiers sent in the headers, so that the request to Azure OpenAI includes here like this "identifier-header": "123456" – user30039021 Commented Mar 27 at 17:00
  • Let me know if at all, is it possible to send some custom additional headers that is just for my own purposes (Azure OpenAI doesn't need header like this) – user30039021 Commented Mar 27 at 17:01
Add a comment  | 

1 Answer 1

Reset to default 0

You can pass custom headers directly in the additional_headers argument when creating the Weaviate client. These headers will be forwarded with the requests sent to Weaviate, and can then be passed to the Azure OpenAI vectorizer if needed.

Code:

import weaviate

client = weaviate.Client(
    url="http://localhost:8080",  # Weaviate instance URL
    additional_headers={
        "X-Azure-Api-Key": "your_azure_api_key",  # Azure API Key
        "identifier-header": "123456",
        "another-header": "value",  
    }
)

# Weaviate operations...
  • "identifier-header": "123456" will be sent as part of the HTTP request to Weaviate, and should be forwarded to Azure OpenAI during the embedding process.

If the headers need to be passed directly to the Azure OpenAI vectorizer, Configure the headers in the module configuration.

client.schema.create_class({
    "class": "YourClass",
    "vectorizer": "text2vec-azure-openai",
    "moduleConfig": {
        "text2vec-azure-openai": {
            "model": "your_model_name",
            "headers": {
                "X-Azure-Api-Key": "your_azure_api_key",
                "identifier-header": "123456"
            }
        }
    }
})

This documentation for Python client v4 describes how to interact with Weaviate using the Python SDK. This includes client initialization, managing schema, querying data, and configuring headers.

Configuring headers in API requests for the vectorizer and other modules, like text2vec-azure-openai follow this link.

发布评论

评论列表(0)

  1. 暂无评论