llm

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: MIT Imports: 12 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 []ChatMessage `json:"messages"`
}

ChatCompletionRequest represents the request body for chat completion.

type ChatCompletionResponse

type ChatCompletionResponse struct {
	ID      string `json:"id"`
	Object  string `json:"object"`
	Created int64  `json:"created"`
	Model   string `json:"model"`
	Choices []struct {
		Index        int         `json:"index"`
		Message      ChatMessage `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"`
}

ChatCompletionResponse represents the response from the chat completion endpoint.

type ChatMessage

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

ChatMessage represents a message in the chat completion request.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents an OpenAI API client.

func (*Client) Generate

func (c *Client) Generate(ctx context.Context, prompt string, options *LLMOptions) (string, error)

Generate sends a chat completion request to the OpenAI API

type GeminiClient

type GeminiClient struct {
	// contains filtered or unexported fields
}

func (*GeminiClient) Generate

func (c *GeminiClient) Generate(ctx context.Context, prompt string, options *LLMOptions) (string, error)

type LLMClient

type LLMClient interface {
	Generate(ctx context.Context, prompt string, options *LLMOptions) (string, error)
}

func NewLLMClient

func NewLLMClient(provider string) (LLMClient, error)

type LLMOptions

type LLMOptions struct {
	Model        string
	SystemPrompt string
}

type Message

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

type OpenRouterClient

type OpenRouterClient struct {
	// contains filtered or unexported fields
}

OpenRouterClient represents an OpenRouter API client.

func (*OpenRouterClient) Generate

func (c *OpenRouterClient) Generate(ctx context.Context, prompt string, options *LLMOptions) (string, error)

Generate sends a generation request to the OpenRouter API.

type OpenRouterRequest

type OpenRouterRequest struct {
	Model    string    `json:"model"`
	Messages []Message `json:"messages"`
}

OpenRouterRequest represents the request body for text generation.

type OpenRouterResponse

type OpenRouterResponse struct {
	Choices []struct {
		Message struct {
			Content string `json:"content"`
		} `json:"message"`
	} `json:"choices"`
}

OpenRouterResponse represents the response from the OpenRouter API.

Jump to

Keyboard shortcuts

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