Skip to content

Commit 413df77

Browse files
committed
feat(api): add text embeddings dimensions param (#650)
1 parent 5ac7cb7 commit 413df77

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

src/resources/chat/completions.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,8 @@ export interface ChatCompletionCreateParamsBase {
660660
*/
661661
model:
662662
| (string & {})
663+
| 'gpt-4-0125-preview'
664+
| 'gpt-4-turbo-preview'
663665
| 'gpt-4-1106-preview'
664666
| 'gpt-4-vision-preview'
665667
| 'gpt-4'
@@ -754,7 +756,8 @@ export interface ChatCompletionCreateParamsBase {
754756

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

875878
/**
876879
* An object specifying the format that the model must output. Compatible with
877-
* `gpt-4-1106-preview` and `gpt-3.5-turbo-1106`.
880+
* [GPT-4 Turbo](https://platform.openai.com/docs/models/gpt-4-and-gpt-4-turbo) and
881+
* `gpt-3.5-turbo-1106`.
878882
*
879883
* Setting to `{ "type": "json_object" }` enables JSON mode, which guarantees the
880884
* message the model generates is valid JSON.

src/resources/embeddings.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ export interface EmbeddingCreateParams {
9696
* [Model overview](https://platform.openai.com/docs/models/overview) for
9797
* descriptions of them.
9898
*/
99-
model: (string & {}) | 'text-embedding-ada-002';
99+
model: (string & {}) | 'text-embedding-ada-002' | 'text-embedding-3-small' | 'text-embedding-3-large';
100+
101+
/**
102+
* The number of dimensions the resulting output embeddings should have. Only
103+
* supported in `text-embedding-3` and later models.
104+
*/
105+
dimensions?: number;
100106

101107
/**
102108
* The format to return the embeddings in. Can be either `float` or

tests/api-resources/embeddings.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('resource embeddings', () => {
1212
test('create: only required params', async () => {
1313
const responsePromise = openai.embeddings.create({
1414
input: 'The quick brown fox jumped over the lazy dog',
15-
model: 'text-embedding-ada-002',
15+
model: 'text-embedding-3-small',
1616
});
1717
const rawResponse = await responsePromise.asResponse();
1818
expect(rawResponse).toBeInstanceOf(Response);
@@ -26,7 +26,8 @@ describe('resource embeddings', () => {
2626
test('create: required and optional params', async () => {
2727
const response = await openai.embeddings.create({
2828
input: 'The quick brown fox jumped over the lazy dog',
29-
model: 'text-embedding-ada-002',
29+
model: 'text-embedding-3-small',
30+
dimensions: 1,
3031
encoding_format: 'float',
3132
user: 'user-1234',
3233
});

0 commit comments

Comments
 (0)