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
7ad5a7a1
authored
Nov 14, 2024
by
CalciumIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: aws claude
parent
b72b4f26
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
16 deletions
+19
-16
relay/channel/aws/dto.go
+17
-2
relay/channel/aws/relay-aws.go
+2
-14
No files found.
relay/channel/aws/dto.go
View file @
7ad5a7a1
...
@@ -7,9 +7,9 @@ import (
...
@@ -7,9 +7,9 @@ import (
type
AwsClaudeRequest
struct
{
type
AwsClaudeRequest
struct
{
// AnthropicVersion should be "bedrock-2023-05-31"
// AnthropicVersion should be "bedrock-2023-05-31"
AnthropicVersion
string
`json:"anthropic_version"`
AnthropicVersion
string
`json:"anthropic_version"`
System
string
`json:"system"`
System
string
`json:"system
,omitempty
"`
Messages
[]
claude
.
ClaudeMessage
`json:"messages"`
Messages
[]
claude
.
ClaudeMessage
`json:"messages"`
MaxTokens
int
`json:"max_tokens,omitempty"`
MaxTokens
uint
`json:"max_tokens,omitempty"`
Temperature
float64
`json:"temperature,omitempty"`
Temperature
float64
`json:"temperature,omitempty"`
TopP
float64
`json:"top_p,omitempty"`
TopP
float64
`json:"top_p,omitempty"`
TopK
int
`json:"top_k,omitempty"`
TopK
int
`json:"top_k,omitempty"`
...
@@ -17,3 +17,18 @@ type AwsClaudeRequest struct {
...
@@ -17,3 +17,18 @@ type AwsClaudeRequest struct {
Tools
[]
claude
.
Tool
`json:"tools,omitempty"`
Tools
[]
claude
.
Tool
`json:"tools,omitempty"`
ToolChoice
any
`json:"tool_choice,omitempty"`
ToolChoice
any
`json:"tool_choice,omitempty"`
}
}
func
copyRequest
(
req
*
claude
.
ClaudeRequest
)
*
AwsClaudeRequest
{
return
&
AwsClaudeRequest
{
AnthropicVersion
:
"bedrock-2023-05-31"
,
System
:
req
.
System
,
Messages
:
req
.
Messages
,
MaxTokens
:
req
.
MaxTokens
,
Temperature
:
req
.
Temperature
,
TopP
:
req
.
TopP
,
TopK
:
req
.
TopK
,
StopSequences
:
req
.
StopSequences
,
Tools
:
req
.
Tools
,
ToolChoice
:
req
.
ToolChoice
,
}
}
relay/channel/aws/relay-aws.go
View file @
7ad5a7a1
...
@@ -5,7 +5,6 @@ import (
...
@@ -5,7 +5,6 @@ import (
"encoding/json"
"encoding/json"
"fmt"
"fmt"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/pkg/errors"
"io"
"io"
"net/http"
"net/http"
...
@@ -78,13 +77,7 @@ func awsHandler(c *gin.Context, info *relaycommon.RelayInfo, requestMode int) (*
...
@@ -78,13 +77,7 @@ func awsHandler(c *gin.Context, info *relaycommon.RelayInfo, requestMode int) (*
return
wrapErr
(
errors
.
New
(
"request not found"
)),
nil
return
wrapErr
(
errors
.
New
(
"request not found"
)),
nil
}
}
claudeReq
:=
claudeReq_
.
(
*
claude
.
ClaudeRequest
)
claudeReq
:=
claudeReq_
.
(
*
claude
.
ClaudeRequest
)
awsClaudeReq
:=
&
AwsClaudeRequest
{
awsClaudeReq
:=
copyRequest
(
claudeReq
)
AnthropicVersion
:
"bedrock-2023-05-31"
,
}
if
err
=
copier
.
Copy
(
awsClaudeReq
,
claudeReq
);
err
!=
nil
{
return
wrapErr
(
errors
.
Wrap
(
err
,
"copy request"
)),
nil
}
awsReq
.
Body
,
err
=
json
.
Marshal
(
awsClaudeReq
)
awsReq
.
Body
,
err
=
json
.
Marshal
(
awsClaudeReq
)
if
err
!=
nil
{
if
err
!=
nil
{
return
wrapErr
(
errors
.
Wrap
(
err
,
"marshal request"
)),
nil
return
wrapErr
(
errors
.
Wrap
(
err
,
"marshal request"
)),
nil
...
@@ -136,12 +129,7 @@ func awsStreamHandler(c *gin.Context, resp *http.Response, info *relaycommon.Rel
...
@@ -136,12 +129,7 @@ func awsStreamHandler(c *gin.Context, resp *http.Response, info *relaycommon.Rel
}
}
claudeReq
:=
claudeReq_
.
(
*
claude
.
ClaudeRequest
)
claudeReq
:=
claudeReq_
.
(
*
claude
.
ClaudeRequest
)
awsClaudeReq
:=
&
AwsClaudeRequest
{
awsClaudeReq
:=
copyRequest
(
claudeReq
)
AnthropicVersion
:
"bedrock-2023-05-31"
,
}
if
err
=
copier
.
Copy
(
awsClaudeReq
,
claudeReq
);
err
!=
nil
{
return
wrapErr
(
errors
.
Wrap
(
err
,
"copy request"
)),
nil
}
awsReq
.
Body
,
err
=
json
.
Marshal
(
awsClaudeReq
)
awsReq
.
Body
,
err
=
json
.
Marshal
(
awsClaudeReq
)
if
err
!=
nil
{
if
err
!=
nil
{
return
wrapErr
(
errors
.
Wrap
(
err
,
"marshal request"
)),
nil
return
wrapErr
(
errors
.
Wrap
(
err
,
"marshal request"
)),
nil
...
...
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