generated from songquanpeng/gin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support claude now (close #150)
- Loading branch information
1 parent
4139a70
commit 2ff15ba
Showing
8 changed files
with
398 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package controller | ||
|
||
type ClaudeMetadata struct { | ||
UserId string `json:"user_id"` | ||
} | ||
|
||
type ClaudeRequest struct { | ||
Model string `json:"model"` | ||
Prompt string `json:"prompt"` | ||
MaxTokensToSample int `json:"max_tokens_to_sample"` | ||
StopSequences []string `json:"stop_sequences,omitempty"` | ||
Temperature float64 `json:"temperature,omitempty"` | ||
TopP float64 `json:"top_p,omitempty"` | ||
TopK int `json:"top_k,omitempty"` | ||
//ClaudeMetadata `json:"metadata,omitempty"` | ||
Stream bool `json:"stream,omitempty"` | ||
} | ||
|
||
type ClaudeError struct { | ||
Type string `json:"type"` | ||
Message string `json:"message"` | ||
} | ||
|
||
type ClaudeResponse struct { | ||
Completion string `json:"completion"` | ||
StopReason string `json:"stop_reason"` | ||
Model string `json:"model"` | ||
Error ClaudeError `json:"error"` | ||
} | ||
|
||
func stopReasonClaude2OpenAI(reason string) string { | ||
switch reason { | ||
case "stop_sequence": | ||
return "stop" | ||
case "max_tokens": | ||
return "length" | ||
default: | ||
return reason | ||
} | ||
} |
Oops, something went wrong.