reface to openteam

This commit is contained in:
Sakurasan
2025-04-16 18:01:27 +08:00
parent bc223d6530
commit e7ffc9e8b9
92 changed files with 5345 additions and 1273 deletions

41
llm/types.go Normal file
View 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
}