initmodel

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package initmodel provides provider-neutral chat model initialization from a "provider:model" string, mirroring langchain's init_chat_model.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedProvider = fmt.Errorf("init_chat_model: unsupported provider")

ErrUnsupportedProvider is returned when the provider id has no registered factory.

Functions

func InitChatModel

func InitChatModel(ctx context.Context, providerModel string) (llms.Model, error)

InitChatModel resolves a "provider:model" string to a chat model, e.g. "openai:gpt-5" or "anthropic:claude-opus-5". If no provider prefix is present, it defaults to "openai".

func Register

func Register(provider string, f Factory)

Register registers a factory for a provider id (e.g. "openai", "anthropic").

Types

type Factory

type Factory func(ctx context.Context, model string) (llms.Model, error)

Factory builds a chat model. It receives the model name and returns a Model.

func Lookup

func Lookup(provider string) (Factory, bool)

Lookup returns the factory for a provider, if registered.

Directories

Path Synopsis
Package initreg wires up the built-in chat model providers into the initmodel registry.
Package initreg wires up the built-in chat model providers into the initmodel registry.

Jump to

Keyboard shortcuts

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