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

[spruce] Regenerate OpenAPI core, update query and fetch to return usage / readUnits #183

Merged
merged 3 commits into from
Jan 11, 2024

Conversation

austin-denoble
Copy link
Contributor

@austin-denoble austin-denoble commented Jan 10, 2024

Problem

The backend is now support readUnits in responses for the query and fetch operations. We've updated the vector_service.proto file to include the new response shapes, and this needs to be pulled into the clients: https://github.com/pinecone-io/pinecone-protos/pull/105

Solution

  • Regenerate pinecone-generated-ts-fetch core and drop it in. This includes @haruska's updates to our tags, thus the renaming of ManagePodIndexesApi -> ManageIndexesApi.
  • Add new OperationUsage type to /src/data/types.ts (open to changing the name OperationUsage).
  • Update our custom types for QueryResponse and FetchResponse to include usage.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Test Plan

You will need to call either fetch() or query() and validate the field is returned in the response.

await client.index('test-dim-2').fetch(['1', '2'])

// {
//   records: {
//     '1': {
//       id: '1',
//       values: [Array],
//       sparseValues: undefined,
//       metadata: undefined
//     },
//     '2': {
//       id: '2',
//       values: [Array],
//       sparseValues: undefined,
//       metadata: undefined
//     }
//   },
//   namespace: '',
//   usage: { readUnits: 1 }
// }

await client.index('test-dim-2').query({ vector: [0.2, 0.3], topK: 5, includeValues: true })

// {
//   matches: [
//     {
//       id: '1',
//       score: 1.00242746,
//       values: [Array],
//       sparseValues: undefined,
//       metadata: undefined
//     },
//     {
//       id: '2',
//       score: 1.00034547,
//       values: [Array],
//       sparseValues: undefined,
//       metadata: undefined
//     }
//   ],
//   namespace: '',
//   usage: { readUnits: 5 }
// }

@austin-denoble austin-denoble changed the title [spruce] Update query and fetch to return usage / readUnits [spruce] Regenerate OpenAPI core, update query and fetch to return usage / readUnits Jan 10, 2024
Copy link

@haruska haruska left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. Thanks for updating to the new interface!

@austin-denoble austin-denoble force-pushed the adenoble/regenerate-openapi-core branch from ca8bea5 to d0a6210 Compare January 11, 2024 21:47
@austin-denoble austin-denoble merged commit 822834b into spruce Jan 11, 2024
20 checks passed
@austin-denoble austin-denoble deleted the adenoble/regenerate-openapi-core branch January 11, 2024 22:07
austin-denoble added a commit that referenced this pull request Jan 13, 2024
…age / readUnits (#183)

## Problem
The backend is now support `readUnits` in responses for the `query` and
`fetch` operations. We've updated the `vector_service.proto` file to
include the new response shapes, and this needs to be pulled into the
clients: pinecone-io/pinecone-protos#105

## Solution
- Regenerate `pinecone-generated-ts-fetch` core and drop it in. This
includes @haruska's updates to our tags, thus the renaming of
`ManagePodIndexesApi` -> `ManageIndexesApi`.
- Add new `OperationUsage` type to `/src/data/types.ts` (open to
changing the name `OperationUsage`).
- Update our custom types for `QueryResponse` and `FetchResponse` to
include `usage`.

## Type of Change
- [X] New feature (non-breaking change which adds functionality)
- [X] This change requires a documentation update

## Test Plan
You will need to call either `fetch()` or `query()` and validate the
field is returned in the response.

```
await client.index('test-dim-2').fetch(['1', '2'])

// {
//   records: {
//     '1': {
//       id: '1',
//       values: [Array],
//       sparseValues: undefined,
//       metadata: undefined
//     },
//     '2': {
//       id: '2',
//       values: [Array],
//       sparseValues: undefined,
//       metadata: undefined
//     }
//   },
//   namespace: '',
//   usage: { readUnits: 1 }
// }

await client.index('test-dim-2').query({ vector: [0.2, 0.3], topK: 5, includeValues: true })

// {
//   matches: [
//     {
//       id: '1',
//       score: 1.00242746,
//       values: [Array],
//       sparseValues: undefined,
//       metadata: undefined
//     },
//     {
//       id: '2',
//       score: 1.00034547,
//       values: [Array],
//       sparseValues: undefined,
//       metadata: undefined
//     }
//   ],
//   namespace: '',
//   usage: { readUnits: 5 }
// }
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants