Skip to content

Commit

Permalink
feat(api): add text embeddings dimensions param (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot authored Jan 25, 2024
1 parent 7e4b903 commit 1b5a977
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
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

0 comments on commit 1b5a977

Please sign in to comment.