Skip to content

Commit b173b05

Browse files
feat(api): adding temperature parameter (#742)
1 parent 7b1e593 commit b173b05

File tree

5 files changed

+66
-15
lines changed

5 files changed

+66
-15
lines changed

Diff for: src/resources/beta/threads/messages/messages.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -353,9 +353,9 @@ export interface Message {
353353
role: 'user' | 'assistant';
354354

355355
/**
356-
* If applicable, the ID of the
357-
* [run](https://platform.openai.com/docs/api-reference/runs) associated with the
358-
* authoring of this message.
356+
* The ID of the [run](https://platform.openai.com/docs/api-reference/runs)
357+
* associated with the creation of this message. Value is `null` when messages are
358+
* created manually using the create message or create thread endpoints.
359359
*/
360360
run_id: string | null;
361361

@@ -501,10 +501,14 @@ export interface MessageCreateParams {
501501
content: string;
502502

503503
/**
504-
* The role of the entity that is creating the message. Currently only `user` is
505-
* supported.
504+
* The role of the entity that is creating the message. Allowed values include:
505+
*
506+
* - `user`: Indicates the message is sent by an actual user and should be used in
507+
* most cases to represent user-generated messages.
508+
* - `assistant`: Indicates the message is generated by the assistant. Use this
509+
* value to insert messages from the assistant into the conversation.
506510
*/
507-
role: 'user';
511+
role: 'user' | 'assistant';
508512

509513
/**
510514
* A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that

Diff for: src/resources/beta/threads/runs/runs.ts

+19
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,11 @@ export interface Run {
331331
* in a terminal state (i.e. `in_progress`, `queued`, etc.).
332332
*/
333333
usage: Run.Usage | null;
334+
335+
/**
336+
* The sampling temperature used for this run. If not set, defaults to 1.
337+
*/
338+
temperature?: number | null;
334339
}
335340

336341
export namespace Run {
@@ -461,6 +466,13 @@ export interface RunCreateParamsBase {
461466
*/
462467
stream?: boolean | null;
463468

469+
/**
470+
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
471+
* make the output more random, while lower values like 0.2 will make it more
472+
* focused and deterministic.
473+
*/
474+
temperature?: number | null;
475+
464476
/**
465477
* Override the tools the assistant can use for this run. This is useful for
466478
* modifying the behavior on a per-run basis.
@@ -555,6 +567,13 @@ export interface RunCreateAndStreamParams {
555567
*/
556568
model?: string | null;
557569

570+
/**
571+
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
572+
* make the output more random, while lower values like 0.2 will make it more
573+
* focused and deterministic.
574+
*/
575+
temperature?: number | null;
576+
558577
/**
559578
* Override the tools the assistant can use for this run. This is useful for
560579
* modifying the behavior on a per-run basis.

Diff for: src/resources/beta/threads/threads.ts

+35-9
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,14 @@ export namespace ThreadCreateParams {
164164
content: string;
165165

166166
/**
167-
* The role of the entity that is creating the message. Currently only `user` is
168-
* supported.
167+
* The role of the entity that is creating the message. Allowed values include:
168+
*
169+
* - `user`: Indicates the message is sent by an actual user and should be used in
170+
* most cases to represent user-generated messages.
171+
* - `assistant`: Indicates the message is generated by the assistant. Use this
172+
* value to insert messages from the assistant into the conversation.
169173
*/
170-
role: 'user';
174+
role: 'user' | 'assistant';
171175

172176
/**
173177
* A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
@@ -238,6 +242,13 @@ export interface ThreadCreateAndRunParamsBase {
238242
*/
239243
stream?: boolean | null;
240244

245+
/**
246+
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
247+
* make the output more random, while lower values like 0.2 will make it more
248+
* focused and deterministic.
249+
*/
250+
temperature?: number | null;
251+
241252
/**
242253
* If no thread is provided, an empty thread will be created.
243254
*/
@@ -280,10 +291,14 @@ export namespace ThreadCreateAndRunParams {
280291
content: string;
281292

282293
/**
283-
* The role of the entity that is creating the message. Currently only `user` is
284-
* supported.
294+
* The role of the entity that is creating the message. Allowed values include:
295+
*
296+
* - `user`: Indicates the message is sent by an actual user and should be used in
297+
* most cases to represent user-generated messages.
298+
* - `assistant`: Indicates the message is generated by the assistant. Use this
299+
* value to insert messages from the assistant into the conversation.
285300
*/
286-
role: 'user';
301+
role: 'user' | 'assistant';
287302

288303
/**
289304
* A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
@@ -355,6 +370,13 @@ export interface ThreadCreateAndRunStreamParams {
355370
*/
356371
model?: string | null;
357372

373+
/**
374+
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
375+
* make the output more random, while lower values like 0.2 will make it more
376+
* focused and deterministic.
377+
*/
378+
temperature?: number | null;
379+
358380
/**
359381
* If no thread is provided, an empty thread will be created.
360382
*/
@@ -397,10 +419,14 @@ export namespace ThreadCreateAndRunStreamParams {
397419
content: string;
398420

399421
/**
400-
* The role of the entity that is creating the message. Currently only `user` is
401-
* supported.
422+
* The role of the entity that is creating the message. Allowed values include:
423+
*
424+
* - `user`: Indicates the message is sent by an actual user and should be used in
425+
* most cases to represent user-generated messages.
426+
* - `assistant`: Indicates the message is generated by the assistant. Use this
427+
* value to insert messages from the assistant into the conversation.
402428
*/
403-
role: 'user';
429+
role: 'user' | 'assistant';
404430

405431
/**
406432
* A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that

Diff for: tests/api-resources/beta/threads/runs/runs.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ describe('resource runs', () => {
2828
metadata: {},
2929
model: 'string',
3030
stream: false,
31+
temperature: 1,
3132
tools: [{ type: 'code_interpreter' }, { type: 'code_interpreter' }, { type: 'code_interpreter' }],
3233
});
3334
});

Diff for: tests/api-resources/beta/threads/threads.test.ts

+1
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ describe('resource threads', () => {
109109
metadata: {},
110110
model: 'string',
111111
stream: false,
112+
temperature: 1,
112113
thread: {
113114
messages: [
114115
{ role: 'user', content: 'x', file_ids: ['string'], metadata: {} },

0 commit comments

Comments
 (0)