Skip to content

Commit

Permalink
feat(api): adding temperature parameter (#742)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-bot committed Mar 29, 2024
1 parent 7b1e593 commit b173b05
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 15 deletions.
16 changes: 10 additions & 6 deletions src/resources/beta/threads/messages/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,9 @@ export interface Message {
role: 'user' | 'assistant';

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

Expand Down Expand Up @@ -501,10 +501,14 @@ export interface MessageCreateParams {
content: string;

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

/**
* A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
Expand Down
19 changes: 19 additions & 0 deletions src/resources/beta/threads/runs/runs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ export interface Run {
* in a terminal state (i.e. `in_progress`, `queued`, etc.).
*/
usage: Run.Usage | null;

/**
* The sampling temperature used for this run. If not set, defaults to 1.
*/
temperature?: number | null;
}

export namespace Run {
Expand Down Expand Up @@ -461,6 +466,13 @@ export interface RunCreateParamsBase {
*/
stream?: boolean | null;

/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;

/**
* Override the tools the assistant can use for this run. This is useful for
* modifying the behavior on a per-run basis.
Expand Down Expand Up @@ -555,6 +567,13 @@ export interface RunCreateAndStreamParams {
*/
model?: string | null;

/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;

/**
* Override the tools the assistant can use for this run. This is useful for
* modifying the behavior on a per-run basis.
Expand Down
44 changes: 35 additions & 9 deletions src/resources/beta/threads/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,14 @@ export namespace ThreadCreateParams {
content: string;

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

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

/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;

/**
* If no thread is provided, an empty thread will be created.
*/
Expand Down Expand Up @@ -280,10 +291,14 @@ export namespace ThreadCreateAndRunParams {
content: string;

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

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

/**
* What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
* make the output more random, while lower values like 0.2 will make it more
* focused and deterministic.
*/
temperature?: number | null;

/**
* If no thread is provided, an empty thread will be created.
*/
Expand Down Expand Up @@ -397,10 +419,14 @@ export namespace ThreadCreateAndRunStreamParams {
content: string;

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

/**
* A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
Expand Down
1 change: 1 addition & 0 deletions tests/api-resources/beta/threads/runs/runs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('resource runs', () => {
metadata: {},
model: 'string',
stream: false,
temperature: 1,
tools: [{ type: 'code_interpreter' }, { type: 'code_interpreter' }, { type: 'code_interpreter' }],
});
});
Expand Down
1 change: 1 addition & 0 deletions tests/api-resources/beta/threads/threads.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ describe('resource threads', () => {
metadata: {},
model: 'string',
stream: false,
temperature: 1,
thread: {
messages: [
{ role: 'user', content: 'x', file_ids: ['string'], metadata: {} },
Expand Down

0 comments on commit b173b05

Please sign in to comment.