Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EmbedResponse type, regenerate core for 2024-10 #83

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions internal/gen/db_control/db_control_2024-10.oas.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/gen/db_data/rest/db_data_2024-10.oas.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 24 additions & 8 deletions pinecone/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,14 @@ func (c *Client) DeleteCollection(ctx context.Context, collectionName string) er
return nil
}

// InferenceService is a struct which exposes methods for interacting with the Pinecone Inference API. InferenceService
// can be accessed via the Client object through the Client.Inference namespace.
//
// [Pinecone Inference API]: https://docs.pinecone.io/guides/inference/understanding-inference#embedding-models
type InferenceService struct {
client *inference.Client
}

// EmbedRequest holds the parameters for generating embeddings for a list of input strings.
//
// Fields:
Expand All @@ -1248,12 +1256,20 @@ type EmbedParameters struct {
Truncate string
}

// InferenceService is a struct which exposes methods for interacting with the Pinecone Inference API. InferenceService
// can be accessed via the Client object through the Client.Inference namespace.
// EmbedResponse represents holds the embeddings generated for a single input.
//
// [Pinecone Inference API]: https://docs.pinecone.io/guides/inference/understanding-inference#embedding-models
type InferenceService struct {
client *inference.Client
// Fields:
// - Data: A list of Embedding objects containing the embeddings generated for the input.
// - Model: The model used to generate the embeddings.
// - Usage: Usage statistics ([Total Tokens]) for the request.
//
// [Total Tokens]: https://docs.pinecone.io/guides/organizations/manage-cost/understanding-cost#embed
type EmbedResponse struct {
Data []Embedding `json:"data"`
Model string `json:"model"`
Usage struct {
TotalTokens *int `json:"total_tokens,omitempty"`
} `json:"usage"`
}

// Embed generates embeddings for a list of inputs using the specified model and (optional) parameters.
Expand Down Expand Up @@ -1298,7 +1314,7 @@ type InferenceService struct {
// } else {
// fmt.Printf("Successfull generated embeddings: %+v", res)
// }
func (i *InferenceService) Embed(ctx context.Context, in *EmbedRequest) (*inference.EmbeddingsList, error) {
func (i *InferenceService) Embed(ctx context.Context, in *EmbedRequest) (*EmbedResponse, error) {

if len(in.TextInputs) == 0 {
return nil, fmt.Errorf("TextInputs must contain at least one value")
Expand Down Expand Up @@ -1537,8 +1553,8 @@ func decodeIndex(resBody io.ReadCloser) (*Index, error) {
return toIndex(&idx), nil
}

func decodeEmbeddingsList(resBody io.ReadCloser) (*inference.EmbeddingsList, error) {
var embeddingsList inference.EmbeddingsList
func decodeEmbeddingsList(resBody io.ReadCloser) (*EmbedResponse, error) {
var embeddingsList EmbedResponse
err := json.NewDecoder(resBody).Decode(&embeddingsList)
if err != nil {
return nil, fmt.Errorf("failed to decode embeddings response: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion pinecone/index_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -1065,7 +1065,7 @@ func (idx *IndexConnection) StartImport(ctx context.Context, uri string, integra
}

req := db_data_rest.StartImportRequest{
Uri: &uri,
Uri: uri,
IntegrationId: integrationId,
}

Expand Down
7 changes: 7 additions & 0 deletions pinecone/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,13 @@ type MetadataFilter = structpb.Struct
// [attached to, or updated for, a vector]: https://docs.pinecone.io/guides/data/filter-with-metadata#inserting-metadata-into-an-index
type Metadata = structpb.Struct

// The embedding of a single input which is returned after [generating embeddings].
//
// [generating embeddings]: https://docs.pinecone.io/guides/inference/generate-embeddings#3-generate-embeddings
type Embedding struct {
Values *[]float32 `json:"values,omitempty"`
}

// ImportStatus represents the status of an import operation.
//
// Values:
Expand Down