Mojentic.Examples.React.Formatters (Mojentic v1.2.0)

Copy Markdown View Source

Formatting utilities for the ReAct pattern implementation.

This module provides helper functions for formatting context and tool information into human-readable strings for LLM prompts.

Summary

Functions

Formats the available tools into a readable list.

Formats the current context into a readable string.

Functions

format_available_tools(tools)

Formats the available tools into a readable list.

Parameters

  • tools: A list of tool modules

Returns

A formatted string listing available tools and their descriptions.

Examples

iex> tools = [Mojentic.LLM.Tools.DateResolver]
iex> Formatters.format_available_tools(tools)
"Tools available:\n- resolve_date: Take text that specifies a relative date, and output an absolute date\n..."

format_current_context(context)

Formats the current context into a readable string.

Parameters

  • context: The current context containing query, plan, and history

Returns

A formatted multi-line string describing the current context.

Examples

iex> context = CurrentContext.new("What is the date next Friday?")
iex> Formatters.format_current_context(context)
"Current Context:\nThe user has asked us to answer the following query:\n> What is the date next Friday?\n..."