llm

package
v0.1.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

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 NewClient

func NewClient(cfg *config.Config) *Client

NewClient creates a new LLM client

func NewClientWithConfig

func NewClientWithConfig(baseURL, apiKey string) *Client

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 Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

Message represents a chat message

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL