Skip to content

Commit b65c6c4

Browse files
committed
add cost saving parameters
1 parent 95428cb commit b65c6c4

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

run.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ type Run struct {
2828
Metadata map[string]any `json:"metadata"`
2929
Usage Usage `json:"usage,omitempty"`
3030

31+
Temperature *int `json:"temperature,omitempty"`
32+
// The maximum number of prompt tokens that may be used over the course of the run.
33+
// If the run exceeds the number of prompt tokens specified, the run will end with status 'complete'
34+
MaxPromptTokens int `json:"max_prompt_tokens,omitempty"`
35+
// The maximum number of completion tokens that may be used over the course of the run.
36+
// If the run exceeds the number of completion tokens specified, the run will end with status 'complete'
37+
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`
38+
// ThreadTruncationStrategy defines the truncation strategy to use for the thread
39+
TruncationStrategy *ThreadTruncationStrategy `json:"truncation_strategy,omitempty"`
40+
3141
httpHeader
3242
}
3343

@@ -78,8 +88,41 @@ type RunRequest struct {
7888
AdditionalInstructions string `json:"additional_instructions,omitempty"`
7989
Tools []Tool `json:"tools,omitempty"`
8090
Metadata map[string]any `json:"metadata,omitempty"`
91+
92+
// 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.
93+
Temperature *int `json:"temperature,omitempty"`
94+
95+
// The maximum number of prompt tokens that may be used over the course of the run.
96+
// If the run exceeds the number of prompt tokens specified, the run will end with status 'complete'
97+
MaxPromptTokens int `json:"max_prompt_tokens,omitempty"`
98+
99+
// The maximum number of completion tokens that may be used over the course of the run.
100+
// If the run exceeds the number of completion tokens specified, the run will end with status 'complete'
101+
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`
102+
103+
// ThreadTruncationStrategy defines the truncation strategy to use for the thread
104+
TruncationStrategy *ThreadTruncationStrategy `json:"truncation_strategy,omitempty"`
81105
}
82106

107+
// ThreadTruncationStrategy defines the truncation strategy to use for the thread
108+
// https://platform.openai.com/docs/assistants/how-it-works/truncation-strategy
109+
type ThreadTruncationStrategy struct {
110+
// default 'auto'
111+
Type TruncationStrategy `json:"type,omitempty"`
112+
// this field should be set if the truncation strategy is set to LastMessages
113+
LastMessages *int `json:"last_messages,omitempty"`
114+
}
115+
116+
// TruncationStrategy defines the existing truncation strategies existing for thread management in an assistant
117+
type TruncationStrategy string
118+
119+
const (
120+
// TruncationStrategyAuto messages in the middle of the thread will be dropped to fit the context length of the model
121+
TruncationStrategyAuto = TruncationStrategy("auto")
122+
// TruncationStrategyLastMessages the thread will be truncated to the n most recent messages in the thread
123+
TruncationStrategyLastMessages = TruncationStrategy("last_messages")
124+
)
125+
83126
type RunModifyRequest struct {
84127
Metadata map[string]any `json:"metadata,omitempty"`
85128
}

0 commit comments

Comments
 (0)