Skip to content

Commit

Permalink
add cost saving parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
qhenkart committed Apr 15, 2024
1 parent 95428cb commit b65c6c4
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ type Run struct {
Metadata map[string]any `json:"metadata"`
Usage Usage `json:"usage,omitempty"`

Temperature *int `json:"temperature,omitempty"`
// The maximum number of prompt tokens that may be used over the course of the run.
// If the run exceeds the number of prompt tokens specified, the run will end with status 'complete'
MaxPromptTokens int `json:"max_prompt_tokens,omitempty"`
// The maximum number of completion tokens that may be used over the course of the run.
// If the run exceeds the number of completion tokens specified, the run will end with status 'complete'
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`
// ThreadTruncationStrategy defines the truncation strategy to use for the thread
TruncationStrategy *ThreadTruncationStrategy `json:"truncation_strategy,omitempty"`

httpHeader
}

Expand Down Expand Up @@ -78,8 +88,41 @@ type RunRequest struct {
AdditionalInstructions string `json:"additional_instructions,omitempty"`
Tools []Tool `json:"tools,omitempty"`
Metadata map[string]any `json:"metadata,omitempty"`

// 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.

Check failure on line 92 in run.go

View workflow job for this annotation

GitHub Actions / Sanity check

line is 184 characters (lll)
Temperature *int `json:"temperature,omitempty"`

// The maximum number of prompt tokens that may be used over the course of the run.
// If the run exceeds the number of prompt tokens specified, the run will end with status 'complete'
MaxPromptTokens int `json:"max_prompt_tokens,omitempty"`

// The maximum number of completion tokens that may be used over the course of the run.
// If the run exceeds the number of completion tokens specified, the run will end with status 'complete'
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`

// ThreadTruncationStrategy defines the truncation strategy to use for the thread
TruncationStrategy *ThreadTruncationStrategy `json:"truncation_strategy,omitempty"`
}

// ThreadTruncationStrategy defines the truncation strategy to use for the thread
// https://platform.openai.com/docs/assistants/how-it-works/truncation-strategy
type ThreadTruncationStrategy struct {
// default 'auto'
Type TruncationStrategy `json:"type,omitempty"`
// this field should be set if the truncation strategy is set to LastMessages
LastMessages *int `json:"last_messages,omitempty"`
}

// TruncationStrategy defines the existing truncation strategies existing for thread management in an assistant

Check failure on line 116 in run.go

View workflow job for this annotation

GitHub Actions / Sanity check

Comment should end in a period (godot)
type TruncationStrategy string

const (
// TruncationStrategyAuto messages in the middle of the thread will be dropped to fit the context length of the model

Check failure on line 120 in run.go

View workflow job for this annotation

GitHub Actions / Sanity check

Comment should end in a period (godot)
TruncationStrategyAuto = TruncationStrategy("auto")
// TruncationStrategyLastMessages the thread will be truncated to the n most recent messages in the thread

Check failure on line 122 in run.go

View workflow job for this annotation

GitHub Actions / Sanity check

Comment should end in a period (godot)
TruncationStrategyLastMessages = TruncationStrategy("last_messages")
)

type RunModifyRequest struct {
Metadata map[string]any `json:"metadata,omitempty"`
}
Expand Down

0 comments on commit b65c6c4

Please sign in to comment.