Nous.Types (nous v0.9.0)
View SourceCore type definitions for Nous AI.
This module defines all the types used throughout the library. No functions, just type specifications for documentation and Dialyzer.
Summary
Types
Message content - can be text or multi-modal.
Any message type
Model identifier - provider:model string
Model request message.
Model response message.
Output type specification - :string or an Ecto schema module
Message parts that can appear in requests to the model
Message parts that can appear in responses from the model
Stream event types
System prompt message part
Text response part from model
Thinking/reasoning part from model
Tool call information from the model.
Tool call part from model
Tool return information sent back to the model.
Tool return message part
User prompt message part
Types
@type content() :: String.t() | {:text, String.t()} | {:image_url, String.t()} | {:audio_url, String.t()} | {:document_url, String.t()}
Message content - can be text or multi-modal.
Examples
"Just text"
{:text, "Formatted text"}
{:image_url, "https://example.com/image.png"}
@type message() :: model_request() | model_response()
Any message type
@type model() :: String.t()
Model identifier - provider:model string
@type model_request() :: %{parts: [request_part()], timestamp: DateTime.t()}
Model request message.
A message we send to the model.
@type model_response() :: %{ parts: [response_part()], usage: Nous.Usage.t(), model_name: String.t(), timestamp: DateTime.t() }
Model response message.
A message we receive from the model, including usage information.
@type output_type() :: :string | module()
Output type specification - :string or an Ecto schema module
@type request_part() :: system_prompt_part() | user_prompt_part() | tool_return_part()
Message parts that can appear in requests to the model
@type response_part() :: text_part() | tool_call_part() | thinking_part()
Message parts that can appear in responses from the model
@type stream_event() :: {:text_delta, String.t()} | {:thinking_delta, String.t()} | {:tool_call_delta, any()} | {:finish, String.t()} | {:complete, any()} | {:error, term()}
Stream event types
@type system_prompt_part() :: {:system_prompt, String.t()}
System prompt message part
@type text_part() :: {:text, String.t()}
Text response part from model
@type thinking_part() :: {:thinking, String.t()}
Thinking/reasoning part from model
Tool call information from the model.
The model requests to call a tool with these parameters.
@type tool_call_part() :: {:tool_call, tool_call()}
Tool call part from model
Tool return information sent back to the model.
The result of executing a tool call.
@type tool_return_part() :: {:tool_return, tool_return()}
Tool return message part
User prompt message part