Module: mellea.stdlib.chat

Chat primitives.

Classes

class mellea.stdlib.chat.Message(role: 'Message.Role', content: str)

A single Message in a Chat history.

Constructor

Initializer for Chat messages.

Arguments

  • role: str: The role that this message came from (e.g., user, assistant).
  • content: str: The content of the message.

Methods

mellea.stdlib.chat.Message.parts()
Returns all of the constituent parts of an Instruction.
mellea.stdlib.chat.Message.format_for_llm()
Formats the content for a Language Model. The formatted output suitable for language models.
mellea.stdlib.chat.Message.__str__()
Pretty representation of messages, because they are a special case.

class mellea.stdlib.chat.ToolMessage(role: Message.Role, content: str, tool_output: Any, name: str, args: Mapping[str, Any], tool: ModelToolCall)

Adds the name field for function name.

Constructor

Initializer for Chat messages.

Arguments

  • role: the role of this message. Most backends/models use something like tool.
  • content: The content of the message; should be a stringified version of the tool_output.
  • name: The name of the tool/function.
  • args: The args required to call the function.
  • tool_output: the output of the tool/function call.
  • tool: the ModelToolCall representation.

Methods

mellea.stdlib.chat.ToolMessage.format_for_llm()
The same representation as Message with a name field added to args.
mellea.stdlib.chat.ToolMessage.__str__()
Pretty representation of messages, because they are a special case.