Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Choice ¶
type Choice struct {
Index int `json:"index"`
Message Message `json:"message"`
FinishReason string `json:"finish_reason"`
// for stream
Delta *struct {
Role string `json:"role"`
Content string `json:"content"`
} `json:"delta,omitempty"`
}
Choice represents a completion choice
type Error ¶ added in v0.2.0
type Message ¶
type Message struct {
Role string `json:"role"`
Content interface{} `json:"content"`
}
Message represents a single message in the conversation
type OpenAIProvider ¶
type OpenAIProvider struct {
// contains filtered or unexported fields
}
OpenAIProvider implements the Provider interface for OpenAI
func NewOpenAIProvider ¶
func NewOpenAIProvider(apiKey, endpoint, model string, timeout time.Duration) *OpenAIProvider
NewOpenAIProvider creates a new OpenAIProvider
func (*OpenAIProvider) SendRequest ¶
func (p *OpenAIProvider) SendRequest(priorityParams, anyParam AnyParams, headers map[string]string) (*Response, *Error)
SendRequest sends a request to OpenAI API
func (*OpenAIProvider) SupportsStreaming ¶
func (p *OpenAIProvider) SupportsStreaming() bool
SupportsStreaming returns whether OpenAI supports streaming
type Provider ¶
type Provider interface {
// Name returns the provider name
Name() string
// SendRequest sends a request to the LLM and returns the response
SendRequest(priorityParams AnyParams, anyParam AnyParams, headers map[string]string) (*Response, *Error)
// SupportsStreaming returns whether the provider supports streaming
SupportsStreaming() bool
}
Provider interface for different LLM providers
type QwenProvider ¶
type QwenProvider struct {
// contains filtered or unexported fields
}
QwenProvider implements the Provider interface for Qwen(same as OpenAI)
func NewQwenProvider ¶
func NewQwenProvider(apiKey, endpoint, model string, timeout time.Duration) *QwenProvider
NewQwenProvider creates a new QwenProvider
func (*QwenProvider) SendRequest ¶
func (p *QwenProvider) SendRequest(priorityParams, anyParam AnyParams, headers map[string]string) (*Response, *Error)
SendRequest sends a request to Qwen API
func (*QwenProvider) SupportsStreaming ¶
func (p *QwenProvider) SupportsStreaming() bool
SupportsStreaming returns whether Qwen supports streaming
type Response ¶
type Response struct {
ID string `json:"id"`
Model string `json:"model"`
Choices []Choice `json:"choices,omitempty"`
Usage Usage `json:"usage"`
// local fields
Latency time.Duration `json:"-"`
FirstTokenLatency time.Duration `json:"-"` // Streaming specific fields
JsonData string `json:"-"`
}
Response represents an LLM response
Click to show internal directories.
Click to hide internal directories.