Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OpenAIMessage ¶
OpenAIMessage represents a message in the OpenAI chat format
type OpenAIProvider ¶
type OpenAIProvider struct {
APIKey string
Model string
BaseURL string
HTTPClient *http.Client
Timeout time.Duration
}
OpenAIProvider implements the Provider interface for OpenAI models
func NewOpenAIProvider ¶
func NewOpenAIProvider(apiKey, model string) *OpenAIProvider
NewOpenAIProvider creates a new OpenAI provider
func (*OpenAIProvider) GetModelInfo ¶
func (p *OpenAIProvider) GetModelInfo() map[string]interface{}
GetModelInfo returns information about the model
func (*OpenAIProvider) GetUsageInfo ¶
func (p *OpenAIProvider) GetUsageInfo() map[string]interface{}
GetUsageInfo returns token usage information
func (*OpenAIProvider) SendPrompt ¶
SendPrompt sends a prompt to the OpenAI API and returns the response
type OpenAIRequest ¶
type OpenAIRequest struct {
Model string `json:"model"`
Messages []OpenAIMessage `json:"messages"`
Temperature float64 `json:"temperature,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
}
OpenAIRequest represents a request to the OpenAI API
type OpenAIResponse ¶
type OpenAIResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Choices []struct {
Index int `json:"index"`
Message struct {
Role string `json:"role"`
Content string `json:"content"`
} `json:"message"`
FinishReason string `json:"finish_reason"`
} `json:"choices"`
Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
} `json:"usage"`
}
OpenAIResponse represents a response from the OpenAI API
Click to show internal directories.
Click to hide internal directories.