This project provides agent framework for creating market agents with economic incentive. The agents have utilities for parallel AI inference and prompt caching using large language models (LLMs).
The datagenie/marketagents_function_calling/ module provides a modular pipeline for generating function calling datasets. It supports two modes:
- Curriculum Mode: Generate tools and queries from task descriptions (CSV/JSONL)
- HuggingFace Mode: Augment existing datasets to multi-turn conversations
flowchart TD
subgraph Input["📥 Input"]
A[Task Description / HF Dataset]
end
subgraph ToolGen["🔧 Tool Generation"]
B[Tool Generator Agent]
C[Docstring Agent<br/><i>conditional</i>]
end
subgraph QueryGen["💬 Query Generation"]
D[Query Generator Agent]
end
subgraph ToolCalling["🔄 Tool Calling Workflow"]
E[Initialize ChatThread<br/>with Tools & System Prompt]
F[Send User Query]
G{Response Type?}
H[Tool Call]
I[Schema Agent]
J[Results Agent]
K[Append Tool Results]
L[Plain Text<br/><i>First Turn</i>]
M[Clarification Agent]
N[User Clarification]
O[Plain Text<br/><i>After Tool Calls</i>]
P[Summary Response]
end
subgraph FollowUp["🔁 Follow-up"]
Q[Follow-up Agent]
R[New User Query]
end
subgraph Output["📤 Output"]
S[Results JSONL]
T[ShareGPT JSONL]
U[Agent Outputs JSONL]
end
A --> B
B --> C
C --> D
B --> D
D --> E
E --> F
F --> G
G -->|Tool Call| H
H --> I
I --> J
J --> K
K -->|Loop Check| G
G -->|Plain Text<br/>Turn 0| L
L -->|Clarification<br/>Enabled| M
M --> N
N --> G
L -->|Clarification<br/>Disabled| P
G -->|Plain Text<br/>After Tools| O
O --> P
P --> Q
Q --> R
R --> E
P --> S
P --> T
K --> U
style ToolCalling fill:#e1f5fe
style ToolGen fill:#fff3e0
style QueryGen fill:#f3e5f5
style FollowUp fill:#e8f5e9
-
Tool Generation (Curriculum mode only)
- Generates realistic tool/function definitions from task descriptions
- Optionally generates docstrings for tools lacking descriptions
-
Query Generation (Curriculum mode only)
- Creates natural user queries that would invoke the generated tools
- Includes all required parameters with realistic fake data
-
Tool Calling Workflow
- Maintains a persistent
ChatThreadfor conversation state - Handles multiple tool call rounds with loop detection
- Supports clarification flow when assistant asks for more details
- Maintains a persistent
-
Follow-up Generation
- Generates contextual follow-up queries based on conversation history
- Runs another tool calling workflow for multi-turn samples
# Curriculum mode (generate from task descriptions)
python -m datagenie.marketagents_function_calling.run --mode curriculum --limit 10
# HuggingFace mode (augment existing dataset)
python -m datagenie.marketagents_function_calling.run --mode huggingface --limit 100See datagenie/marketagents_function_calling/configs/ for:
pipeline_config.yaml- Pipeline settings (mode, batch size, recursion depth)agents_config.yaml- Per-agent LLM configuration (model, temperature, max_tokens)
To install the market_agents package in editable mode, follow these steps:
-
Clone the repository:
git clone https://github.com/marketagents-ai/MarketAgents.git cd MarketAgents -
Install the package in editable mode:
pip install -e . -
Install the required dependencies:
pip install -r requirements.txt
-
Follow the README.md (just navigate to market_agents/agents/db)
cat ./market_agents/agents/db/README.md
-
Make a copy of .env.example
cp .env.example .env
Note: Setup API keys and more...
-
Edit the
market_agents/orchestrator_config.yamlaccoding to your configuration
You can run the run_simulation.sh as follows:
sh market_agents/run_simulation.sh