ai

package
v0.0.0-...-a43d33b Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Embedding = &embedding{}
View Source
var ErrPlatformModelUnsupported = errors.New("system built-in AI model type is unsupported")

ErrPlatformModelUnsupported means platform mode intentionally does not expose this model capability. Callers may use errors.Is to apply a silent, deterministic fallback without treating it as an upstream outage.

View Source
var LLM = &llm{}

Functions

func GetEnabledAIConfig

func GetEnabledAIConfig(modelType enums.AIModelType) (*models.AIConfig, error)

func ResolveAIConfig

func ResolveAIConfig(ctx context.Context, modelType enums.AIModelType, customConfigID int64) (*models.AIConfig, error)

ResolveAIConfig resolves the effective model configuration for one logical AI call. Platform mode always uses the host gateway and never falls back to locally stored credentials. Custom mode uses customConfigID when provided, otherwise it selects the enabled configuration for modelType.

func ResolveVisionAIConfig

func ResolveVisionAIConfig(ctx context.Context, customConfigID int64) (*models.AIConfig, error)

ResolveVisionAIConfig resolves the image-message model independently from the ordinary chat capability. Custom mode keeps using the configured LLM; the runtime's conservative model-name check decides whether it can receive image parts. Platform mode requires the explicit vision task route.

func SetPlatformAIProvider

func SetPlatformAIProvider(provider contract.PlatformAIProvider)

SetPlatformAIProvider registers the host-provided system AI gateway for chat, vision, and embedding calls. Passing nil keeps the standalone/custom model behavior unchanged.

func WithPlatformAIRequestPurpose

func WithPlatformAIRequestPurpose(ctx context.Context, purpose string) context.Context

WithPlatformAIRequestPurpose separates otherwise identical calls belonging to different stages such as retrieval and document indexing.

func WithPlatformAIRequestScope

func WithPlatformAIRequestScope(ctx context.Context, base string) context.Context

WithPlatformAIRequestScope binds a persisted business operation identity to platform AI calls. Recreating a scope with the same base during recovery reproduces the same purpose/ordinal request IDs, while one live scope gives every logical upstream call a distinct ordinal.

Types

type ChatCompletionResult

type ChatCompletionResult struct {
	Content          string
	ModelName        string
	PromptTokens     int
	CompletionTokens int
}

type EmbeddingResult

type EmbeddingResult struct {
	Vector     []float32
	TokensUsed int
	ModelName  string
	Dimension  int
}

type ImageInput

type ImageInput struct {
	AssetID    string
	Filename   string
	MIMEType   string
	Base64Data string
	FileSize   int64
}

ImageInput is trusted image data prepared by the conversation asset boundary. The runtime intentionally accepts inline data only; arbitrary customer-provided URLs must never be forwarded to an upstream model.

type ToolCall

type ToolCall struct {
	ID        string
	Name      string
	Arguments string
}

type ToolCallExecutor

type ToolCallExecutor func(context.Context, ToolCall) (string, error)

type ToolDefinition

type ToolDefinition struct {
	Name        string
	Description string
	Parameters  map[string]any
}

type ToolLoopResult

type ToolLoopResult struct {
	ChatCompletionResult
	ToolCalls []ToolCall
}

Directories

Path Synopsis
application
rag
readtools
Package readtools executes deterministic, read-only graph tools through the shared Tool Registry boundary.
Package readtools executes deterministic, read-only graph tools through the shared Tool Registry boundary.
Package tooling provides the engine-independent tool governance boundary.
Package tooling provides the engine-independent tool governance boundary.

Jump to

Keyboard shortcuts

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