Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5ba44f5a
authored
Feb 25, 2025
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Update Claude relay temperature setting
parent
d04d78a1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
common/utils.go
+19
-0
relay/channel/claude/relay-claude.go
+3
-0
No files found.
common/utils.go
View file @
5ba44f5a
...
...
@@ -5,6 +5,7 @@ import (
"context"
crand
"crypto/rand"
"encoding/base64"
"encoding/json"
"fmt"
"github.com/pkg/errors"
"html/template"
...
...
@@ -213,6 +214,24 @@ func RandomSleep() {
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.
func
SaveTmpFile
(
filename
string
,
data
io
.
Reader
)
(
string
,
error
)
{
f
,
err
:=
os
.
CreateTemp
(
os
.
TempDir
(),
filename
)
...
...
relay/channel/claude/relay-claude.go
View file @
5ba44f5a
...
...
@@ -108,7 +108,10 @@ func RequestOpenAI2ClaudeMessage(textRequest dto.GeneralOpenAIRequest) (*ClaudeR
Type
:
"enabled"
,
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
.
Temperature
=
common
.
GetPointer
[
float64
](
1.0
)
claudeRequest
.
Model
=
strings
.
TrimSuffix
(
textRequest
.
Model
,
"-thinking"
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment