Documentation
¶
Index ¶
- Constants
- Variables
- func ContainsContextLimitError(input string) bool
- func IsAnchorContinuationEnabled(model llm.Model) bool
- func IsContextContinuationEnabled(model llm.Model) bool
- func IsContinuationContextLimit(err error) bool
- type ContinuationContextLimitError
- type ExpandUserPromptInput
- type ExpandUserPromptOutput
- type GenerateInput
- type GenerateOutput
- type Service
- func (s *Service) AttachmentUsage(convID string) int64
- func (s *Service) BuildContinuationRequest(ctx context.Context, req *llm.GenerateRequest, history *prompt.History) *llm.GenerateRequest
- func (s *Service) EnrichToolDefinition(def *llm.ToolDefinition)
- func (s *Service) EnrichedToolDefinitions() []llm.ToolDefinition
- func (s *Service) ExpandUserPrompt(ctx context.Context, in *ExpandUserPromptInput, out *ExpandUserPromptOutput) error
- func (s *Service) Generate(ctx context.Context, input *GenerateInput, output *GenerateOutput) (retErr error)
- func (s *Service) Method(name string) (svc.Executable, error)
- func (s *Service) Methods() svc.Signatures
- func (s *Service) ModelFinder() llm.Finder
- func (s *Service) ModelImplements(ctx context.Context, modelName, feature string) bool
- func (s *Service) ModelMatcher() llm.Matcher
- func (s *Service) ModelToolPreviewLimit(model string) int
- func (s *Service) Name() string
- func (s *Service) ProviderAttachmentLimit(model llm.Model) int64
- func (s *Service) SetAttachmentUsage(convID string, used int64)
- func (s *Service) SetConversationClient(c apiconv.Client)
- func (s *Service) SetModelPreviewLimits(m map[string]int)
- func (s *Service) SetStreamPublisher(p modelcallctx.StreamPublisher)
- func (s *Service) Stream(ctx context.Context, in, out interface{}) (func(), error)
- func (s *Service) ToolDefinitions() []llm.ToolDefinition
- type StreamInput
- type StreamOutput
Constants ¶
const Name = "llm/core"
Variables ¶
var ErrContextLimitExceeded = errors.New("llm/core: context limit exceeded")
ErrContextLimitExceeded signals that a provider/model rejected the request due to exceeding the maximum context window (prompt too long / too many tokens).
Functions ¶
func IsAnchorContinuationEnabled ¶
IsAnchorContinuationEnabled reports whether previous_response_id-style anchor continuation should be used. Some providers/endpoints (e.g. ChatGPT backend HTTP responses) support Responses API transport but not anchor continuation.
func IsContextContinuationEnabled ¶
IsContextContinuationEnabled reports whether the provided model supports server-side context continuation (i.e. continuation by response id by open ai). The current core only gates this by the model capability flag; per-request overrides are not handled here.
func IsContinuationContextLimit ¶
IsContinuationContextLimit reports whether the error is a continuation context-limit failure.
Types ¶
type ContinuationContextLimitError ¶
type ContinuationContextLimitError struct {
Err error
}
ContinuationContextLimitError marks context-limit failures during continuation (previous_response_id) calls. It unwraps to ErrContextLimitExceeded so existing recovery flows still trigger.
func (ContinuationContextLimitError) Error ¶
func (e ContinuationContextLimitError) Error() string
func (ContinuationContextLimitError) Unwrap ¶
func (e ContinuationContextLimitError) Unwrap() error
type ExpandUserPromptInput ¶
type ExpandUserPromptInput struct {
Prompt *prompt.Prompt `json:"prompt,omitempty"`
Binding *prompt.Binding `json:"binding,omitempty"`
}
ExpandUserPromptInput represents a lightweight request to expand only the user prompt template given a binding, without constructing a full GenerateRequest or calling the model. It mirrors the user-facing portion of GenerateInput.
type ExpandUserPromptOutput ¶
type ExpandUserPromptOutput struct {
ExpandedUserPrompt string `json:"expandedUserPrompt"`
}
ExpandUserPromptOutput carries the expanded user prompt text.
type GenerateInput ¶
type GenerateInput struct {
llm.ModelSelection
SystemPrompt *prompt.Prompt
Instruction *prompt.Prompt
Prompt *prompt.Prompt
Binding *prompt.Binding
Message []llm.Message
// Instructions holds expanded top-level model instructions, when provided.
Instructions string
// ExpandedUserPrompt holds the fully expanded user task text
// produced from the user template and binding. Callers that
// wish to persist the expanded task as the canonical user
// message (instead of the raw input) can read this value
// after Init completes.
ExpandedUserPrompt string `yaml:"expandedUserPrompt,omitempty" json:"expandedUserPrompt,omitempty"`
// UserPromptAlreadyInHistory, when true, signals that the caller has
// already persisted the expanded user prompt as the latest user
// message in Binding.History.Past. In that case, Init will not
// append a synthetic chat_user message into History.Current. When
// false (default), Init may add a synthetic user message for the
// current turn.
UserPromptAlreadyInHistory bool `yaml:"userPromptAlreadyInHistory,omitempty" json:"userPromptAlreadyInHistory,omitempty"`
// IncludeCurrentHistory controls whether History.Current (in-flight
// turn messages) should be included when building the LLM request
// messages. When false, only Past (committed) turns participate;
// when true (default), Past then Current are flattened.
IncludeCurrentHistory bool `yaml:"includeCurrentHistory,omitempty" json:"includeCurrentHistory,omitempty"`
// Participant identities for multi-user/agent attribution
UserID string `yaml:"userID" json:"userID"`
AgentID string `yaml:"agentID" json:"agentID"`
}
func (*GenerateInput) MatchModelIfNeeded ¶
func (i *GenerateInput) MatchModelIfNeeded(matcher llm.Matcher)
type GenerateOutput ¶
type GenerateOutput struct {
Response *llm.GenerateResponse
Content string
MessageID string
}
GenerateOutput represents output from extraction
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) AttachmentUsage ¶
AttachmentUsage returns cumulative attachment bytes recorded for a conversation.
func (*Service) BuildContinuationRequest ¶
func (s *Service) BuildContinuationRequest(ctx context.Context, req *llm.GenerateRequest, history *prompt.History) *llm.GenerateRequest
BuildContinuationRequest constructs a continuation request by selecting the latest assistant response anchor (resp.id) and including only tool-call messages that map to that anchor.
func (*Service) EnrichToolDefinition ¶
func (s *Service) EnrichToolDefinition(def *llm.ToolDefinition)
EnrichToolDefinition mutates def in place, replacing its Parameters with an enriched copy when overlays match.
func (*Service) EnrichedToolDefinitions ¶
func (s *Service) EnrichedToolDefinitions() []llm.ToolDefinition
EnrichedToolDefinitions exposes the executor definitions with overlay enrichment so callers return UI-ready schemas.
func (*Service) ExpandUserPrompt ¶
func (s *Service) ExpandUserPrompt(ctx context.Context, in *ExpandUserPromptInput, out *ExpandUserPromptOutput) error
ExpandUserPrompt provides a typed helper around the internal expandUserPrompt executable so callers within this process can expand only the user prompt template without invoking a full generate call.
func (*Service) Generate ¶
func (s *Service) Generate(ctx context.Context, input *GenerateInput, output *GenerateOutput) (retErr error)
func (*Service) Method ¶
func (s *Service) Method(name string) (svc.Executable, error)
Method returns the specified method
func (*Service) Methods ¶
func (s *Service) Methods() svc.Signatures
Methods returns the service methods
func (*Service) ModelFinder ¶
func (*Service) ModelImplements ¶
ModelImplements reports whether a given model supports a feature. When modelName is empty or not found, it returns false.
func (*Service) ModelMatcher ¶
func (*Service) ModelToolPreviewLimit ¶
ModelToolPreviewLimit returns the preview limit in bytes for a model or 0 when not configured.
func (*Service) ProviderAttachmentLimit ¶
ProviderAttachmentLimit returns the provider-configured attachment cap for the given model. Zero means unlimited/not enforced by this provider.
func (*Service) SetAttachmentUsage ¶
SetAttachmentUsage sets cumulative attachment bytes for a conversation.
func (*Service) SetConversationClient ¶
func (*Service) SetModelPreviewLimits ¶
SetModelPreviewLimits sets per-model preview byte limits used by binding to trim tool results.
func (*Service) SetStreamPublisher ¶
func (s *Service) SetStreamPublisher(p modelcallctx.StreamPublisher)
SetStreamPublisher injects a stream publisher used for token-level deltas.
func (*Service) Stream ¶
Stream handles streaming LLM responses, structuring JSON output for text chunks, function calls and finish reasons.
func (*Service) ToolDefinitions ¶
func (s *Service) ToolDefinitions() []llm.ToolDefinition
ToolDefinitions returns every tool definition registered in the tool registry. The slice may be empty when no registry is configured (unit tests or mis-configuration).
type StreamInput ¶
type StreamInput struct {
*GenerateInput
StreamID string
}
type StreamOutput ¶
type StreamOutput struct {
Events []streaming.Event `json:"events"`
MessageID string `json:"messageId,omitempty"`
}
StreamOutput aggregates streaming events into a slice.