feat: Update Claude relay temperature setting
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
crand "crypto/rand"
|
crand "crypto/rand"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"html/template"
|
"html/template"
|
||||||
@@ -213,6 +214,24 @@ func RandomSleep() {
|
|||||||
time.Sleep(time.Duration(rand.Intn(3000)) * time.Millisecond)
|
time.Sleep(time.Duration(rand.Intn(3000)) * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetPointer[T any](v T) *T {
|
||||||
|
return &v
|
||||||
|
}
|
||||||
|
|
||||||
|
func Any2Type[T any](data any) (T, error) {
|
||||||
|
var zero T
|
||||||
|
bytes, err := json.Marshal(data)
|
||||||
|
if err != nil {
|
||||||
|
return zero, err
|
||||||
|
}
|
||||||
|
var res T
|
||||||
|
err = json.Unmarshal(bytes, &res)
|
||||||
|
if err != nil {
|
||||||
|
return zero, err
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
|
|
||||||
// SaveTmpFile saves data to a temporary file. The filename would be apppended with a random string.
|
// SaveTmpFile saves data to a temporary file. The filename would be apppended with a random string.
|
||||||
func SaveTmpFile(filename string, data io.Reader) (string, error) {
|
func SaveTmpFile(filename string, data io.Reader) (string, error) {
|
||||||
f, err := os.CreateTemp(os.TempDir(), filename)
|
f, err := os.CreateTemp(os.TempDir(), filename)
|
||||||
|
|||||||
@@ -108,7 +108,10 @@ func RequestOpenAI2ClaudeMessage(textRequest dto.GeneralOpenAIRequest) (*ClaudeR
|
|||||||
Type: "enabled",
|
Type: "enabled",
|
||||||
BudgetTokens: int(float64(claudeRequest.MaxTokens) * 0.8),
|
BudgetTokens: int(float64(claudeRequest.MaxTokens) * 0.8),
|
||||||
}
|
}
|
||||||
|
// TODO: 临时处理
|
||||||
|
// https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking#important-considerations-when-using-extended-thinking
|
||||||
claudeRequest.TopP = 0
|
claudeRequest.TopP = 0
|
||||||
|
claudeRequest.Temperature = common.GetPointer[float64](1.0)
|
||||||
claudeRequest.Model = strings.TrimSuffix(textRequest.Model, "-thinking")
|
claudeRequest.Model = strings.TrimSuffix(textRequest.Model, "-thinking")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user