Skip to main content

Crate agentai_core

Crate agentai_core 

Source
Expand description

§AgentAI Core

Shared building blocks of the AgentAI crates.

  • message and prompt: the conversation types (Message, Part, Media, ToolOutput, Prompt, …), re-exported by agentai.
  • history: HistoryProcessor changes the messages sent to the model, HistoryPruning removes media and reasoning from finished turns.
  • mime: one table of MIME types and file extensions (mime::extension, mime::from_path, mime::with_extension), also behind Media::extension and Media::file_name.
  • base64: base64::encode and base64::decode, the encoding of Media bytes and data URLs (Media::to_url).
  • storage: MediaStorage (MediaRead + MediaSave), a blob storage for images and other files, with MemoryStorage.
  • HTTP: the HttpClient trait hides the HTTP stack, so crates such as agentai-image send their requests without depending on a particular client. ReqwestClient implements it with reqwest; another environment (for example WebAssembly) can provide its own. With the test-support feature, mock::MockHttp records requests and answers with prepared responses, for tests of providers.
  • tls: the TLS backend is chosen with the rustls-ring (default), rustls-aws-lc and native-tls features.

§Features

Available features for agentai-core crate.

Features list:

  • reqwest (enabled by default) — Enables ReqwestClient, the HttpClient on top of reqwest
  • test-support — mock::MockHttp, a HttpClient that records requests and answers with prepared responses, for the tests of provider crates. Enable it in [dev-dependencies] only.
  • rustls-ring (enabled by default) — TLS with rustls and the ring crypto provider, checking certificates against the OS trust store. Install the provider with tls::install_crypto_provider before you build your own reqwest client.
  • rustls-aws-lc — TLS with rustls and the aws-lc-rs crypto provider (builds the aws-lc-sys C library).
  • native-tls — TLS of the operating system (OpenSSL, SChannel or Security Framework). It cannot be combined with a rustls-* feature: set default-features = false.
  • system-proxy (enabled by default) — Reads the macOS and Windows system proxy settings. Proxy environment variables (HTTP_PROXY, HTTPS_PROXY, NO_PROXY) work without it.

Modules§

base64
Base64 (standard alphabet, with padding), the encoding of MediaSource::Base64 and of data URLs.
history
Processing the history before it is sent
message
Conversation messages
mime
MIME types and file extensions of images, audio and video.
prompt
Prompts
storage
Storage for media: images, audio and other files, kept under an ID.
tls
TLS backend.

Structs§

HttpRequest
A request sent with a HttpClient. The body is always plain bytes, so a client only has to send them.
HttpResponse
A response returned by a HttpClient, with the whole body read.
Multipart
A multipart/form-data body, built in memory.
ReqwestClient
HttpClient on top of reqwest.

Enums§

HttpError
Errors of a HttpClient and of building or reading a request.
Method
HTTP method of a HttpRequest.

Traits§

HttpClient
Sends HTTP requests.

Functions§

percent_encode
Percent-encodes value for use as one path segment or query value of a URL: everything but the unreserved characters of RFC 3986 (letters, digits, -, ., _, ~) is escaped.