Skip to content

Commit a42f519

Browse files
authored
[New_Features] Adds recently added Assistant cost saving parameters (#710)
* add cost saving parameters * add periods at the end of comments * shorten commnet * further lower comment length * fix type
1 parent 2446f08 commit a42f519

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

run.go

+44
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 *float32 `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,42 @@ 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+
// Sampling temperature between 0 and 2. Higher values like 0.8 are more random.
93+
// lower values are more focused and deterministic.
94+
Temperature *float32 `json:"temperature,omitempty"`
95+
96+
// The maximum number of prompt tokens that may be used over the course of the run.
97+
// If the run exceeds the number of prompt tokens specified, the run will end with status 'complete'.
98+
MaxPromptTokens int `json:"max_prompt_tokens,omitempty"`
99+
100+
// The maximum number of completion tokens that may be used over the course of the run.
101+
// If the run exceeds the number of completion tokens specified, the run will end with status 'complete'.
102+
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"`
103+
104+
// ThreadTruncationStrategy defines the truncation strategy to use for the thread.
105+
TruncationStrategy *ThreadTruncationStrategy `json:"truncation_strategy,omitempty"`
81106
}
82107

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

0 commit comments

Comments
 (0)