2024-01-14 11:21:03 +00:00
|
|
|
package xunfei
|
|
|
|
|
|
|
|
import (
|
2024-02-17 16:15:31 +00:00
|
|
|
"github.com/songquanpeng/one-api/relay/model"
|
2024-01-14 11:21:03 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Message struct {
|
|
|
|
Role string `json:"role"`
|
|
|
|
Content string `json:"content"`
|
|
|
|
}
|
|
|
|
|
2024-06-12 16:07:26 +00:00
|
|
|
type Functions struct {
|
2024-06-20 14:56:59 +00:00
|
|
|
Text []model.Function `json:"text,omitempty"`
|
2024-06-12 16:07:26 +00:00
|
|
|
}
|
|
|
|
|
2024-01-14 11:21:03 +00:00
|
|
|
type ChatRequest struct {
|
|
|
|
Header struct {
|
|
|
|
AppId string `json:"app_id"`
|
|
|
|
} `json:"header"`
|
|
|
|
Parameter struct {
|
|
|
|
Chat struct {
|
|
|
|
Domain string `json:"domain,omitempty"`
|
|
|
|
Temperature float64 `json:"temperature,omitempty"`
|
|
|
|
TopK int `json:"top_k,omitempty"`
|
|
|
|
MaxTokens int `json:"max_tokens,omitempty"`
|
|
|
|
Auditing bool `json:"auditing,omitempty"`
|
|
|
|
} `json:"chat"`
|
|
|
|
} `json:"parameter"`
|
|
|
|
Payload struct {
|
|
|
|
Message struct {
|
|
|
|
Text []Message `json:"text"`
|
|
|
|
} `json:"message"`
|
2024-06-12 16:07:26 +00:00
|
|
|
Functions *Functions `json:"functions,omitempty"`
|
2024-01-14 11:21:03 +00:00
|
|
|
} `json:"payload"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type ChatResponseTextItem struct {
|
2024-03-31 15:12:29 +00:00
|
|
|
Content string `json:"content"`
|
|
|
|
Role string `json:"role"`
|
|
|
|
Index int `json:"index"`
|
|
|
|
ContentType string `json:"content_type"`
|
|
|
|
FunctionCall *model.Function `json:"function_call"`
|
2024-01-14 11:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type ChatResponse struct {
|
|
|
|
Header struct {
|
|
|
|
Code int `json:"code"`
|
|
|
|
Message string `json:"message"`
|
|
|
|
Sid string `json:"sid"`
|
|
|
|
Status int `json:"status"`
|
|
|
|
} `json:"header"`
|
|
|
|
Payload struct {
|
|
|
|
Choices struct {
|
|
|
|
Status int `json:"status"`
|
|
|
|
Seq int `json:"seq"`
|
|
|
|
Text []ChatResponseTextItem `json:"text"`
|
|
|
|
} `json:"choices"`
|
|
|
|
Usage struct {
|
|
|
|
//Text struct {
|
|
|
|
// QuestionTokens string `json:"question_tokens"`
|
|
|
|
// PromptTokens string `json:"prompt_tokens"`
|
|
|
|
// CompletionTokens string `json:"completion_tokens"`
|
|
|
|
// TotalTokens string `json:"total_tokens"`
|
|
|
|
//} `json:"text"`
|
2024-02-17 16:15:31 +00:00
|
|
|
Text model.Usage `json:"text"`
|
2024-01-14 11:21:03 +00:00
|
|
|
} `json:"usage"`
|
|
|
|
} `json:"payload"`
|
|
|
|
}
|