Skip to content

Commit

Permalink
[Go] register Pinecone actions by index ID (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
ianlancetaylor authored Jun 11, 2024
1 parent 68a11e9 commit bee1c27
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions go/plugins/pinecone/genkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ func Init(ctx context.Context, cfg Config) (err error) {
if err != nil {
return err
}
host := indexData.Host
index, err := client.index(ctx, host)
index, err := client.index(ctx, indexData.Host)
if err != nil {
return err
}
Expand All @@ -91,8 +90,8 @@ func Init(ctx context.Context, cfg Config) (err error) {
embedderOptions: cfg.EmbedderOptions,
textKey: cfg.TextKey,
}
ai.DefineIndexer(provider, host, r.Index)
ai.DefineRetriever(provider, host, r.Retrieve)
ai.DefineIndexer(provider, cfg.IndexID, r.Index)
ai.DefineRetriever(provider, cfg.IndexID, r.Retrieve)
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions go/plugins/pinecone/genkit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestGenkit(t *testing.T) {
Options: indexerOptions,
}
t.Logf("index flag = %q, indexData.Host = %q", *testIndex, indexData.Host)
err = ai.Index(ctx, Indexer(indexData.Host), indexerReq)
err = ai.Index(ctx, Indexer(*testIndex), indexerReq)
if err != nil {
t.Fatalf("Index operation failed: %v", err)
}
Expand Down Expand Up @@ -127,7 +127,7 @@ func TestGenkit(t *testing.T) {
Document: d1,
Options: retrieverOptions,
}
retrieverResp, err := ai.Retrieve(ctx, Retriever(indexData.Host), retrieverReq)
retrieverResp, err := ai.Retrieve(ctx, Retriever(*testIndex), retrieverReq)
if err != nil {
t.Fatalf("Retrieve operation failed: %v", err)
}
Expand Down

0 comments on commit bee1c27

Please sign in to comment.