Documentation
¶
Index ¶
- type ChatCompletionRequest
- type ChatCompletionResponse
- type Choice
- type Client
- func (c *Client) ChatCompletions(ctx context.Context, req ChatCompletionRequest) (*ChatCompletionResponse, error)
- func (c *Client) ChatCompletionsRaw(ctx context.Context, req ChatCompletionRequest) (*http.Response, error)
- func (c *Client) ConvertStreamToText(ctx context.Context, chunks <-chan StreamChunk, errors <-chan error) (<-chan string, <-chan error)
- func (c *Client) StreamChatCompletions(ctx context.Context, req ChatCompletionRequest) (<-chan StreamChunk, <-chan error)
- type Message
- type StreamChoice
- type StreamChunk
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatCompletionRequest ¶
type ChatCompletionRequest struct {
Model string `json:"model"`
Messages []Message `json:"messages"`
Stream bool `json:"stream"`
}
ChatCompletionRequest represents a request to the chat completion API
type ChatCompletionResponse ¶
type ChatCompletionResponse struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []Choice `json:"choices"`
}
ChatCompletionResponse represents a response from the chat completion API
type Choice ¶
type Choice struct {
Index int `json:"index"`
Message Message `json:"message"`
FinishReason *string `json:"finish_reason,omitempty"`
}
Choice represents a choice in the chat completion response
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client handles communication with LLM services
func NewClientWithConfig ¶
NewClientWithConfig creates a new LLM client with proper configuration
func (*Client) ChatCompletions ¶
func (c *Client) ChatCompletions(ctx context.Context, req ChatCompletionRequest) (*ChatCompletionResponse, error)
ChatCompletions sends a chat completion request
func (*Client) ChatCompletionsRaw ¶
func (c *Client) ChatCompletionsRaw(ctx context.Context, req ChatCompletionRequest) (*http.Response, error)
ChatCompletionsRaw sends a chat completion request and returns the raw HTTP response.
func (*Client) ConvertStreamToText ¶
func (c *Client) ConvertStreamToText(ctx context.Context, chunks <-chan StreamChunk, errors <-chan error) (<-chan string, <-chan error)
ConvertStreamToText converts a stream of chunks to text
func (*Client) StreamChatCompletions ¶
func (c *Client) StreamChatCompletions(ctx context.Context, req ChatCompletionRequest) (<-chan StreamChunk, <-chan error)
StreamChatCompletions sends a streaming chat completion request
type StreamChoice ¶
type StreamChoice struct {
Index int `json:"index"`
Delta Message `json:"delta"`
FinishReason *string `json:"finish_reason,omitempty"`
}
StreamChoice represents a choice in a streaming response
type StreamChunk ¶
type StreamChunk struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []StreamChoice `json:"choices"`
}
StreamChunk represents a chunk in a streaming response