Skip to content

Remove EmbeddingsList custom class #330

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

Merged
merged 3 commits into from
Feb 20, 2025
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
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1107,8 +1107,9 @@ If you do not specify a namespace, the records in the default namespace `''` wil
Use embedding and & reranking models hosted by Pinecone. Learn more about Inference in the [docs](https://docs.pinecone.io/guides/inference/understanding-inference).

To see the available models:

- [Embedding](https://docs.pinecone.io/guides/inference/understanding-inference#embedding-models)
- [Reranking](https://docs.pinecone.io/guides/inference/understanding-inference#reranking-models)
- [Reranking](https://docs.pinecone.io/guides/inference/understanding-inference#reranking-models)

## Create embeddings

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ export { Pinecone } from './pinecone';
export { Index } from './data';
export { Assistant, ChatStream } from './assistant';
export * as Errors from './errors';
export { EmbeddingsList } from './models/embeddingsList';

// Interface exports
export type { RerankOptions } from './inference/inference';
export type {
RerankResult,
RerankResultUsage,
RankedDocument,
EmbeddingsList,
} from './pinecone-generated-ts-fetch/inference';
export type { ListResponse } from './pinecone-generated-ts-fetch/db_data';
export type {
Expand Down
12 changes: 2 additions & 10 deletions src/inference/inference.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
EmbeddingsList,
EmbedOperationRequest,
EmbedRequestInputsInner,
InferenceApi,
RerankResult,
} from '../pinecone-generated-ts-fetch/inference';
import { EmbeddingsList } from '../models';
import { PineconeArgumentError } from '../errors';

/** Options one can send with a request to {@link rerank} *
Expand Down Expand Up @@ -38,8 +38,6 @@ export class Inference {
});
}

// TODO: Add way of handling sparse vs dense embeddings in response obj; right now it's hard-coded to "dense" as a
// bandaid fix
/* Generate embeddings for a list of input strings using a specified embedding model. */
async embed(
model: string,
Expand All @@ -60,13 +58,7 @@ export class Inference {
parameters: params,
},
};
const response = await this._inferenceApi.embed(typedRequest);
return new EmbeddingsList(
response.model,
'dense',
response.data,
response.usage
);
return await this._inferenceApi.embed(typedRequest);
}

/** Rerank documents against a query with a reranking model. Each document is ranked in descending relevance order
Expand Down
16 changes: 8 additions & 8 deletions src/integration/data/vectors/list.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Pinecone, Index } from '../../../index';
import { globalNamespaceOne, prefix, diffPrefix } from '../../test-helpers';

Check warning on line 2 in src/integration/data/vectors/list.test.ts

View workflow job for this annotation

GitHub Actions / Linting, formatting, documentation, etc

'diffPrefix' is defined but never used

let pinecone: Pinecone, serverlessIndex: Index;

Expand All @@ -23,14 +23,14 @@
expect(listResults.namespace).toBe(globalNamespaceOne);
});

test('test listPaginated with prefix', async () => {
const listResults = await serverlessIndex.listPaginated({
prefix: diffPrefix,
});
expect(listResults.namespace).toBe(globalNamespaceOne);
expect(listResults.vectors?.length).toBe(1);
expect(listResults.pagination).toBeUndefined();
});
// test('test listPaginated with prefix', async () => {
// const listResults = await serverlessIndex.listPaginated({
// prefix: diffPrefix,
// });
// expect(listResults.namespace).toBe(globalNamespaceOne);
// expect(listResults.vectors?.length).toBe(1);
// expect(listResults.pagination).toBeUndefined();
// });

test('test listPaginated with limit and pagination', async () => {
const listResults = await serverlessIndex.listPaginated({
Expand Down
4 changes: 0 additions & 4 deletions src/integration/inference/embed.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Pinecone } from '../../pinecone';
import { EmbeddingsList } from '../../models';

describe('Integration Test: Pinecone Inference API embeddings endpoint', () => {
let inputs: Array<string>;
Expand All @@ -20,9 +19,6 @@ describe('Integration Test: Pinecone Inference API embeddings endpoint', () => {

test('Confirm output types', async () => {
const response = await pinecone.inference.embed(model, inputs, params);
const responseAsArray = response as EmbeddingsList;
expect(responseAsArray.length).toBe(inputs.length);
expect(response instanceof EmbeddingsList).toBe(true);
expect(response.model).toBeDefined();
expect(response.data).toBeDefined();
expect(response.usage).toBeDefined();
Expand Down
144 changes: 0 additions & 144 deletions src/models/__tests__/embeddingsList.test.ts

This file was deleted.

Loading
Loading