agentmap 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. agentmap-0.1.0/LICENSE +21 -0
  2. agentmap-0.1.0/PKG-INFO +395 -0
  3. agentmap-0.1.0/README.md +369 -0
  4. agentmap-0.1.0/agentmap/__init__.py +6 -0
  5. agentmap-0.1.0/agentmap/agents/__init__.py +103 -0
  6. agentmap-0.1.0/agentmap/agents/base_agent.py +151 -0
  7. agentmap-0.1.0/agentmap/agents/builtins/__init__.py +38 -0
  8. agentmap-0.1.0/agentmap/agents/builtins/anthropic_agent.py +56 -0
  9. agentmap-0.1.0/agentmap/agents/builtins/branching_agent.py +97 -0
  10. agentmap-0.1.0/agentmap/agents/builtins/default_agent.py +28 -0
  11. agentmap-0.1.0/agentmap/agents/builtins/echo_agent.py +30 -0
  12. agentmap-0.1.0/agentmap/agents/builtins/failure_agent.py +63 -0
  13. agentmap-0.1.0/agentmap/agents/builtins/google_agent.py +67 -0
  14. agentmap-0.1.0/agentmap/agents/builtins/input_agent.py +31 -0
  15. agentmap-0.1.0/agentmap/agents/builtins/openai_agent.py +55 -0
  16. agentmap-0.1.0/agentmap/agents/builtins/success_agent.py +43 -0
  17. agentmap-0.1.0/agentmap/agents/custom/__init__.py +0 -0
  18. agentmap-0.1.0/agentmap/agents/loader.py +70 -0
  19. agentmap-0.1.0/agentmap/cli.py +129 -0
  20. agentmap-0.1.0/agentmap/config.py +150 -0
  21. agentmap-0.1.0/agentmap/context/__init__.py +0 -0
  22. agentmap-0.1.0/agentmap/context/context_builder.py +9 -0
  23. agentmap-0.1.0/agentmap/exceptions/__init__.py +18 -0
  24. agentmap-0.1.0/agentmap/exceptions/agent_exceptions.py +11 -0
  25. agentmap-0.1.0/agentmap/exceptions/graph_exceptions.py +7 -0
  26. agentmap-0.1.0/agentmap/fastapi_server.py +15 -0
  27. agentmap-0.1.0/agentmap/functions/__init__.py +0 -0
  28. agentmap-0.1.0/agentmap/graph/__init__.py +26 -0
  29. agentmap-0.1.0/agentmap/graph/assembler.py +257 -0
  30. agentmap-0.1.0/agentmap/graph/builder.py +206 -0
  31. agentmap-0.1.0/agentmap/graph/csv_loader.py +68 -0
  32. agentmap-0.1.0/agentmap/graph/routing.py +68 -0
  33. agentmap-0.1.0/agentmap/graph/scaffold.py +324 -0
  34. agentmap-0.1.0/agentmap/graph/serialization.py +592 -0
  35. agentmap-0.1.0/agentmap/graph/tracked_node.py +83 -0
  36. agentmap-0.1.0/agentmap/handler.py +39 -0
  37. agentmap-0.1.0/agentmap/logging/__init__.py +4 -0
  38. agentmap-0.1.0/agentmap/logging/logger.py +24 -0
  39. agentmap-0.1.0/agentmap/runner.py +225 -0
  40. agentmap-0.1.0/agentmap/server.py +28 -0
  41. agentmap-0.1.0/agentmap/templates/__init__.py +0 -0
  42. agentmap-0.1.0/agentmap/templates/agent_template.py.txt +33 -0
  43. agentmap-0.1.0/agentmap/templates/function_template.py.txt +28 -0
  44. agentmap-0.1.0/agentmap/templates/readme.md +1 -0
  45. agentmap-0.1.0/agentmap/utils/__init__.py +0 -0
  46. agentmap-0.1.0/agentmap/utils/common.py +18 -0
  47. agentmap-0.1.0/agentmap/utils/prompts.py +0 -0
  48. agentmap-0.1.0/pyproject.toml +58 -0
