refactor: Refactor: Consolidate Anthropic model requests into GeneralOpenAIRequest

- Refactor Anthropic adapter to work with the new Anthropic API and model requests
- Remove the default value for `MaxTokensToSample`
- Set `MaxTokens` to 500 instead of 1000000
- Use `system` messages as the system prompt instead of the first message
This commit is contained in:
Laisky.Cai
2024-03-05 03:38:26 +00:00
parent fb23ea0c9a
commit bb8755bc98
4 changed files with 26 additions and 40 deletions

View File

@@ -1,19 +1,17 @@
package anthropic
import (
"github.com/songquanpeng/one-api/relay/model"
)
type Metadata struct {
UserId string `json:"user_id"`
}
type Request 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"`
//Metadata `json:"metadata,omitempty"`
Stream bool `json:"stream,omitempty"`
model.GeneralOpenAIRequest
// System anthropic messages API use system to represent the system prompt
System string `json:"system"`
}
type Error struct {