Skip to main content

Crate ferrin_message

Crate ferrin_message 

Source
Expand description

Ferrin application-level messages.

  • Message and its role structs: the conversation model applications build and persist. Content may be a plain string or a list of parts.
  • Part types: UserPart, AssistantPart, ToolPart and the application-only parts ImagePart, FilePart, ReasoningFilePart, ToolApprovalRequest, ToolApprovalResponse. Parts whose shape equals the provider specification (TextPart, ReasoningPart, CustomPart, ToolCallPart, ToolResultPart, ToolResultOutput) are re-exported from ferrin_spec.
  • FileSource: application file payloads (bytes, base64, URL, provider reference, inline text, local path) plus data_url parsing.
  • prune: removal of reasoning, tool calls and empty messages from a history.

Conversion to the provider Prompt (downloads, media type detection) lives in the core crate.

Design: docs/01-architecture/03-core-data-model.md §7, docs/01-architecture/05-prompt-conversion.md.

§Attribution

Portions of this crate are derived from the Vercel AI SDK (Apache-2.0, Copyright 2023 Vercel, Inc.), translated from TypeScript to Rust and modified. See the NOTICE file in the crate root.

Re-exports§

pub use data_url::DataUrl;
pub use prune::PruneOptions;

Modules§

data_url
RFC 2397 data: URL parsing.
prune
Message pruning: drop reasoning, tool calls and empty messages to control context size.

Structs§

ApprovalId
Identifier of a tool approval request.
AssistantMessage
An assistant message.
CustomPart
Provider-specific content identified by a provider.type kind.
FilePart
A file in a user or assistant message.
ImagePart
An image in a user message.
InvalidDataContentError
Binary or data-URL content could not be decoded.
MediaType
An IANA media type such as image/png, or a top-level type such as image.
ReasoningFilePart
A reasoning artefact (for example an image the model reasoned over) in an assistant message.
ReasoningPart
Reasoning text produced by the model.
SystemMessage
A system message.
TextPart
Text content.
ToolApprovalRequest
A request for user approval of a tool call, recorded in an assistant message.
ToolApprovalResponse
The user’s answer to a ToolApprovalRequest, recorded in a tool message.
ToolCallId
Identifier of a tool call, assigned by the provider.
ToolCallPart
A tool call issued by the model in a previous step.
ToolMessage
A tool message.
ToolName
Name of a tool as exposed to the model.
ToolResultPart
The result of a tool call.
UserMessage
A user message.

Enums§

AssistantContent
Content of an assistant message: a string or a list of parts.
AssistantPart
A part of an assistant message.
FileData
The payload of a file: inline bytes, a URL, a provider reference or an inline text document.
FileSource
Where the bytes of a file part come from.
FileSourceError
A FileSource could not be converted into provider file data.
Message
A message in an application conversation, tagged by role.
Role
The role of a Message.
ToolPart
A part of a tool message.
ToolResultContentPart
A part of a multi-part tool result.
ToolResultOutput
The output of a tool call as sent back to the model.
UserContent
Content of a user message: a string or a list of parts.
UserPart
A part of a user message.

Traits§

MessagesExt
Helpers for message histories.

Type Aliases§

ProviderOptions
Provider-specific request options, grouped by provider key.
ProviderReference
Provider-side resource identifiers, keyed by provider name.