langchaingo

package module
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvOpenAIModel   = "OPENAI_MODEL"
	EnvOpenAIAPIKey  = "OPENAI_API_KEY"
	EnvOpenAIBaseURL = "OPENAI_BASE_URL"

	DefaultOpenAIModel = "gpt-4o-mini"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

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

Model adapts langchaingo llms.Model to intent.LLM.

func MustNewOpenAI

func MustNewOpenAI(opts ...OpenAIOption) *Model

MustNewOpenAI is like NewOpenAI but panics on error.

func NewModel

func NewModel(model lclang.Model, info intent.Model) *Model

NewModel wraps a langchaingo model.

func NewOpenAI

func NewOpenAI(opts ...OpenAIOption) (*Model, error)

NewOpenAI returns an intent.LLM backed by OpenAI via langchaingo. Unset fields are populated from OPENAI_MODEL, OPENAI_API_KEY, and OPENAI_BASE_URL when present.

func (*Model) Generate

func (m *Model) Generate(ctx context.Context, req intent.Request) (intent.Response, error)

func (*Model) Model

func (m *Model) Model() intent.Model

func (*Model) Stream

func (m *Model) Stream(ctx context.Context, req intent.Request) (intent.Stream, error)

type OpenAIOption

type OpenAIOption func(*openaiConfig)

OpenAIOption configures an OpenAI-backed intent.LLM.

func WithOpenAIAPIKey

func WithOpenAIAPIKey(key string) OpenAIOption

WithOpenAIAPIKey sets the OpenAI API key.

func WithOpenAIBaseURL

func WithOpenAIBaseURL(baseURL string) OpenAIOption

WithOpenAIBaseURL sets a custom OpenAI-compatible base URL.

func WithOpenAIInfo

func WithOpenAIInfo(info intent.Model) OpenAIOption

WithOpenAIInfo sets model metadata exposed through intent.Model.

func WithOpenAIModel

func WithOpenAIModel(name string) OpenAIOption

WithOpenAIModel sets the OpenAI model name.

Jump to

Keyboard shortcuts

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