feat(thinkingControl): implement thinking mode configuration in model editor
- Added a new thinking mode control field in the ModelEditorDialog, allowing users to specify how the agent's thinking mode is formatted for API requests. - Introduced localization strings for thinking mode labels and descriptions in English, Korean, Russian, and Chinese, enhancing user experience across multiple languages. - Updated the model form data structure to include thinking control settings, ensuring proper handling during model edits and saves. - Implemented utility functions for resolving and defaulting thinking control values based on provider and model, improving backend integration. - Added tests for the new thinking control functionality to ensure reliability and correctness in handling user configurations.
This commit is contained in:
@@ -153,6 +153,7 @@ func (c *AnthropicChat) Chat(ctx context.Context, messages []Message, opts *Chat
|
||||
if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices {
|
||||
return nil, fmt.Errorf("API request failed with status %d: %s", resp.StatusCode, chatResp.Content)
|
||||
}
|
||||
logUsage(ctx, c.modelName, &chatResp.Usage)
|
||||
return chatResp, nil
|
||||
}
|
||||
|
||||
@@ -167,7 +168,9 @@ func (c *AnthropicChat) Chat(ctx context.Context, messages []Message, opts *Chat
|
||||
return nil, fmt.Errorf("API request failed with status %d: %s", resp.StatusCode, string(body))
|
||||
}
|
||||
|
||||
return c.parseResponse(&chatResp), nil
|
||||
result := c.parseResponse(&chatResp)
|
||||
logUsage(ctx, c.modelName, &result.Usage)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *AnthropicChat) ChatStream(ctx context.Context, messages []Message, opts *ChatOptions) (<-chan types.StreamResponse, error) {
|
||||
@@ -204,7 +207,7 @@ func (c *AnthropicChat) ChatStream(ctx context.Context, messages []Message, opts
|
||||
}
|
||||
|
||||
streamChan := make(chan types.StreamResponse)
|
||||
go processAnthropicStream(resp, streamChan)
|
||||
go processAnthropicStream(ctx, c.modelName, resp, streamChan)
|
||||
return streamChan, nil
|
||||
}
|
||||
|
||||
@@ -382,7 +385,7 @@ func parseAnthropicSSE(reader io.Reader) (*types.ChatResponse, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func processAnthropicStream(resp *http.Response, streamChan chan types.StreamResponse) {
|
||||
func processAnthropicStream(ctx context.Context, model string, resp *http.Response, streamChan chan types.StreamResponse) {
|
||||
defer close(streamChan)
|
||||
defer resp.Body.Close()
|
||||
|
||||
@@ -394,6 +397,7 @@ func processAnthropicStream(resp *http.Response, streamChan chan types.StreamRes
|
||||
event, err := sseReader.ReadEvent()
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
logUsage(ctx, model, usage)
|
||||
streamChan <- types.StreamResponse{
|
||||
ResponseType: types.ResponseTypeAnswer,
|
||||
Content: "",
|
||||
@@ -411,6 +415,7 @@ func processAnthropicStream(resp *http.Response, streamChan chan types.StreamRes
|
||||
return
|
||||
}
|
||||
if event.Done {
|
||||
logUsage(ctx, model, usage)
|
||||
streamChan <- types.StreamResponse{
|
||||
ResponseType: types.ResponseTypeAnswer,
|
||||
Content: "",
|
||||
|
||||
Reference in New Issue
Block a user