admin管理员组文章数量:1401425
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 |1 Answer
Reset to default 0You 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.
本文标签: pythonAdditional headers are not being sent to the Azure OpenAI through Weaviate SDKStack Overflow
版权声明:本文标题:python - Additional headers are not being sent to the Azure OpenAI through Weaviate SDK - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744256946a2597526.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
moduleConfig.text2vec-azure-openai.headers
within the Weaviate schema instead ofadditional_headers
in the client. – Dasari Kamali Commented Mar 24 at 7:13"identifier-header": "123456"
– user30039021 Commented Mar 27 at 17:00