agentmap-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 John W
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,395 @@
1
+ Metadata-Version: 2.3
2
+ Name: agentmap
3
+ Version: 0.1.0
4
+ Summary: AgentMap: Build and deploy LangGraph workflows from CSV files. Create complex LLM agent graphs without coding, convert simple spreadsheets into powerful AI agents, and orchestrate multi-agent systems with ease. Integrates with OpenAI, Anthropic, and Google AI models. Includes CLI and FastAPI server for quick deployment.
5
+ License: MIT
6
+ Author: John Welborn
7
+ Author-email: jwwelbor@gmail.com
8
+ Requires-Python: >=3.11
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Dist: anthropic (>=0.17.0,<0.18.0)
12
+ Requires-Dist: dill (>=0.3.6,<0.4.0)
13
+ Requires-Dist: fastapi (>=0.111.0,<0.112.0)
14
+ Requires-Dist: google-generativeai (>=0.3.2,<0.4.0)
15
+ Requires-Dist: httpx (>=0.27.0,<0.28.0)
16
+ Requires-Dist: langgraph (>=0.4.1,<0.5.0)
17
+ Requires-Dist: openai (>=1.12.0,<2.0.0)
18
+ Requires-Dist: pandas (>=2.2.1,<3.0.0)
19
+ Requires-Dist: pydantic (>=2.6.3,<3.0.0)
20
+ Requires-Dist: python-multipart (>=0.0.9,<0.0.10)
21
+ Requires-Dist: typer (>=0.12.3,<0.13.0)
22
+ Project-URL: Homepage, https://github.com/jwwelbor/AgentMap
23
+ Project-URL: Source, https://github.com/jwwelbor/AgentMap
24
+ Project-URL: Tracker, https://github.com/jwwelbor/AgentMap/issues
25
+ Description-Content-Type: text/markdown
26
+
27
+ # AgentMap
28
+
29
+ AgentMap is a declarative orchestration framework for defining and executing LangGraph workflows through CSV and YAML configurations. It enables developers to create complex AI agent workflows without writing extensive code.
30
+
31
+ ## 🌟 Features
32
+
33
+ - **CSV-Driven Workflow Definition:** Create agent workflows through simple CSV files
34
+ - **Agent & Function Scaffolding:** Auto-generate starter code for custom agents and functions
35
+ - **Built-in Agent Types:** Use pre-built agents or create custom ones
36
+ - **Multiple LLM Support:** Easily use OpenAI, Anthropic Claude, Google Gemini, and other LLMs
37
+ - **Dynamic Routing:** Support for conditional branching based on agent outputs
38
+ - **Shared State Management:** Maintain context across agent interactions
39
+ - **Execution Tracking:** Built-in logging and execution path tracking
40
+ - **CLI and API Interfaces:** Run workflows from command line or integrate via API
41
+
42
+ ## 🚀 Installation
43
+
44
+ ### From PyPI (Recommended)
45
+
46
+ ```bash
47
+ pip install agentmap
48
+ ```
49
+
50
+ ### From Source
51
+
52
+ ```bash
53
+ # Clone the repository
54
+ git clone https://github.com/yourusername/agentmap.git
55
+ cd agentmap
56
+
57
+ # Install in development mode
58
+ pip install -e .
59
+ ```
60
+
61
+ ## 🔍 Building Workflows with CSV
62
+
63
+ AgentMap uses CSV files to define the structure and behavior of agent workflows. Each row in the CSV represents a node in the workflow graph.
64
+
65
+ ### Required Columns
66
+
67
+ | Column | Description |
68
+ |--------|-------------|
69
+ | `GraphName` | Name of the workflow graph |
70
+ | `Node` | Name of a specific node in the graph |
71
+ | `Edge` | Connection to the next node or function reference (e.g., `func:choose_next`) |
72
+ | `Context` | Description or prompt for the node |
73
+ | `AgentType` | Type of agent to use (e.g., `openai`, `claude`, `echo`) |
74
+ | `Success_Next` | Where to go on success (can be multiple with `\|` separator) |
75
+ | `Failure_Next` | Where to go on failure (can be multiple with `\|` separator) |
76
+ | `Input_Fields` | Fields to extract from state (pipe-separated) |
77
+ | `Output_Field` | Field to store the agent's output |
78
+ | `Prompt` | Used to pass a prompt to the built-in LLM agents or to your custom agent, pair with input and output fields for extra power |
79
+
80
+ ### Example Workflow CSV
81
+
82
+ ```csv
83
+ GraphName,Node,Edge,Context,AgentType,Success_Next,Failure_Next,Input_Fields,Output_Field,Prompt
84
+ WeatherFlow,InputCollector,,Collect user location,echo,DataFetcher,,user_input,location,
85
+ WeatherFlow,DataFetcher,,Fetch weather data for {location},ApiClient,Analyzer,ErrorHandler,location,weather_data,
86
+ WeatherFlow,Analyzer,,Analyze the weather patterns from the data,openai,Report,,weather_data,analysis,
87
+ WeatherFlow,Report,,Generate weather report,claude,,,analysis|weather_data,report,
88
+ WeatherFlow,ErrorHandler,,Handle API errors,echo,,,error,error_message,
89
+ ```
90
+
91
+ ## 📊 Complete Workflow Example
92
+
93
+ ### 1. Create a CSV Workflow File
94
+
95
+ Create a file named `simple_workflow.csv` with the following content:
96
+
97
+ ```csv
98
+ GraphName,Node,Edge,Context,AgentType,Success_Next,Failure_Next,Input_Fields,Output_Field,Prompt
99
+ SimpleWorkflow,Start,,Starting node of the workflow,Echo,Process,Error,input,initial_data,
100
+ SimpleWorkflow,Process,,Process the input data,Default,End,Error,initial_data,processed_data,Processing data from previous step
101
+ SimpleWorkflow,End,,Final node of the workflow,Echo,,,processed_data,final_output,
102
+ SimpleWorkflow,Error,,Error handling node,Echo,,,error,error_message,
103
+ ```
104
+
105
+ This workflow has four nodes:
106
+ - **Start**: Takes initial input and passes it to the Process node
107
+ - **Process**: Processes the data and sends it to the End node on success
108
+ - **End**: Final node that outputs the processed data
109
+ - **Error**: Handles any errors that occur during processing
110
+
111
+ ### 2. Run the Workflow Using Python
112
+
113
+ ```python
114
+ from agentmap.runner import run_graph
115
+ from agentmap.logging import get_logger
116
+
117
+ logger = get_logger("MyApp")
118
+
119
+ # Define initial input data
120
+ initial_state = {
121
+ "input": "Hello from AgentMap!"
122
+ }
123
+
124
+ # Run the workflow
125
+ result = run_graph(
126
+ graph_name="SimpleWorkflow",
127
+ initial_state=initial_state,
128
+ csv_path="simple_workflow.csv"
129
+ )
130
+
131
+ # Display execution results
132
+ logger.info(f"Final output: {result.get('final_output')}")
133
+
134
+ # Display execution path
135
+ if "execution_steps" in result:
136
+ logger.info("\nExecution path:")
137
+ for step in result["execution_steps"]:
138
+ node = step["node"]
139
+ duration = step["duration"]
140
+ success = "✓" if step["success"] else "✗"
141
+ logger.info(f" {success} {node} ({duration:.3f}s)")
142
+ ```
143
+
144
+ ### 3. Run the Workflow Using CLI
145
+
146
+ ```bash
147
+ # Run with input from command line
148
+ agentmap run --graph SimpleWorkflow --csv simple_workflow.csv --state '{"input": "Hello from AgentMap!"}'
149
+ ```
150
+
151
+ ## 🧩 Built-in Agent Types
152
+
153
+ AgentMap comes with several built-in agent types:
154
+
155
+ | Agent Type | Description |
156
+ |------------|-------------|
157
+ | `default` | Simple agent that returns a message with the prompt |
158
+ | `echo` | Returns input data unchanged |
159
+ | `branching` | Test agent for conditional branching |
160
+ | `success` | Always succeeds |
161
+ | `failure` | Always fails |
162
+ | `input` | Prompts for user input during execution |
163
+ | `openai` | Uses OpenAI's models |
164
+ | `claude`/`anthropic` | Uses Anthropic's Claude models |
165
+ | `gemini`/`google` | Uses Google's Gemini models |
166
+
167
+ ## 📝 Tracking Workflow Execution
168
+
169
+ ### Automatic Execution Tracking
170
+
171
+ AgentMap automatically tracks the execution of your workflow. Every node execution is recorded in the `execution_steps` field of the result state. Each step contains:
172
+
173
+ - **node**: Name of the executed node
174
+ - **timestamp**: When the node started executing
175
+ - **duration**: How long the node took to execute (in seconds)
176
+ - **success**: Whether the node executed successfully
177
+
178
+ ```python
179
+ # Example of accessing execution steps
180
+ result = run_graph("MyWorkflow", initial_state)
181
+ steps = result.get("execution_steps", [])
182
+
183
+ for step in steps:
184
+ print(f"Node: {step['node']}")
185
+ print(f"Duration: {step['duration']}s")
186
+ print(f"Success: {step['success']}")
187
+ print("---")
188
+ ```
189
+
190
+ ### Visualizing the Execution Path
191
+
192
+ You can visualize the execution path using the recorded steps:
193
+
194
+ ```python
195
+ from agentmap.runner import run_graph
196
+
197
+ result = run_graph("MyWorkflow", initial_state)
198
+
199
+ print("Execution path:")
200
+ for i, step in enumerate(result.get("execution_steps", [])):
201
+ status = "✅" if step["success"] else "❌"
202
+ print(f"{i+1}. {status} {step['node']} ({step['duration']:.3f}s)")
203
+ ```
204
+
205
+ ## 🧭 Data Flow and State Management
206
+
207
+ Data flows through the workflow via a shared state object:
208
+
209
+ 1. Each node extracts inputs from state using `Input_Fields`
210
+ 2. The agent processes inputs and generates an output
211
+ 3. The output is stored in state at the location specified by `Output_Field`
212
+ 4. The next node accesses this data via its own `Input_Fields`
213
+
214
+ ### Inspecting State Changes
215
+
216
+ You can trace how data flows through your workflow by examining the state at each step:
217
+
218
+ ```python
219
+ import json
220
+ from agentmap.runner import run_graph
221
+ from agentmap.logging import get_logger
222
+
223
+ logger = get_logger()
224
+ logger.setLevel("DEBUG") # Enable detailed logging
225
+
226
+ # This will show state changes between nodes during execution
227
+ result = run_graph("MyWorkflow", initial_state)
228
+ ```
229
+
230
+ ## 🛠️ Customizing Agents
231
+
232
+ ### Creating Custom Agents
233
+
234
+ You can use the scaffolding tool to create custom agents:
235
+
236
+ ```bash
237
+ # Generate scaffold for custom agents in your workflow
238
+ agentmap scaffold --csv my_workflow.csv
239
+ ```
240
+
241
+ This creates Python files in `agentmap/agents/custom/` that you can customize:
242
+
243
+ ```python
244
+ from agentmap.agents.base_agent import BaseAgent
245
+ from typing import Dict, Any
246
+
247
+ class MyCustomAgent(BaseAgent):
248
+ def process(self, inputs: Dict[str, Any]) -> Any:
249
+ # Access input fields
250
+ input_text = inputs.get("input_field")
251
+
252
+ # Process the inputs
253
+ output = f"Processed: {input_text}"
254
+
255
+ # Return the output
256
+ return output
257
+ ```
258
+
259
+ ### Implementing Dynamic Routing
260
+
261
+ For complex routing logic, you can create custom routing functions:
262
+
263
+ ```python
264
+ # In agentmap/functions/choose_route.py
265
+ def choose_route(state, success_target, failure_target):
266
+ """
267
+ Choose next node based on custom conditions.
268
+ """
269
+ # Access state data
270
+ data = state.get("processed_data", {})
271
+
272
+ # Apply custom routing logic
273
+ if "important" in str(data).lower():
274
+ return "PriorityNode"
275
+ elif state.get("last_action_success", True):
276
+ return success_target
277
+ else:
278
+ return failure_target
279
+ ```
280
+
281
+ Then reference it in your CSV:
282
+
283
+ ```csv
284
+ MyWorkflow,ProcessNode,,Process data,Default,SuccessNode,FailureNode,input,processed_data,
285
+ MyWorkflow,ProcessNode,func:choose_route,Process data,Default,SuccessNode,FailureNode,input,processed_data,
286
+ ```
287
+
288
+ ## 🔄 Running Workflows
289
+
290
+ ### Via CLI
291
+
292
+ ```bash
293
+ # Run a workflow with initial state
294
+ agentmap run --graph MyWorkflow --state '{"initial_data": "value"}'
295
+
296
+ # Override CSV path
297
+ agentmap run --graph MyWorkflow --csv path/to/workflow.csv --state '{"initial_data": "value"}'
298
+
299
+ # Enable autocompile
300
+ agentmap run --graph MyWorkflow --state '{"initial_data": "value"}' --autocompile
301
+ ```
302
+
303
+ ### Via Python
304
+
305
+ ```python
306
+ from agentmap.runner import run_graph
307
+
308
+ result = run_graph(
309
+ graph_name="MyWorkflow",
310
+ initial_state={"initial_data": "value"},
311
+ csv_path="path/to/workflow.csv", # Optional
312
+ autocompile_override=True # Optional
313
+ )
314
+ ```
315
+
316
+ ### Via API Server
317
+
318
+ Start the server:
319
+
320
+ ```bash
321
+ # Start the FastAPI server
322
+ uvicorn agentmap.server:app --reload
323
+ ```
324
+
325
+ Then send requests:
326
+
327
+ ```bash
328
+ curl -X POST http://localhost:8000/run \
329
+ -H "Content-Type: application/json" \
330
+ -d '{"graph": "MyWorkflow", "state": {"initial_data": "value"}}'
331
+ ```
332
+
333
+ ## 🔧 Configuration
334
+
335
+ AgentMap uses a YAML configuration file (`agentmap_config.yaml`) and environment variables:
336
+
337
+ ```yaml
338
+ csv_path: path/to/default.csv
339
+ autocompile: false
340
+
341
+ paths:
342
+ custom_agents: "agentmap/agents/custom"
343
+ functions: "agentmap/functions"
344
+
345
+ llm:
346
+ openai:
347
+ api_key: "" # Will fall back to OPENAI_API_KEY env var
348
+ model: "gpt-3.5-turbo"
349
+ anthropic:
350
+ api_key: "" # Will fall back to ANTHROPIC_API_KEY env var
351
+ model: "claude-3-sonnet-20240229"
352
+ ```
353
+
354
+ ## 🌐 Serverless Deployment
355
+
356
+ AgentMap includes a handler for serverless deployment:
357
+
358
+ ```python
359
+ # AWS Lambda
360
+ from agentmap.handler import handler
361
+
362
+ def lambda_handler(event, context):
363
+ return handler(event, context)
364
+ ```
365
+
366
+ ## 📚 Advanced Topics
367
+
368
+ ### Compiling Graphs for Performance
369
+
370
+ For production use, you can compile graphs to improve performance:
371
+
372
+ ```bash
373
+ # Compile all graphs defined in your CSV
374
+ agentmap compile
375
+
376
+ # Compile a specific graph
377
+ agentmap compile --graph MyWorkflow
378
+ ```
379
+
380
+ ### Exporting Graphs as Python Code
381
+
382
+ You can export graphs as Python code for further customization:
383
+
384
+ ```bash
385
+ # Export as Python script
386
+ agentmap export --graph MyWorkflow --output my_workflow.py
387
+ ```
388
+
389
+ ## 🤝 Contributing
390
+
391
+ Contributions are welcome! Please feel free to submit a Pull Request.
392
+
393
+ ## 📜 License
394
+
395
+ [MIT License](LICENSE)