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
894f950e
authored
Mar 03, 2025
by
1808837298@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: vertex claude
parent
d499b641
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
13 deletions
+27
-13
relay/channel/aws/dto.go
+1
-1
relay/channel/claude/dto.go
+1
-1
relay/channel/vertex/adaptor.go
+1
-7
relay/channel/vertex/dto.go
+24
-4
No files found.
relay/channel/aws/dto.go
View file @
894f950e
...
...
@@ -14,7 +14,7 @@ type AwsClaudeRequest struct {
TopP
float64
`json:"top_p,omitempty"`
TopK
int
`json:"top_k,omitempty"`
StopSequences
[]
string
`json:"stop_sequences,omitempty"`
Tools
[]
claude
.
Tool
`json:"tools,omitempty"`
Tools
any
`json:"tools,omitempty"`
ToolChoice
any
`json:"tool_choice,omitempty"`
Thinking
*
claude
.
Thinking
`json:"thinking,omitempty"`
}
...
...
relay/channel/claude/dto.go
View file @
894f950e
...
...
@@ -58,7 +58,7 @@ type ClaudeRequest struct {
TopK
int
`json:"top_k,omitempty"`
//ClaudeMetadata `json:"metadata,omitempty"`
Stream
bool
`json:"stream,omitempty"`
Tools
[]
Tool
`json:"tools,omitempty"`
Tools
any
`json:"tools,omitempty"`
ToolChoice
any
`json:"tool_choice,omitempty"`
Thinking
*
Thinking
`json:"thinking,omitempty"`
}
...
...
relay/channel/vertex/adaptor.go
View file @
894f950e
...
...
@@ -5,7 +5,6 @@ import (
"errors"
"fmt"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
"io"
"net/http"
"one-api/dto"
...
...
@@ -127,12 +126,7 @@ func (a *Adaptor) ConvertRequest(c *gin.Context, info *relaycommon.RelayInfo, re
if
err
!=
nil
{
return
nil
,
err
}
vertexClaudeReq
:=
&
VertexAIClaudeRequest
{
AnthropicVersion
:
anthropicVersion
,
}
if
err
=
copier
.
Copy
(
vertexClaudeReq
,
claudeReq
);
err
!=
nil
{
return
nil
,
errors
.
New
(
"failed to copy claude request"
)
}
vertexClaudeReq
:=
copyRequest
(
claudeReq
,
anthropicVersion
)
c
.
Set
(
"request_model"
,
claudeReq
.
Model
)
return
vertexClaudeReq
,
nil
}
else
if
a
.
RequestMode
==
RequestModeGemini
{
...
...
relay/channel/vertex/dto.go
View file @
894f950e
package
vertex
import
"one-api/relay/channel/claude"
import
(
"one-api/relay/channel/claude"
)
type
VertexAIClaudeRequest
struct
{
AnthropicVersion
string
`json:"anthropic_version"`
Messages
[]
claude
.
ClaudeMessage
`json:"messages"`
System
string
`json:"system,omitempty"`
MaxTokens
int
`json:"max_tokens,omitempty"`
System
any
`json:"system,omitempty"`
MaxTokens
uint
`json:"max_tokens,omitempty"`
StopSequences
[]
string
`json:"stop_sequences,omitempty"`
Stream
bool
`json:"stream,omitempty"`
Temperature
*
float64
`json:"temperature,omitempty"`
TopP
float64
`json:"top_p,omitempty"`
TopK
int
`json:"top_k,omitempty"`
Tools
[]
claude
.
Tool
`json:"tools,omitempty"`
Tools
any
`json:"tools,omitempty"`
ToolChoice
any
`json:"tool_choice,omitempty"`
Thinking
*
claude
.
Thinking
`json:"thinking,omitempty"`
}
func
copyRequest
(
req
*
claude
.
ClaudeRequest
,
version
string
)
*
VertexAIClaudeRequest
{
return
&
VertexAIClaudeRequest
{
AnthropicVersion
:
version
,
System
:
req
.
System
,
Messages
:
req
.
Messages
,
MaxTokens
:
req
.
MaxTokens
,
Stream
:
req
.
Stream
,
Temperature
:
req
.
Temperature
,
TopP
:
req
.
TopP
,
TopK
:
req
.
TopK
,
StopSequences
:
req
.
StopSequences
,
Tools
:
req
.
Tools
,
ToolChoice
:
req
.
ToolChoice
,
Thinking
:
req
.
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