feat: add translate command
This commit is contained in:
parent
eecbaf18b3
commit
899491e867
9 changed files with 236 additions and 9 deletions
46
openai/chat.go
Normal file
46
openai/chat.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package openai
|
||||
|
||||
const ChatAPIPath = "/v1/chat/completions"
|
||||
|
||||
type ChatRole string
|
||||
|
||||
const (
|
||||
ChatRoleSystem ChatRole = "system"
|
||||
ChatRoleAssistant ChatRole = "assistant"
|
||||
ChatRoleUser ChatRole = "user"
|
||||
)
|
||||
|
||||
type ChatMessage struct {
|
||||
Role ChatRole `json:"role"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type ChatRequest struct {
|
||||
Model string `json:"model"`
|
||||
Messages []ChatMessage `json:"messages"`
|
||||
Temperature *float64 `json:"temperature,omitempty"`
|
||||
TopP *float64 `json:"top_p,omitempty"`
|
||||
N int `json:"n,omitempty"`
|
||||
Stream bool `json:"stream,omitempty"`
|
||||
Stop []string `json:"stop,omitempty"`
|
||||
MaxTokens int `json:"max_tokens,omitempty"`
|
||||
PresencePenalty *float64 `json:"presence_penalty,omitempty"`
|
||||
FrequencyPenalty *float64 `json:"frequency_penalty,omitempty"`
|
||||
LogitBias map[string]float64 `json:"logit_bias,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
}
|
||||
|
||||
type ChatResponseChoice struct {
|
||||
Message ChatMessage `json:"message"`
|
||||
FinishReason string `json:"finish_reason"`
|
||||
Index int `json:"index"`
|
||||
}
|
||||
|
||||
type ChatResponse struct {
|
||||
ID string `json:"id"`
|
||||
Object string `json:"object"`
|
||||
Created int `json:"created"`
|
||||
Model string `json:"model"`
|
||||
Usage map[string]int `json:"usage"`
|
||||
Choices []ChatResponseChoice `json:"choices"`
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue