Skip to content
English

模型与交互 ​

Support · 推荐实现与策略 · 返回本层目录

符号类别用途
chatCompletionFunctionOptionsfunctionBuild the tool-selection request fields for a function-calling stage. The adapter expects exactly one function call per response, so tool use is required and parallel calls are disabled.
chatCompletionMessagesfunctionMap Core and provider messages to chat-completions message payloads. Only declared message fields are sent. Assistant tool declarations become nested tool_calls, and tool results become tool_call_id; both are rewritten explicitly rather than forwarded as-is. Messages with images become a content-block array; images are accepted only on user messages and only as http(s) or data:image URLs.
chatCompletionPartsfunctionConvert one streamed choice.delta into Core model parts. Text is emitted only when non-empty; each tool-call fragment carries its index so Core can reassemble arguments that arrive across chunks.
CompatibleModelConfiginterfaceConfiguration of one OpenAI-compatible endpoint.
CompatibleModelPortsinterfaceAdapter ports the App may override without replacing the provider.
CompatibleModelProviderclassHTTP/SSE lifecycle shared by hosts. Apps supply config and user-visible error mapping only. A static configuration is validated and frozen in the constructor. A configuration function is called once per request instead, so credentials and models may rotate between calls.
CompatibleModelProviderOptionsinterfaceConstruction options for a compatible provider.
CompletionFailuretypeBuild the classified failure a policy throws; the provider records it like its own failures.
CompletionPolicyinterfaceDecision whether a finished stream satisfies the request.
completionPolicyCatalogconstant
CompletionRequestFactsinterfaceFacts the provider reads from the request it actually sends. functions reports the Core call options and keeps the default policy equivalent to the behavior that existed before policies were configurable. toolChoice is the effective field of the serialized body, so a host override, or a field dropped for being undefined, is visible exactly as the upstream receives it.
CompletionSessioninterfacePer-request completion state observed by one policy.
createJsonTransportfunctionCreate a typed JSON transport without a capability-selection envelope. The transport embeds the JSON Schema in the instruction and requires the response to be one complete JSON value. The returned response parser rejects native call events and invalid JSON, then validates the value through the supplied schema.
createModelStrategyfunctionCompose runner options in precedence order: budget preset, selected model, declared reasoning, exact budget, then explicit Core fields. The result is validated through the same Core binding rules but creates no runner and spends no calls.
createProviderObservationScopefunctionBind provider observations to a caller-owned destination across diagnostic child spans. attach returns a scoped diagnostic context; contexts that were not attached through this scope produce no observations. Child contexts inherit the owner and a parent/child span path.
createReplyPreviewfunctionCreate a model-output event handler that publishes preview bubbles. The handler resets on model.start, ignores other invocations, disables itself on unexpected output, and clears the preview when a call ends unsuccessfully. Rules are snapshotted at creation, and only explicitly registered prose fields are projected.
createReplyPreviewRulesfunctionGenerate frozen preview rules from capability and stage declarations. Capabilities without preview metadata are skipped even when their stage opts in. Default paths are text and bubbles[*], each kept only when the capability schema declares it.
createSessionModelTransportfunctionCreate a session transport.
createStageModelTransportfunctionBuild a transport that projects a capability source through declared stage references.
createTextTransportfunctionCreate a plain-text transport that trims the assembled response.
defaultCompletionPolicyconstant
defineModelToolsfunctionBuild a sealed capability catalog from typed declarations.
modelBudgetStrategiesconstant
ModelBudgetStrategytypePreset name, or an explicit partial set of Core runner settings.
ModelChildrenOptionsinterfaceGroup options: worker count, extra cancellation and accept/commit hooks.
ModelChildTaskinterfaceOne child call in a group: its own limits plus the work to run with the child runner.
ModelChoiceIndexinterfaceMinimal selector shape used while filtering the provider response choices.
modelInteractionCatalogconstant
ModelProviderErrorCodetypeStable failure classification reported by the compatible provider adapter.
ModelProviderFailureinterfaceFailure detail passed to the App's error factory.
ModelStageTransportRegistrationinterfaceStage IDs and capability references are App-owned; this adapter only compiles their relation.
ModelStrategyOptionstypeInput of createModelStrategy: model selection, optional reasoning and budget plus explicit Core overrides. Explicit Core fields win over every generated value.
PreparedSessionTransportinterfacePrepared session transport handed to the runner.
prepareSessionFunctionsfunctionBuild the session policy for one stage.
PreviewToolinterfaceA model tool with an explicit, presentation-only streaming preview contract.
ProviderAssistantMessageinterfaceAssistant turn; content may be empty when the turn is only a tool declaration.
ProviderErrorCaptureinterfaceCaptured upstream error body and whether it had to be truncated.
ProviderEventDescriptorinterfaceProvider event name plus its content class.
ProviderEventNametypeUnion of provider event names.
ProviderEventPayloadsinterfacePayload of each provider event. Content-bearing events are accepted explicitly.
ProviderMessagetypeMessage list a host may pass to the compatible provider directly.
ProviderObservationtypeOne observation: event name with its payload.
ProviderObserverinterfaceThe caller can correlate each observation using the original, request-local model options.
ProviderReasoningLeveltypeSupplier wire shape is explicit; levels express requested effort, not measured quality.
ProviderReasoningStrategytypeHow a reasoning level is translated into request fields. requestBody entries override generated fields, so a host can correct a provider that expects a different shape.
ProviderSystemMessageinterfaceSystem instruction turn; text only, so the union rejects images and tool fields here.
ProviderToolCalltypeOne tool call the assistant declared, in wire order; aliases the Core shape.
ProviderToolMessageinterfaceTool result answering one declared call.
ProviderUserMessageinterfaceUser turn; the only message type that may carry images, and never tool calls.
ReplyPreviewOptionsinterfaceSettings for createReplyPreview; sink receives every bubble list and is required.
ReplyPreviewRuleinterfaceOne projection rule: which stage/capability it matches and which prose fields may be shown. A rule without toolId may only match a registered plain-text stage.
ReplyPreviewStageinterfaceStage declaration: which tools it exposes and whether it previews text or arguments.
ReplyPreviewToolinterfaceCapability declaration used to derive preview rules. Omitted preview means the capability never previews, so previewing is an explicit opt-in.
ResolvedSessionCallinterfaceOne completed call with host-facing resolution; unknown tools and bad JSON stay non-fatal.
ResolvedSessionResultinterfaceComplete result of one session response after host-facing resolution.
runChildrenfunctionRun child tasks concurrently and return their values in declaration order. The first failure aborts the remaining group, but an already in-flight commit is still awaited because cancellation does not mean the write was rolled back.
sessionCompletionPolicyconstant
SessionFunctionOptionsinterfaceOptions a session transport may pass through to provider options.
SessionModelTransportRegistrationinterfaceRegistration for one session transport.

接口参考、使用示例与开发指南。