Condukt.Message (Condukt v0.16.1)

Copy Markdown View Source

Represents a message in the conversation history.

Messages can be from the user, the assistant, or represent tool results. Assistant messages may include tool calls and their results.

Message Roles

  • :user - A message from the user
  • :assistant - A response from the LLM
  • :tool_result - The result of a tool execution

Content Blocks

Assistant messages can contain multiple content blocks:

  • {:text, string} - Plain text
  • {:thinking, string} - Model's reasoning (if thinking enabled)
  • {:tool_call, id, name, args} - A tool invocation

Summary

Functions

Creates a new assistant message.

Checks if the message contains any tool calls.

Extracts plain text from a message's content.

Extracts thinking content from a message.

Extracts tool calls from a message.

Creates a tool result message.

Extracts the content from a tool result message for display.

Creates a new user message.

Functions

assistant(content)

Creates a new assistant message.

Content can be a string or a list of content blocks.

has_tool_calls?(arg1)

Checks if the message contains any tool calls.

text(message)

Extracts plain text from a message's content.

Returns the concatenated text blocks for assistant messages, or the content directly for user messages.

thinking(arg1)

Extracts thinking content from a message.

tool_calls(arg1)

Extracts tool calls from a message.

Returns a list of {id, name, args} tuples.

tool_result(tool_call_id, content)

Creates a tool result message.

The content will be JSON-encoded if not a string.

tool_result_content(message)

Extracts the content from a tool result message for display.

user(text, images \\ [])

Creates a new user message.

Examples

Message.user("Hello!")
Message.user("What's in this image?", [%{type: :base64, media_type: "image/png", data: "..."}])