Documentation
¶
Index ¶
- func RecordLLMRequest(userID int64, model string, durationSeconds float64, success bool, ...)
- func RecordLLMRetry(model string)
- type ChatCompletionRequest
- type ChatCompletionResponse
- type Client
- type EmbeddingObject
- type EmbeddingRequest
- type EmbeddingResponse
- type File
- type FilePart
- type ImagePart
- type ImageURL
- type JSONSchema
- type Message
- type PDFConfig
- type Plugin
- type ResponseFormat
- type ResponseFormatJSONSchema
- type TextPart
- type Tool
- type ToolCall
- type ToolFunction
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RecordLLMRequest ¶ added in v0.3.0
func RecordLLMRequest(userID int64, model string, durationSeconds float64, success bool, promptTokens, completionTokens int, cost *float64, jobType string)
RecordLLMRequest записывает метрики LLM запроса. jobType should be "interactive" or "background" (use jobtype.JobType constants).
func RecordLLMRetry ¶ added in v0.3.0
func RecordLLMRetry(model string)
RecordLLMRetry записывает retry-попытку.
Types ¶
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
Plugins []Plugin `json:"plugins,omitempty"`
Tools []Tool `json:"tools,omitempty"`
ToolChoice any `json:"tool_choice,omitempty"`
ResponseFormat interface{} `json:"response_format,omitempty"`
// UserID is used for metrics tracking only, not sent to API
UserID int64 `json:"-"`
}
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
ID string `json:"id"`
Model string `json:"model"`
Choices []struct {
Message struct {
Role string `json:"role"`
Content string `json:"content"`
ToolCalls []ToolCall `json:"tool_calls,omitempty"`
ReasoningDetails interface{} `json:"reasoning_details,omitempty"`
} `json:"message"`
FinishReason string `json:"finish_reason,omitempty"`
Index int `json:"index"`
} `json:"choices"`
Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
Cost *float64 `json:"cost,omitempty"` // Cost in USD from OpenRouter
} `json:"usage"`
}
type Client ¶
type Client interface {
CreateChatCompletion(ctx context.Context, req ChatCompletionRequest) (ChatCompletionResponse, error)
CreateEmbeddings(ctx context.Context, req EmbeddingRequest) (EmbeddingResponse, error)
}
type EmbeddingObject ¶
type EmbeddingRequest ¶
type EmbeddingResponse ¶
type EmbeddingResponse struct {
Object string `json:"object"`
Data []EmbeddingObject `json:"data"`
Model string `json:"model"`
Usage struct {
PromptTokens int `json:"prompt_tokens"`
TotalTokens int `json:"total_tokens"`
Cost *float64 `json:"cost,omitempty"` // Cost in USD from OpenRouter
} `json:"usage"`
}
type JSONSchema ¶
type ResponseFormat ¶
type ResponseFormat struct {
Type string `json:"type"`
JSONSchema *JSONSchema `json:"json_schema,omitempty"`
}
type ResponseFormatJSONSchema ¶
type ResponseFormatJSONSchema struct {
Type string `json:"type"` // "json_schema"
JSONSchema JSONSchema `json:"json_schema"`
}
type Tool ¶
type Tool struct {
Type string `json:"type"`
Function ToolFunction `json:"function"`
}
type ToolFunction ¶
Click to show internal directories.
Click to hide internal directories.