fix(llm): 移除测试用 token 限制,保留完整的推理模型 temperature 兼容与 Usage 空指针修复
This commit is contained in:
1 parent
738bce4a03
commit
16618303ed
2 files changed
+52
-1
No files matched your search
@@ -464,7 +464,7 @@ func (c *Client) ReviewStream(ctx context.Context, systemPrompt, diff string, on
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 捕获最后一个 chunk 中携带的 Usage 信息
|
// 捕获最后一个 chunk 中携带的 Usage 信息
|
||||||
if response.Usage.TotalTokens > 0 {
|
if response.Usage != nil && response.Usage.TotalTokens > 0 {
|
||||||
usage.InputTokens = response.Usage.PromptTokens
|
usage.InputTokens = response.Usage.PromptTokens
|
||||||
usage.OutputTokens = response.Usage.CompletionTokens
|
usage.OutputTokens = response.Usage.CompletionTokens
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package llm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestIsReasoningModel(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
model string
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{"o1", true},
|
||||||
|
{"o1-mini", true},
|
||||||
|
{"o1-preview", true},
|
||||||
|
{"o3-mini", true},
|
||||||
|
{"gpt-5.6-luna", true},
|
||||||
|
{"gpt-5.6-sol", true},
|
||||||
|
{"gpt-5.6-terra", true},
|
||||||
|
{"deepseek-reasoner", true},
|
||||||
|
{"gemini-3.7-flash", false},
|
||||||
|
{"claude-4.6-sonnet", false},
|
||||||
|
{"gpt-4o", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
got := isReasoningModel(tt.model)
|
||||||
|
if got != tt.expected {
|
||||||
|
t.Errorf("isReasoningModel(%q) = %v, expected %v", tt.model, got, tt.expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestIsTemperatureError(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
errStr string
|
||||||
|
expected bool
|
||||||
|
}{
|
||||||
|
{"this model has beta-limitations, temperature, top_p and n are fixed at 1", true},
|
||||||
|
{"temperature must be 1.0", true},
|
||||||
|
{"invalid api key", false},
|
||||||
|
{"rate limit exceeded", false},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
got := isTemperatureError(fmt.Errorf("%s", tt.errStr))
|
||||||
|
if got != tt.expected {
|
||||||
|
t.Errorf("isTemperatureError(%q) = %v, expected %v", tt.errStr, got, tt.expected)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user