You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optional configs to pass additional_headers/additional_metadata to indexes (#297)
## Problem
There are some debugging scenarios where, in order to debug or track a
specific request, we would like the ability to pass additional headers
with each request.
## Solution
- Add `additional_headers` kwarg to `Index()` for REST calls
- Add `additional_metadata` field within existing `grpc_config` object
for configuring equivalent for GRPC
- Add unit tests for both ways of doing it. Metadata is a [similar
concept](https://grpc.io/docs/guides/metadata/) to http request headers
in GRPC, not to be confused with vector metadata.
## Type of Change
- [x] None of the above: New feature, but really for Pinecone
developer/support use only.
### Usage (REST)
```python
from pinecone import Pinecone
pc = Pinecone(api_key='xxx')
index = pc.Index(
host='hosturl',
additional_headers={ 'header-1': 'header-1-value' }
)
# Now do things
index.upsert(...)
```
### Usage (GRPC)
```python
from pinecone.grpc import PineconeGRPC, GRPCClientConfig
pc = PineconeGRPC(api_key='YOUR_API_KEY')
grpc_config = GRPCClientConfig(additional_metadata={'extra-header': 'value123'})
index = pc.Index(
name='my-index',
host='host',
grpc_config=grpc_config
)
# do stuff
index.upsert(...)
```
## Test Plan
Besides unit tests, I will try running some test commands with
`PINECONE_DEBUG_CURL='true'` enabled to see what request is being sent.
0 commit comments