LemonAi.Types.Context (lemon_ai v0.1.0)

View Source

Conversation context containing messages, tools, and system prompt

Summary

Functions

Add an assistant message to the context

Add a tool result to the context

Add a user message to the context

Returns messages in chronological order (oldest first).

Create a new empty context

Types

message()

t()

@type t() :: %LemonAi.Types.Context{
  messages: [message()],
  system_prompt: String.t() | nil,
  tools: [LemonAi.Types.Tool.t()]
}

Functions

add_assistant_message(ctx, message)

Add an assistant message to the context

add_tool_result(ctx, result)

Add a tool result to the context

add_user_message(ctx, content)

Add a user message to the context

get_messages_chronological(ctx)

Returns messages in chronological order (oldest first).

Messages are stored internally in reverse order for O(1) append performance. Use this function when you need messages in chronological order for LLM APIs.

new(opts \\ [])

Create a new empty context