Skip to content

Commit

Permalink
feat(pinecone) remove api-version header when pinecone base client is…
Browse files Browse the repository at this point in the history
… formed

remove api version 2024-10 from headers as this is latest stable version now and supports rerank api by default
  • Loading branch information
MubeenKodvavi committed Oct 28, 2024
1 parent 1b82d4f commit dd8c27f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/component/data/pinecone/v0/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ func (c *component) CreateExecution(x base.ComponentExecution) (base.IExecution,
}, nil
}

// newIndexClient creates a new httpclient.Client with the index URL provided in setup
func newIndexClient(setup *structpb.Struct, logger *zap.Logger) *httpclient.Client {
c := httpclient.New("Pinecone", getURL(setup),
httpclient.WithLogger(logger),
Expand All @@ -73,16 +74,15 @@ func newIndexClient(setup *structpb.Struct, logger *zap.Logger) *httpclient.Clie
return c
}

func newPineconeBaseClient(setup *structpb.Struct, logger *zap.Logger) *httpclient.Client {
// newBaseClient creates a new httpclient.Client with the default Pinecone API URL.
func newBaseClient(setup *structpb.Struct, logger *zap.Logger) *httpclient.Client {
c := httpclient.New("Pinecone", "https://api.pinecone.io",
httpclient.WithLogger(logger),
httpclient.WithEndUserError(new(errBody)),
)

c.SetHeader("Api-Key", getAPIKey(setup))
c.SetHeader("User-Agent", "source_tag=instillai")
c.SetHeader("X-Pinecone-API-Version", "2024-10") // TODO: Remove this once 2024-10 or above is default

return c
}

Expand Down Expand Up @@ -164,7 +164,7 @@ func (e *execution) Execute(ctx context.Context, jobs []*base.Job) error {
}
case taskRerank:
// rerank task does not need index URL, so using the base client with the default pinecone API URL.
req := newPineconeBaseClient(e.Setup, e.GetLogger()).R()
req := newBaseClient(e.Setup, e.GetLogger()).R()

// parse input struct
inputStruct := rerankInput{}
Expand Down

0 comments on commit dd8c27f

Please sign in to comment.