Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
aulorbe committed Jul 31, 2024
1 parent 1b0734d commit 7df2c68
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pinecone/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ func (req CreatePodIndexRequest) TotalCount() int {
func (c *Client) CreatePodIndex(ctx context.Context, in *CreatePodIndexRequest) (*Index, error) {
requiredFields := []string{"Name", "Dimension", "Metric", "Environment", "PodType"}
if err := utils.CheckMissingFields(in, requiredFields); err != nil {
log.Fatalln("name, dimension, metric, environment, and podtype must be included in CreatePodIndexRequest")
return nil, fmt.Errorf("name, dimension, metric, environment, and podtype must be included in CreatePodIndexRequest: %w", err)
}

deletionProtection := pointerOrNil(control.DeletionProtection(in.DeletionProtection))
Expand Down Expand Up @@ -659,7 +659,7 @@ type CreateServerlessIndexRequest struct {
func (c *Client) CreateServerlessIndex(ctx context.Context, in *CreateServerlessIndexRequest) (*Index, error) {
requiredFields := []string{"Name", "Dimension", "Metric", "Cloud", "Region"}
if err := utils.CheckMissingFields(in, requiredFields); err != nil {
log.Fatalln("name, dimension, metric, cloud, and region must be included in CreateServerlessIndexRequest")
return nil, fmt.Errorf("name, dimension, metric, cloud, and region must be included in CreateServerlessIndexRequest: %w", err)
}

deletionProtection := pointerOrNil(control.DeletionProtection(in.DeletionProtection))
Expand Down Expand Up @@ -1117,7 +1117,7 @@ type CreateCollectionRequest struct {
func (c *Client) CreateCollection(ctx context.Context, in *CreateCollectionRequest) (*Collection, error) {
requiredFields := []string{"Name", "Source"}
if err := utils.CheckMissingFields(in, requiredFields); err != nil {
log.Fatalln("name and source must be included in CreateCollectionRequest")
return nil, fmt.Errorf("name and source must be included in CreateCollectionRequest: %w", err)
}

req := control.CreateCollectionRequest{
Expand Down
10 changes: 7 additions & 3 deletions pinecone/index_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,13 @@ func (idx *IndexConnection) Close() error {
// }
func (idx *IndexConnection) UpsertVectors(ctx context.Context, in []*Vector) (uint32, error) {
requiredFields := []string{"Id", "Values"}
if err := utils.CheckMissingFields(in, requiredFields); err != nil {
log.Fatalln("vectors must have at least ID and Values fields in order to be upserted")
for _, vector := range in {
if err := utils.CheckMissingFields(vector, requiredFields); err != nil {
return 0, fmt.Errorf("vectors must have at least ID and Values fields in order to be upserted: %w", err)
}
// TODO: Is it okay to return 0 here?
}
// TODO: might not want to do this for each vector in the slice b/c it's inefficient...

vectors := make([]*data.Vector, len(in))
for i, v := range in {
Expand Down Expand Up @@ -839,7 +843,7 @@ type UpdateVectorRequest struct {
func (idx *IndexConnection) UpdateVector(ctx context.Context, in *UpdateVectorRequest) error {
requiredFields := []string{"Id"}
if err := utils.CheckMissingFields(in, requiredFields); err != nil {
log.Fatalln("a vector ID plus at least one of Values, SparseValues, or Metadata must be provided to update a vector")
return fmt.Errorf("a vector ID plus at least one of Values, SparseValues, or Metadata must be provided to update a vector")
}

req := &data.UpdateRequest{
Expand Down

0 comments on commit 7df2c68

Please sign in to comment.