Production-ready implementations of advanced LLM function calling patterns in TypeScript and Python. This library provides battle-tested implementations of ReAct (Reasoning and Acting) and ReWOO (Reasoning Without Observation) patterns for building sophisticated AI agents.
- Dual Language Support: Full implementations in both TypeScript (Node.js) and Python
- Multiple LLM Providers: OpenAI, Anthropic, Groq, Together AI, DeepSeek, Cerebras, Ollama
- Shared Configuration: Common environment variables work across both implementations
- Modern Stack:
- Node.js 22+, TypeScript 5, Vite, ESM modules
- Python 3.12+, Pydantic, uv package manager
- Production Ready: Error handling, retries, content moderation, logging
.
├── .env.example # Shared environment configuration
├── README.md # This file
├── node/ # TypeScript/Node.js implementation
│ ├── package.json
│ ├── README.md
│ └── src/
└── python/ # Python implementation
├── pyproject.toml
├── README.md
└── src/
cd node
npm install
cp ../.env.example .env
# Edit .env with your API keys
npm run react-cli # Run ReAct CLI
npm run rewoo-cli # Run ReWOO CLIcd python
# Using uv (recommended)
uv venv && source .venv/bin/activate
uv pip install -e ".[dev]"
cp ../.env.example .env
# Edit .env with your API keys
uv run react-cli # Run ReAct CLI
uv run rewoo-cli # Run ReWOO CLIBoth implementations use the same environment variables. Copy .env.example to .env in either the node/ or python/ directory.
| Variable | Description | Example |
|---|---|---|
LLM_PROVIDER |
Provider name | openai, anthropic, groq |
LLM_MODEL |
Model identifier | gpt-4o, claude-3-5-sonnet-20241022 |
OPENAI_API_KEY |
OpenAI API key | sk-... |
ANTHROPIC_API_KEY |
Anthropic API key | sk-ant-... |
GROQ_API_KEY |
Groq API key | gsk_... |
| Variable | Default | Description |
|---|---|---|
LLM_BASE_URL |
Provider default | Custom API endpoint |
LLM_TIMEOUT_MS |
30000 |
Request timeout in milliseconds |
LLM_MAX_RETRIES |
3 |
Maximum retry attempts |
TEMPERATURE |
0.7 |
Sampling temperature (0-2) |
MAX_TOKENS |
Provider default | Maximum completion tokens |
TAVILY_API_KEY |
- | For web search functionality |
| Variable | Description |
|---|---|
TAVILY_API_KEY |
Web search API key |
DOJO_API_KEY |
Document library API key |
DOJO_API_BASE_URL |
Document library base URL |
DOJO_API_LIBRARY_UUID |
Document library UUID |
DATABASE_URL |
PostgreSQL connection string |
POSTGRES_HOST |
PostgreSQL host |
POSTGRES_PORT |
PostgreSQL port |
POSTGRES_DB |
PostgreSQL database name |
POSTGRES_USER |
PostgreSQL username |
POSTGRES_PASSWORD |
PostgreSQL password |
The ReAct (Reasoning and Acting) pattern interleaves reasoning traces with actions:
User Question → Thought → Action → Observation → Thought → ... → Final Answer
Key Components:
- Agent orchestrates the reasoning loop
- Tools execute actions and return observations
- Message handler manages conversation history
- Iteration control prevents infinite loops
The ReWOO (Reasoning Without Observation) pattern separates planning from execution:
Task → Plan (all steps) → Execute Steps → Synthesize Solution
Key Components:
- Planner creates execution plans with evidence variables (#E1, #E2, etc.)
- Worker executes each step using available tools
- Solver synthesizes final solution from collected evidence
- Event bus manages reactive event flow
| Provider | Models | Function Calling | Vision |
|---|---|---|---|
| OpenAI | GPT-4o, GPT-4o-mini, GPT-4 Turbo | Yes | Yes |
| Anthropic | Claude 3.5 Sonnet, Claude 3 Opus/Haiku | Yes | Yes |
| Groq | Llama 3.3 70B, Mixtral 8x7B | Yes | No |
| Together AI | Llama 3.1, Qwen 2.5 | Yes | No |
| DeepSeek | DeepSeek Chat/Coder | Yes | No |
| Cerebras | Llama 3.1 70B/8B | Yes | No |
| Ollama | Any local model | Yes | Varies |
import { ReActAgent, loadReActConfig } from 'llm-function-calling-patterns';
const config = loadReActConfig();
const agent = new ReActAgent(config.ai, config.tools, config.maxIterations);
const answer = await agent.answer('What is 15% of 250?');
console.log(answer);import asyncio
from llm_patterns import ReActAgent, load_react_config
from llm_patterns.react.tools import CalculatorTool
async def main():
config = load_react_config()
agent = ReActAgent(
config=config.ai.resolve(),
tools=[CalculatorTool()],
)
answer = await agent.answer("What is 15% of 250?")
print(answer)
asyncio.run(main())cd node
npm install
npm run dev # Development server
npm test # Run tests
npm run test:coverage # Coverage report
npm run build # Production buildcd python
uv pip install -e ".[dev]"
pytest # Run tests
pytest --cov # Coverage report
ruff check . # Linting
mypy src # Type checking- Node.js README - Detailed Node.js/TypeScript documentation
- Python README - Detailed Python documentation
- ReAct: Synergizing Reasoning and Acting in Language Models
- ReWOO: Decoupling Reasoning from Observations for Efficient Augmented Language Models
MIT License - see LICENSE for details.