Skip to content

Commit

Permalink
Add GET /vectors/list endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
A Terebey authored and ScotterC committed Aug 7, 2024
1 parent 9da85ce commit 1f63beb
Show file tree
Hide file tree
Showing 8 changed files with 760 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ index.fetch(
)
```

List vector IDs from an index (only for serverless indexes)
```ruby
pinecone = Pinecone::Client.new
index = pinecone.index("example-index")
index.list(
namespace: "example-namespace",
prefix: "example-prefix",
limit: 50,
pagination_token: "example-token"
)
```

Updating a vector in an index
```ruby
pinecone = Pinecone::Client.new
Expand Down Expand Up @@ -255,6 +267,7 @@ Contributions welcome!
- Clone the repo locally
- `bundle` to install gems
- run tests with `rspec`
- run linter with `standardrb`
- `mv .env.copy .env` and add Pinecone API Key if developing a new endpoint or modifying existing ones
- to disable VCR and hit real endpoints, `NO_VCR=true rspec`
- To setup cloud indexes when writing new tests `ruby spec/support/setup.rb start` and `stop` to delete them
Expand Down
11 changes: 11 additions & 0 deletions lib/pinecone/vector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ def fetch(namespace: "", ids: [])
self.class.get("#{@base_uri}/vectors/fetch?#{query_string}", options)
end

def list(namespace: "", prefix: "", limit: nil, pagination_token: "")
query_params = {}
query_params["namespace"] = namespace unless namespace.empty?
query_params["prefix"] = prefix unless prefix.empty?
query_params["limit"] = limit if limit
query_params["paginationToken"] = pagination_token unless pagination_token.empty?

query_string = URI.encode_www_form(query_params)
self.class.get("#{@base_uri}/vectors/list?#{query_string}", options)
end

def upsert(body)
payload = options.merge(body: body.to_json)
self.class.post("#{@base_uri}/vectors/upsert", payload)
Expand Down

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

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

Loading

0 comments on commit 1f63beb

Please sign in to comment.