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

feat(api): add text embeddings dimensions param #650

Merged
merged 1 commit into from
Jan 25, 2024
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: 6 additions & 2 deletions src/resources/chat/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,8 @@ export interface ChatCompletionCreateParamsBase {
*/
model:
| (string & {})
| 'gpt-4-0125-preview'
| 'gpt-4-turbo-preview'
| 'gpt-4-1106-preview'
| 'gpt-4-vision-preview'
| 'gpt-4'
Expand Down Expand Up @@ -754,7 +756,8 @@ export interface ChatCompletionCreateParamsBase {

/**
* An object specifying the format that the model must output. Compatible with
* `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
* `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
* message the model generates is valid JSON.
Expand Down Expand Up @@ -874,7 +877,8 @@ export namespace ChatCompletionCreateParams {

/**
* An object specifying the format that the model must output. Compatible with
* `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
* `gpt-3.5-turbo-1106`.
*
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
* message the model generates is valid JSON.
Expand Down
8 changes: 7 additions & 1 deletion src/resources/embeddings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ export interface EmbeddingCreateParams {
* [Model overview](https://platform.openai.com/docs/models/overview) for
* descriptions of them.
*/
model: (string & {}) | 'text-embedding-ada-002';
model: (string & {}) | 'text-embedding-ada-002' | 'text-embedding-3-small' | 'text-embedding-3-large';

/**
* The number of dimensions the resulting output embeddings should have. Only
* supported in `text-embedding-3` and later models.
*/
dimensions?: number;

/**
* The format to return the embeddings in. Can be either `float` or
Expand Down
5 changes: 3 additions & 2 deletions tests/api-resources/embeddings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('resource embeddings', () => {
test('create: only required params', async () => {
const responsePromise = openai.embeddings.create({
input: 'The quick brown fox jumped over the lazy dog',
model: 'text-embedding-ada-002',
model: 'text-embedding-3-small',
});
const rawResponse = await responsePromise.asResponse();
expect(rawResponse).toBeInstanceOf(Response);
Expand All @@ -26,7 +26,8 @@ describe('resource embeddings', () => {
test('create: required and optional params', async () => {
const response = await openai.embeddings.create({
input: 'The quick brown fox jumped over the lazy dog',
model: 'text-embedding-ada-002',
model: 'text-embedding-3-small',
dimensions: 1,
encoding_format: 'float',
user: 'user-1234',
});
Expand Down