Documentation
¶
Index ¶
- type Choice
- type ContentPart
- type ContnetType
- type Delta
- type ErrorResponse
- type FunctionDescription
- type ImageURL
- type MessageRequest
- type MessageResponse
- type MessageRole
- type OpenRouterClient
- type Prediction
- type ProviderPreferences
- type Request
- type Response
- type ResponseFormat
- type ResponseUsage
- type RouterAgent
- func (agent RouterAgent) Chat(messages []MessageRequest) (*Response, error)
- func (agent RouterAgent) ChatStream(messages []MessageRequest, outputChan chan Response, ...)
- func (agent RouterAgent) Completion(prompt string) (*Response, error)
- func (agent RouterAgent) CompletionStream(prompt string, outputChan chan Response, processingChan chan interface{}, ...)
- type RouterAgentChat
- type RouterAgentConfig
- type Tool
- type ToolCall
- type ToolChoice
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Choice ¶
type Choice struct { FinishReason string `json:"finish_reason"` Text string `json:"text,omitempty"` Message *MessageResponse `json:"message,omitempty"` Delta *Delta `json:"delta,omitempty"` Error *ErrorResponse `json:"error,omitempty"` }
type ContentPart ¶
type ContentPart struct { Type ContnetType `json:"type"` Text string `json:"text,omitempty"` ImageURL *ImageURL `json:"image_url,omitempty"` }
ContentPart represents the content part structure.
type ContnetType ¶
type ContnetType string
const ( ContentTypeText ContnetType = "text" ContentTypeImage ContnetType = "image_url" )
type ErrorResponse ¶
type FunctionDescription ¶
type FunctionDescription struct { Description string `json:"description,omitempty"` Name string `json:"name"` Parameters interface{} `json:"parameters"` // JSON Schema object }
FunctionDescription represents the function description structure.
type MessageRequest ¶
type MessageRequest struct { Role MessageRole `json:"role"` Content interface{} `json:"content"` // Can be string or []ContentPart Name string `json:"name,omitempty"` ToolCallID string `json:"tool_call_id,omitempty"` }
Message represents the message structure.
type MessageResponse ¶
type MessageRole ¶
type MessageRole string
const ( RoleSystem MessageRole = "system" RoleUser MessageRole = "user" RoleAssistant MessageRole = "assistant" RoleTool MessageRole = "tool" )
type OpenRouterClient ¶
type OpenRouterClient struct {
// contains filtered or unexported fields
}
func NewOpenRouterClient ¶
func NewOpenRouterClient(apiKey string) *OpenRouterClient
func NewOpenRouterClientFull ¶
func NewOpenRouterClientFull(apiKey string, apiUrl string, client *http.Client) *OpenRouterClient
func (*OpenRouterClient) FetchChatCompletions ¶
func (c *OpenRouterClient) FetchChatCompletions(request Request) (*Response, error)
func (*OpenRouterClient) FetchChatCompletionsStream ¶
type Prediction ¶
Prediction represents the prediction structure.
type ProviderPreferences ¶
type ProviderPreferences struct { RefererURL string `json:"referer_url,omitempty"` SiteName string `json:"site_name,omitempty"` }
ProviderPreferences represents the provider preferences structure.
type Request ¶
type Request struct { Messages []MessageRequest `json:"messages,omitempty"` Prompt string `json:"prompt,omitempty"` Model string `json:"model,omitempty"` ResponseFormat *ResponseFormat `json:"response_format,omitempty"` Stop []string `json:"stop,omitempty"` Stream bool `json:"stream,omitempty"` MaxTokens int `json:"max_tokens,omitempty"` Temperature float64 `json:"temperature,omitempty"` Tools []Tool `json:"tools,omitempty"` ToolChoice ToolChoice `json:"tool_choice,omitempty"` Seed int `json:"seed,omitempty"` TopP float64 `json:"top_p,omitempty"` TopK int `json:"top_k,omitempty"` FrequencyPenalty float64 `json:"frequency_penalty,omitempty"` PresencePenalty float64 `json:"presence_penalty,omitempty"` RepetitionPenalty float64 `json:"repetition_penalty,omitempty"` LogitBias map[int]float64 `json:"logit_bias,omitempty"` TopLogprobs int `json:"top_logprobs,omitempty"` MinP float64 `json:"min_p,omitempty"` TopA float64 `json:"top_a,omitempty"` Prediction *Prediction `json:"prediction,omitempty"` Transforms []string `json:"transforms,omitempty"` Models []string `json:"models,omitempty"` Route string `json:"route,omitempty"` Provider *ProviderPreferences `json:"provider,omitempty"` IncludeReasoning bool `json:"include_reasoning,omitempty"` }
Request represents the main request structure.
type ResponseFormat ¶
type ResponseFormat struct {
Type string `json:"type"`
}
ResponseFormat represents the response format structure.
type ResponseUsage ¶
type RouterAgent ¶
type RouterAgent struct {
// contains filtered or unexported fields
}
func NewRouterAgent ¶
func NewRouterAgent(client *OpenRouterClient, model string, config RouterAgentConfig) *RouterAgent
func (RouterAgent) Chat ¶
func (agent RouterAgent) Chat(messages []MessageRequest) (*Response, error)
func (RouterAgent) ChatStream ¶
func (agent RouterAgent) ChatStream(messages []MessageRequest, outputChan chan Response, processingChan chan interface{}, errChan chan error, ctx context.Context)
func (RouterAgent) Completion ¶
func (agent RouterAgent) Completion(prompt string) (*Response, error)
func (RouterAgent) CompletionStream ¶
type RouterAgentChat ¶
type RouterAgentChat struct { RouterAgent Messages []MessageRequest }
func NewRouterAgentChat ¶
func NewRouterAgentChat(client *OpenRouterClient, model string, config RouterAgentConfig, system_prompt string) RouterAgentChat
func (*RouterAgentChat) Chat ¶
func (agent *RouterAgentChat) Chat(message string) error
type RouterAgentConfig ¶
type RouterAgentConfig struct { ResponseFormat *ResponseFormat `json:"response_format,omitempty"` Stop []string `json:"stop,omitempty"` MaxTokens int `json:"max_tokens,omitempty"` Temperature float64 `json:"temperature,omitempty"` Tools []Tool `json:"tools,omitempty"` ToolChoice ToolChoice `json:"tool_choice,omitempty"` Seed int `json:"seed,omitempty"` TopP float64 `json:"top_p,omitempty"` TopK int `json:"top_k,omitempty"` FrequencyPenalty float64 `json:"frequency_penalty,omitempty"` PresencePenalty float64 `json:"presence_penalty,omitempty"` RepetitionPenalty float64 `json:"repetition_penalty,omitempty"` LogitBias map[int]float64 `json:"logit_bias,omitempty"` TopLogprobs int `json:"top_logprobs,omitempty"` MinP float64 `json:"min_p,omitempty"` TopA float64 `json:"top_a,omitempty"` }
type Tool ¶
type Tool struct { Type string `json:"type"` Function FunctionDescription `json:"function"` }
Tool represents the tool structure.
type ToolChoice ¶
type ToolChoice struct { Type string `json:"type"` Function struct { Name string `json:"name"` } `json:"function"` }
ToolChoice represents the tool choice structure.
Click to show internal directories.
Click to hide internal directories.