fix
This commit is contained in:
@@ -223,13 +223,6 @@ func classifyOpenAITransportErr(model string, err error) (error, bool) {
|
||||
return err, true
|
||||
}
|
||||
|
||||
type chatRequest struct {
|
||||
Model string `json:"model"`
|
||||
Messages []chatMessage `json:"messages"`
|
||||
Temperature float64 `json:"temperature"`
|
||||
MaxTokens int `json:"max_tokens,omitempty"`
|
||||
}
|
||||
|
||||
type chatMessage struct {
|
||||
Role string `json:"role"`
|
||||
Content string `json:"content"`
|
||||
@@ -283,6 +276,7 @@ func (c *OpenAIClient) CompleteWithOptions(ctx context.Context, system, user str
|
||||
temp = 0.3
|
||||
}
|
||||
maxTok := opts.MaxTokens
|
||||
effort := opts.ReasoningEffort
|
||||
|
||||
var lastErr error
|
||||
for attempt := 0; attempt <= c.MaxRetries; attempt++ {
|
||||
@@ -298,7 +292,7 @@ func (c *OpenAIClient) CompleteWithOptions(ctx context.Context, system, user str
|
||||
if err := c.waitRate(ctx); err != nil {
|
||||
return Completion{}, err
|
||||
}
|
||||
comp, retryable, err := c.doComplete(ctx, system, user, temp, maxTok)
|
||||
comp, retryable, err := c.doComplete(ctx, system, user, temp, maxTok, effort)
|
||||
if err == nil {
|
||||
return comp, nil
|
||||
}
|
||||
@@ -471,16 +465,11 @@ func (c *OpenAIClient) doEmbed(ctx context.Context, texts []string) ([][]float32
|
||||
return out, false, nil
|
||||
}
|
||||
|
||||
func (c *OpenAIClient) doComplete(ctx context.Context, system, user string, temperature float64, maxTokens int) (Completion, bool, error) {
|
||||
reqBody := chatRequest{
|
||||
Model: c.Model,
|
||||
Messages: []chatMessage{
|
||||
{Role: "system", Content: system},
|
||||
{Role: "user", Content: user},
|
||||
},
|
||||
Temperature: temperature,
|
||||
MaxTokens: maxTokens,
|
||||
}
|
||||
func (c *OpenAIClient) doComplete(ctx context.Context, system, user string, temperature float64, maxTokens int, reasoningEffort string) (Completion, bool, error) {
|
||||
reqBody := buildChatCompletionBody(c.Model, []chatMessage{
|
||||
{Role: "system", Content: system},
|
||||
{Role: "user", Content: user},
|
||||
}, temperature, maxTokens, reasoningEffort)
|
||||
body, err := json.Marshal(reqBody)
|
||||
if err != nil {
|
||||
return Completion{}, false, err
|
||||
|
||||
Reference in New Issue
Block a user