llmcall

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package llmcall resolves adaptive-router choices and assembles one OpenRouter call. Recovery and multi-turn behavior belong to the caller and steploop.

Index

Constants

View Source
const OutputTokenMax = 32_000

Variables

This section is empty.

Functions

func HasToolCalls

func HasToolCalls(messages []msgmodel.ModelMessage) bool

HasToolCalls reports whether any message carries a tool call or tool result. Only array content is inspected.

Types

type Agent

type Agent struct {
	Name string
	Mode string
	// Tier is the model pool this agent routes on. Empty means high.
	Tier adaptive.ModelTier
}

type ClientFactory

type ClientFactory interface {
	Client(ctx context.Context, model Model, choice *adaptive.RouteChoice, router *adaptive.AdaptiveModelRouter) (StreamClient, error)
}

type ClientFactoryFunc

func (ClientFactoryFunc) Client

type Model

type Model struct {
	ProviderID string
	ID         string
	APIID      string
	Params     orclient.RequestParams
}

type ModelResolver

type ModelResolver interface {
	GetModel(ctx context.Context, providerID, modelID string) (Model, error)
}

type ModelResolverFunc

type ModelResolverFunc func(context.Context, string, string) (Model, error)

func (ModelResolverFunc) GetModel

func (f ModelResolverFunc) GetModel(ctx context.Context, providerID, modelID string) (Model, error)

type OpenRouterClientFactory

type OpenRouterClientFactory func(ctx context.Context, model Model) (*orclient.Client, error)

OpenRouterClientFactory wires a configured endpoint builder to llmcall.

func (OpenRouterClientFactory) Client

type ResolvedCall

type ResolvedCall struct {
	Model      Model
	Choice     *adaptive.RouteChoice
	Candidates []adaptive.ModelCandidate
	Params     orclient.RequestParams
}

type Service

type Service struct {
	Models         ModelResolver
	Clients        ClientFactory
	Router         *adaptive.AdaptiveModelRouter
	DisableRouting bool
}

func (*Service) ResolveAndAssemble

func (s *Service) ResolveAndAssemble(ctx context.Context, input StreamInput) (ResolvedCall, error)

ResolveAndAssemble picks the model (through the router when one is enabled) and assembles the request parameters. A failed routed-model lookup is registered immediately and the incoming model remains usable.

func (*Service) Stream

func (s *Service) Stream(ctx context.Context, input StreamInput) (Stream, error)

type Stream

type Stream interface {
	Next() (orclient.StreamPart, error)
	Close() error
}

type StreamClient

type StreamClient interface {
	DoStream(ctx context.Context, params orclient.RequestParams) (Stream, error)
}

type StreamInput

type StreamInput struct {
	UserID          string
	SessionID       string
	ParentSessionID string
	Model           Model
	Agent           Agent
	System          []string
	Messages        []msgmodel.ModelMessage
	Tools           []orclient.Tool
	DisabledTools   map[string]bool
	UserTools       map[string]bool
	ToolChoice      *orclient.ToolChoice
}

Jump to

Keyboard shortcuts

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