Skip to main content

Crate myco_model

Crate myco_model 

Source
Expand description

Backend-independent messages and one-attempt streaming model drivers.

Construct a driver with new and GenerativeModelConfig, then pass a complete conversation to GenerativeModel::generate. The library accepts resolved settings and credentials; it does not read application config files.

§Streaming and policy

Every call performs one attempt. Consume GenerationEvent directly for incremental output and failure metadata, feeding parts to MessageAccumulator. Use GenerateOutput::from_generation when only the completed output is needed. Dropping a stream cancels its request. Retry, tool execution, and persistence belong to the caller; myco-agent supplies the model/tool loop and retry policy.

§History contract

Message::ToolResults must immediately follow its assistant’s tool calls, with one result per call in the same order. Wire IDs are generated by the drivers. Preserve these pairs when saving or slicing history.

See the inference guide and the inference example for a complete streaming client. The example requires an endpoint; ordinary library tests use local fixtures.

Structs§

AnthropicBackendConfig
Anthropic Messages API settings (BackendConfig::Anthropic).
CatalogModel
One usable catalog entry: spec plus the backend (gateway + credentials) that serves it.
GenerateOutput
GenerationFailure
GenerativeModelConfig
Fully resolved driver inputs. Tool schemas advertise capabilities; the caller remains responsible for executing calls and validating their arguments.
MessageAccumulator
ModelCatalog
Key → model catalog resolved from config.toml. Empty when the user has not configured any models.
ModelSpec
A resolved model: everything the protocol drivers need, minus credentials (those live in BackendConfig). Built by the application configuration from the [models] / [gateways] catalog in config.toml — myco ships no built-in models.
OpenAIBackendConfig
Settings for either OpenAI dialect (BackendConfig::OpenAIResponses / BackendConfig::OpenAICompletions).
RetryPolicy
Agent policy for retrying transient failures before any response parts arrive. Resolved from [gateways.NAME.retry] or [models.KEY.retry].
TokenUsage
Token counts for one generate call. cached_input_tokens is a subset of input_tokens.
ToolResult
ToolSpec
ToolUse
A tool call in an assistant turn. Carries no id: a call is identified by its position (message index + ordinal), and the j-th entry of the next message’s tool_use_results answers it. Providers that need ids on the wire get minted ones from the driver.
ToolUseDelta
ToolUseStart

Enums§

BackendConfig
Provider backend settings: gateway base URL, credential, per-request knobs.
Content
ContentDelta
ContentStart
Effort
Reasoning / extended-thinking effort level sent to providers.
GenerateError
GenerationEvent
One generation attempt emits parts, or ends with a failure.
Message
MessagePart
ModelCreationError
Protocol
Wire protocol a model is served over.
Recovery
What a caller can do about a failed turn.
ThinkingMode
How thinking/reasoning is requested for a model.
TurnEndReason

Constants§

MAX_REQUEST_BYTES
Default ceiling on one serialized API request body: 30 MB (decimal).

Traits§

GenerativeModel

Functions§

answer_content
Clone only answer blocks (Text / Image), dropping thinking.
new
Construct a driver, rejecting a protocol/backend mismatch before any request. No network request is made until the returned model is asked to generate.

Type Aliases§

AsyncStream