LangEx.Message (LangEx v0.7.0)

Copy Markdown View Source

Chat message types for LLM interactions.

Provides struct-based message types and a reducer for accumulating messages in graph state.

Summary

Functions

Reducer that appends new messages to an existing list. Messages with matching IDs replace the existing message (for corrections/updates).

Create an AI message.

Create a human message.

Create a system message.

Create a tool result message.

Types

Functions

add_messages(existing, new)

@spec add_messages([t()], [t()] | t()) :: [t()]

Reducer that appends new messages to an existing list. Messages with matching IDs replace the existing message (for corrections/updates).

ai(content, opts \\ [])

@spec ai(
  String.t(),
  keyword()
) :: LangEx.Message.AI.t()

Create an AI message.

human(content, opts \\ [])

@spec human(
  String.t(),
  keyword()
) :: LangEx.Message.Human.t()

Create a human message.

system(content, opts \\ [])

@spec system(
  String.t(),
  keyword()
) :: LangEx.Message.System.t()

Create a system message.

tool(content, tool_call_id, opts \\ [])

@spec tool(String.t(), String.t(), keyword()) :: LangEx.Message.Tool.t()

Create a tool result message.