llm

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package llm provides interfaces and implementations for LLM interactions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Role    string // "system", "user", "assistant"
	Content string
}

Message represents a single message in a conversation with an LLM.

type OpenAIProvider added in v0.7.1

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

OpenAIProvider calls the OpenAI chat completions API.

func NewOpenAIProvider added in v0.7.1

func NewOpenAIProvider(apiKey, model string) *OpenAIProvider

NewOpenAIProvider creates an LLM provider that calls OpenAI.

func (*OpenAIProvider) Complete added in v0.7.1

func (p *OpenAIProvider) Complete(ctx context.Context, messages []Message) (*Response, error)

Complete sends a conversation to the OpenAI chat completions API.

type Provider

type Provider interface {
	// Complete sends a conversation to the LLM and returns its response.
	Complete(ctx context.Context, messages []Message) (*Response, error)
}

Provider is the interface for completing LLM conversations.

type Response

type Response struct {
	Content string
}

Response represents the LLM's response.

type StubProvider

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

StubProvider returns configurable responses for testing.

func NewStubProvider

func NewStubProvider(responses ...string) *StubProvider

NewStubProvider creates a stub provider that cycles through the given responses. If no responses are provided, it returns an empty string.

func (*StubProvider) CallCount

func (s *StubProvider) CallCount() int

CallCount returns the number of times Complete was called.

func (*StubProvider) Complete

func (s *StubProvider) Complete(_ context.Context, _ []Message) (*Response, error)

Complete returns the next configured response.

Jump to

Keyboard shortcuts

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