reface to openteam
This commit is contained in:
41
llm/types.go
Normal file
41
llm/types.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package llm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/sashabaranov/go-openai"
|
||||
)
|
||||
|
||||
type ChatRequest openai.ChatCompletionRequest
|
||||
|
||||
type ChatResponse openai.ChatCompletionResponse
|
||||
|
||||
type StreamChatResponse openai.ChatCompletionStreamResponse
|
||||
|
||||
type ChatMessage openai.ChatCompletionMessage
|
||||
|
||||
type TokenUsage struct {
|
||||
PromptTokens int `json:"prompt_tokens"`
|
||||
CompletionTokens int `json:"completion_tokens"`
|
||||
ToolsTokens int `json:"total_tokens"`
|
||||
TotalTokens int `json:"total_tokens"`
|
||||
}
|
||||
|
||||
type ErrorResponse struct {
|
||||
Err struct {
|
||||
Message string `json:"message,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Param string `json:"param,omitempty"`
|
||||
Code string `json:"code,omitempty"`
|
||||
} `json:"error,omitempty"`
|
||||
HTTPStatusCode int `json:"-"`
|
||||
HTTPStatus string `json:"-"`
|
||||
}
|
||||
|
||||
func (e ErrorResponse) Error() string {
|
||||
if e.HTTPStatusCode > 0 {
|
||||
return fmt.Sprintf("error, status code: %d, status: %s, message: %s", e.HTTPStatusCode, e.HTTPStatus, e.Err.Message)
|
||||
}
|
||||
|
||||
return e.Err.Message
|
||||
}
|
||||
Reference in New Issue
Block a user