agentu 1.0.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 (43) hide show
  1. agentu-1.0.0/.github/workflows/python-package.yml +57 -0
  2. agentu-1.0.0/.gitignore +15 -0
  3. agentu-1.0.0/CHANGELOG.md +45 -0
  4. agentu-1.0.0/LICENSE +21 -0
  5. agentu-1.0.0/PKG-INFO +249 -0
  6. agentu-1.0.0/README.md +200 -0
  7. agentu-1.0.0/examples/api.py +17 -0
  8. agentu-1.0.0/examples/basic.py +29 -0
  9. agentu-1.0.0/examples/memory.py +25 -0
  10. agentu-1.0.0/examples/orchestrator.py +33 -0
  11. agentu-1.0.0/examples/serve_agent.py +29 -0
  12. agentu-1.0.0/examples/simple_agent.py +44 -0
  13. agentu-1.0.0/examples/workflow.py +68 -0
  14. agentu-1.0.0/pyproject.toml +37 -0
  15. agentu-1.0.0/setup.cfg +4 -0
  16. agentu-1.0.0/src/agentu/__init__.py +36 -0
  17. agentu-1.0.0/src/agentu/agent.py +462 -0
  18. agentu-1.0.0/src/agentu/mcp_config.py +172 -0
  19. agentu-1.0.0/src/agentu/mcp_tool.py +198 -0
  20. agentu-1.0.0/src/agentu/mcp_transport.py +499 -0
  21. agentu-1.0.0/src/agentu/memory.py +417 -0
  22. agentu-1.0.0/src/agentu/memory_storage.py +385 -0
  23. agentu-1.0.0/src/agentu/orchestrator.py.old +518 -0
  24. agentu-1.0.0/src/agentu/search.py +108 -0
  25. agentu-1.0.0/src/agentu/serve.py +265 -0
  26. agentu-1.0.0/src/agentu/tools.py +74 -0
  27. agentu-1.0.0/src/agentu/utils.py +13 -0
  28. agentu-1.0.0/src/agentu/workflow.py +196 -0
  29. agentu-1.0.0/src/agentu.egg-info/PKG-INFO +249 -0
  30. agentu-1.0.0/src/agentu.egg-info/SOURCES.txt +41 -0
  31. agentu-1.0.0/src/agentu.egg-info/dependency_links.txt +1 -0
  32. agentu-1.0.0/src/agentu.egg-info/requires.txt +6 -0
  33. agentu-1.0.0/src/agentu.egg-info/top_level.txt +1 -0
  34. agentu-1.0.0/tests/__init__.py +1 -0
  35. agentu-1.0.0/tests/test_agent.py +108 -0
  36. agentu-1.0.0/tests/test_mcp.py +581 -0
  37. agentu-1.0.0/tests/test_memory.py +368 -0
  38. agentu-1.0.0/tests/test_memory_storage.py +260 -0
  39. agentu-1.0.0/tests/test_orchestrator.py.old +368 -0
  40. agentu-1.0.0/tests/test_search.py +26 -0
  41. agentu-1.0.0/tests/test_serve.py +286 -0
  42. agentu-1.0.0/tests/test_tools.py +70 -0
  43. agentu-1.0.0/tests/test_workflow.py +356 -0
@@ -0,0 +1,57 @@
1
+ # This workflow will upload a Python Package to PyPI when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
3
+
4
+ # This workflow uses actions that are not certified by GitHub.
5
+ # They are provided by a third-party and are governed by
6
+ # separate terms of service, privacy policy, and support
7
+ # documentation.
8
+
9
+ name: Upload Python Package
10
+
11
+ on:
12
+ release:
13
+ types: [published]
14
+ workflow_dispatch:
15
+
16
+ permissions:
17
+ contents: read
18
+
19
+ jobs:
20
+ release-build:
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - uses: actions/checkout@v4
25
+
26
+ - uses: actions/setup-python@v5
27
+ with:
28
+ python-version: "3.x"
29
+
30
+ - name: Build release distributions
31
+ run: |
32
+ python -m pip install build
33
+ python -m build
34
+
35
+ - name: Upload distributions
36
+ uses: actions/upload-artifact@v4
37
+ with:
38
+ name: release-dists
39
+ path: dist/
40
+
41
+ pypi-publish:
42
+ runs-on: ubuntu-latest
43
+ needs:
44
+ - release-build
45
+
46
+ steps:
47
+ - name: Retrieve release distributions
48
+ uses: actions/download-artifact@v4
49
+ with:
50
+ name: release-dists
51
+ path: dist/
52
+
53
+ - name: Publish release distributions to PyPI
54
+ uses: pypa/gh-action-pypi-publish@release/v1
55
+ with:
56
+ user: __token__
57
+ password: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,15 @@
1
+ dist
2
+ llm-task-log.md
3
+ __pycache__/
4
+ *.pyc
5
+ *.pyo
6
+ *.pyd
7
+ *.db
8
+ *.sqlite
9
+ *.sqlite3
10
+ .pytest_cache/
11
+ .coverage
12
+ htmlcov/
13
+ *.egg-info/
14
+ build/
15
+ .DS_Store
@@ -0,0 +1,45 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [1.0.0] - 2025-01-09
9
+
10
+ ### Added
11
+ - **Workflow system** with operator-based composition (`>>` for sequential, `&` for parallel)
12
+ - `Agent.__call__()` method to create workflow steps with clean syntax
13
+ - Comprehensive workflow tests (18 new tests)
14
+ - `workflow.py` module with `Step`, `SequentialStep`, and `ParallelStep` classes
15
+ - Automatic context passing between workflow steps
16
+ - Lambda support for precise data flow control in workflows
17
+ - New workflow examples (`examples/workflow.py`, `examples/orchestrator.py`)
18
+
19
+ ### Changed
20
+ - **BREAKING**: Removed `Orchestrator`, `ExecutionMode`, `Task`, and `Message` classes
21
+ - **BREAKING**: Removed `add_tool()`, `add_tools()`, `add_agent()`, `add_agents()` methods
22
+ - **BREAKING**: Removed `execute_tool()` and `process_input()` (use `call()` and `infer()`)
23
+ - Simplified API: `with_tools()` and `with_agents()` now always require lists
24
+ - Updated all examples to use new workflow operators
25
+ - Simplified README with real-world automated code review example
26
+ - Updated MCP implementation to use `with_mcp()` method
27
+ - Changed tagline to "The sleekest way to build AI agents"
28
+ - Updated default model examples from `llama3` to `qwen3`
29
+
30
+ ### Removed
31
+ - Orchestrator-based multi-agent system (replaced by workflow operators)
32
+ - Task class for simple use cases (still available for advanced scenarios)
33
+ - Backward compatibility aliases
34
+ - `SERVING.md` (documentation consolidated into README)
35
+ - Redundant example files
36
+
37
+ ### Fixed
38
+ - MCP configuration to use correct `type` parameter instead of `auth_type`
39
+ - Agent initialization to use `with_mcp()` instead of removed `load_mcp_tools()`
40
+ - All orchestrator references updated to use `infer()` instead of `process_input()`
41
+ - Test compatibility with new workflow system
42
+
43
+ ## [0.3.0] - Previous release
44
+
45
+ Initial release with basic agent functionality, tools, memory, and orchestration.
agentu-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hemanth HM <hemanth.hm@gmail.com>
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.
agentu-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,249 @@
1
+ Metadata-Version: 2.4
2
+ Name: agentu
3
+ Version: 1.0.0
4
+ Summary: A flexible Python package for creating AI agents with customizable tools
5
+ Author-email: Hemanth HM <hemanth.hm@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2025 Hemanth HM <hemanth.hm@gmail.com>
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/hemanth/agentu
29
+ Project-URL: Bug Tracker, https://github.com/hemanth/agentu/issues
30
+ Keywords: ai,agents,openai,llm,tools
31
+ Classifier: Development Status :: 3 - Alpha
32
+ Classifier: Intended Audience :: Developers
33
+ Classifier: License :: OSI Approved :: MIT License
34
+ Classifier: Programming Language :: Python :: 3
35
+ Classifier: Programming Language :: Python :: 3.7
36
+ Classifier: Programming Language :: Python :: 3.8
37
+ Classifier: Programming Language :: Python :: 3.9
38
+ Classifier: Programming Language :: Python :: 3.10
39
+ Requires-Python: >=3.7
40
+ Description-Content-Type: text/markdown
41
+ License-File: LICENSE
42
+ Requires-Dist: requests>=2.25.1
43
+ Requires-Dist: aiohttp>=3.8.0
44
+ Requires-Dist: duckduckgo-search>=4.1.1
45
+ Requires-Dist: fastapi>=0.100.0
46
+ Requires-Dist: uvicorn>=0.23.0
47
+ Requires-Dist: pydantic>=2.0.0
48
+ Dynamic: license-file
49
+
50
+ # AgentU
51
+
52
+ **The sleekest way to build AI agents.**
53
+
54
+ ```bash
55
+ pip install agentu
56
+ ```
57
+
58
+ ## Why AgentU?
59
+
60
+ ```python
61
+ # This is all you need:
62
+ from agentu import Agent
63
+
64
+ def search_products(query: str) -> list:
65
+ return db.products.search(query)
66
+
67
+ agent = Agent("sales").with_tools([search_products])
68
+
69
+ # Direct execution
70
+ result = await agent.call("search_products", {"query": "laptop"})
71
+
72
+ # Natural language (LLM figures out the tool + params)
73
+ result = await agent.infer("Find me laptops under $1500")
74
+ ```
75
+
76
+ ## Workflows in 3 Lines
77
+
78
+ ```python
79
+ # Sequential: researcher → analyst → writer
80
+ workflow = researcher("Find AI trends") >> analyst("Analyze") >> writer("Summarize")
81
+
82
+ # Parallel: run 3 searches concurrently
83
+ workflow = search("AI") & search("ML") & search("Crypto")
84
+
85
+ # Combined: parallel then merge
86
+ workflow = (search("AI") & search("ML") & search("Crypto")) >> analyst("Compare")
87
+
88
+ result = await workflow.run()
89
+ ```
90
+
91
+ **`>>` chains steps. `&` runs in parallel.** That's the entire API.
92
+
93
+ ## Memory
94
+
95
+ ```python
96
+ agent.remember("Customer prefers email", importance=0.9)
97
+ memories = agent.recall(query="email")
98
+ ```
99
+
100
+ Stored in SQLite. Searchable. Persistent.
101
+
102
+ ## REST API
103
+
104
+ ```python
105
+ from agentu import serve
106
+
107
+ serve(agent, port=8000)
108
+ # curl -X POST localhost:8000/execute -d '{"tool_name": "search_products", ...}'
109
+ ```
110
+
111
+ Auto-generated Swagger docs at `/docs`.
112
+
113
+ ## Real-World Example: Automated Code Review
114
+
115
+ ```python
116
+ import asyncio
117
+ from agentu import Agent
118
+
119
+ def get_pr_diff(pr_number: int) -> str:
120
+ """Fetch PR changes from GitHub."""
121
+ # GitHub API integration
122
+ return "diff --git a/src/auth.py... +added_line -removed_line"
123
+
124
+ def run_tests(branch: str) -> dict:
125
+ """Run test suite."""
126
+ return {"passed": 47, "failed": 2, "coverage": 94.2}
127
+
128
+ def post_comment(pr_number: int, comment: str) -> bool:
129
+ """Post review comment to GitHub."""
130
+ return True
131
+
132
+ async def main():
133
+ # Setup agents
134
+ reviewer = Agent("reviewer", model="gpt-4").with_tools([get_pr_diff])
135
+ tester = Agent("tester").with_tools([run_tests])
136
+ commenter = Agent("commenter").with_tools([post_comment])
137
+
138
+ # Parallel: review code + run tests
139
+ workflow = reviewer("Review PR #247") & tester("Run tests on PR #247")
140
+ code_review, test_results = await workflow.run()
141
+
142
+ # Natural language: synthesize findings
143
+ summary = await commenter.infer(
144
+ f"Create a review comment for PR #247. "
145
+ f"Code review: {code_review}. Tests: {test_results}. "
146
+ f"Be constructive and specific."
147
+ )
148
+
149
+ # Post to GitHub
150
+ await commenter.call("post_comment", {"pr_number": 247, "comment": summary})
151
+ print("✓ Review posted to PR #247")
152
+
153
+ asyncio.run(main())
154
+ ```
155
+
156
+ **What this does:**
157
+ - Reviews code and runs tests **in parallel** (saves time)
158
+ - Uses `infer()` to write **human-quality review comments**
159
+ - Posts directly to GitHub
160
+ - **Zero manual work** - runs on every PR
161
+
162
+ ## Advanced: Lambda Control
163
+
164
+ Need precise data flow? Use lambdas:
165
+
166
+ ```python
167
+ workflow = (
168
+ researcher("Find companies")
169
+ >> analyst(lambda prev: f"Extract top 5 from: {prev['result']}")
170
+ >> writer(lambda prev: f"Write report about: {prev['companies']}")
171
+ )
172
+ ```
173
+
174
+ ## LLM Support
175
+
176
+ Works with any OpenAI-compatible API:
177
+
178
+ ```python
179
+ # Ollama (default)
180
+ Agent("assistant", model="qwen3")
181
+
182
+ # OpenAI
183
+ Agent("assistant", model="gpt-4", api_key="sk-...")
184
+
185
+ # vLLM, LM Studio, etc.
186
+ Agent("assistant", model="mistral", api_base="http://localhost:8000/v1")
187
+ ```
188
+
189
+ ## MCP Integration
190
+
191
+ Connect to Model Context Protocol servers:
192
+
193
+ ```python
194
+ agent.with_mcp(["http://localhost:3000"])
195
+ agent.with_mcp([{"url": "https://api.com/mcp", "headers": {"Auth": "token"}}])
196
+ ```
197
+
198
+ ## API Reference
199
+
200
+ ### Agent
201
+ ```python
202
+ agent = Agent(name, model="qwen3", enable_memory=True)
203
+ agent.with_tools([func1, func2]) # Add tools
204
+ agent.with_mcp([url]) # Connect MCP servers
205
+
206
+ await agent.call("tool", params) # Direct execution
207
+ await agent.infer("natural language") # LLM routing
208
+
209
+ agent.remember(content, importance=0.8) # Store
210
+ agent.recall(query) # Search
211
+ ```
212
+
213
+ ### Workflows
214
+ ```python
215
+ agent("task") # Create step
216
+ step1 >> step2 # Sequential
217
+ step1 & step2 # Parallel
218
+ await workflow.run() # Execute
219
+ ```
220
+
221
+ ### serve()
222
+ ```python
223
+ serve(agent, port=8000, enable_cors=True)
224
+ ```
225
+
226
+ **Endpoints:** `/execute`, `/process`, `/tools`, `/memory/remember`, `/memory/recall`, `/docs`
227
+
228
+ ## Examples
229
+
230
+ ```bash
231
+ git clone https://github.com/hemanth/agentu
232
+ cd agentu
233
+
234
+ python examples/basic.py # Simple agent
235
+ python examples/workflow.py # Workflows
236
+ python examples/memory.py # Memory system
237
+ python examples/api.py # REST API
238
+ ```
239
+
240
+ ## Testing
241
+
242
+ ```bash
243
+ pytest
244
+ pytest --cov=agentu
245
+ ```
246
+
247
+ ## License
248
+
249
+ MIT
agentu-1.0.0/README.md ADDED
@@ -0,0 +1,200 @@
1
+ # AgentU
2
+
3
+ **The sleekest way to build AI agents.**
4
+
5
+ ```bash
6
+ pip install agentu
7
+ ```
8
+
9
+ ## Why AgentU?
10
+
11
+ ```python
12
+ # This is all you need:
13
+ from agentu import Agent
14
+
15
+ def search_products(query: str) -> list:
16
+ return db.products.search(query)
17
+
18
+ agent = Agent("sales").with_tools([search_products])
19
+
20
+ # Direct execution
21
+ result = await agent.call("search_products", {"query": "laptop"})
22
+
23
+ # Natural language (LLM figures out the tool + params)
24
+ result = await agent.infer("Find me laptops under $1500")
25
+ ```
26
+
27
+ ## Workflows in 3 Lines
28
+
29
+ ```python
30
+ # Sequential: researcher → analyst → writer
31
+ workflow = researcher("Find AI trends") >> analyst("Analyze") >> writer("Summarize")
32
+
33
+ # Parallel: run 3 searches concurrently
34
+ workflow = search("AI") & search("ML") & search("Crypto")
35
+
36
+ # Combined: parallel then merge
37
+ workflow = (search("AI") & search("ML") & search("Crypto")) >> analyst("Compare")
38
+
39
+ result = await workflow.run()
40
+ ```
41
+
42
+ **`>>` chains steps. `&` runs in parallel.** That's the entire API.
43
+
44
+ ## Memory
45
+
46
+ ```python
47
+ agent.remember("Customer prefers email", importance=0.9)
48
+ memories = agent.recall(query="email")
49
+ ```
50
+
51
+ Stored in SQLite. Searchable. Persistent.
52
+
53
+ ## REST API
54
+
55
+ ```python
56
+ from agentu import serve
57
+
58
+ serve(agent, port=8000)
59
+ # curl -X POST localhost:8000/execute -d '{"tool_name": "search_products", ...}'
60
+ ```
61
+
62
+ Auto-generated Swagger docs at `/docs`.
63
+
64
+ ## Real-World Example: Automated Code Review
65
+
66
+ ```python
67
+ import asyncio
68
+ from agentu import Agent
69
+
70
+ def get_pr_diff(pr_number: int) -> str:
71
+ """Fetch PR changes from GitHub."""
72
+ # GitHub API integration
73
+ return "diff --git a/src/auth.py... +added_line -removed_line"
74
+
75
+ def run_tests(branch: str) -> dict:
76
+ """Run test suite."""
77
+ return {"passed": 47, "failed": 2, "coverage": 94.2}
78
+
79
+ def post_comment(pr_number: int, comment: str) -> bool:
80
+ """Post review comment to GitHub."""
81
+ return True
82
+
83
+ async def main():
84
+ # Setup agents
85
+ reviewer = Agent("reviewer", model="gpt-4").with_tools([get_pr_diff])
86
+ tester = Agent("tester").with_tools([run_tests])
87
+ commenter = Agent("commenter").with_tools([post_comment])
88
+
89
+ # Parallel: review code + run tests
90
+ workflow = reviewer("Review PR #247") & tester("Run tests on PR #247")
91
+ code_review, test_results = await workflow.run()
92
+
93
+ # Natural language: synthesize findings
94
+ summary = await commenter.infer(
95
+ f"Create a review comment for PR #247. "
96
+ f"Code review: {code_review}. Tests: {test_results}. "
97
+ f"Be constructive and specific."
98
+ )
99
+
100
+ # Post to GitHub
101
+ await commenter.call("post_comment", {"pr_number": 247, "comment": summary})
102
+ print("✓ Review posted to PR #247")
103
+
104
+ asyncio.run(main())
105
+ ```
106
+
107
+ **What this does:**
108
+ - Reviews code and runs tests **in parallel** (saves time)
109
+ - Uses `infer()` to write **human-quality review comments**
110
+ - Posts directly to GitHub
111
+ - **Zero manual work** - runs on every PR
112
+
113
+ ## Advanced: Lambda Control
114
+
115
+ Need precise data flow? Use lambdas:
116
+
117
+ ```python
118
+ workflow = (
119
+ researcher("Find companies")
120
+ >> analyst(lambda prev: f"Extract top 5 from: {prev['result']}")
121
+ >> writer(lambda prev: f"Write report about: {prev['companies']}")
122
+ )
123
+ ```
124
+
125
+ ## LLM Support
126
+
127
+ Works with any OpenAI-compatible API:
128
+
129
+ ```python
130
+ # Ollama (default)
131
+ Agent("assistant", model="qwen3")
132
+
133
+ # OpenAI
134
+ Agent("assistant", model="gpt-4", api_key="sk-...")
135
+
136
+ # vLLM, LM Studio, etc.
137
+ Agent("assistant", model="mistral", api_base="http://localhost:8000/v1")
138
+ ```
139
+
140
+ ## MCP Integration
141
+
142
+ Connect to Model Context Protocol servers:
143
+
144
+ ```python
145
+ agent.with_mcp(["http://localhost:3000"])
146
+ agent.with_mcp([{"url": "https://api.com/mcp", "headers": {"Auth": "token"}}])
147
+ ```
148
+
149
+ ## API Reference
150
+
151
+ ### Agent
152
+ ```python
153
+ agent = Agent(name, model="qwen3", enable_memory=True)
154
+ agent.with_tools([func1, func2]) # Add tools
155
+ agent.with_mcp([url]) # Connect MCP servers
156
+
157
+ await agent.call("tool", params) # Direct execution
158
+ await agent.infer("natural language") # LLM routing
159
+
160
+ agent.remember(content, importance=0.8) # Store
161
+ agent.recall(query) # Search
162
+ ```
163
+
164
+ ### Workflows
165
+ ```python
166
+ agent("task") # Create step
167
+ step1 >> step2 # Sequential
168
+ step1 & step2 # Parallel
169
+ await workflow.run() # Execute
170
+ ```
171
+
172
+ ### serve()
173
+ ```python
174
+ serve(agent, port=8000, enable_cors=True)
175
+ ```
176
+
177
+ **Endpoints:** `/execute`, `/process`, `/tools`, `/memory/remember`, `/memory/recall`, `/docs`
178
+
179
+ ## Examples
180
+
181
+ ```bash
182
+ git clone https://github.com/hemanth/agentu
183
+ cd agentu
184
+
185
+ python examples/basic.py # Simple agent
186
+ python examples/workflow.py # Workflows
187
+ python examples/memory.py # Memory system
188
+ python examples/api.py # REST API
189
+ ```
190
+
191
+ ## Testing
192
+
193
+ ```bash
194
+ pytest
195
+ pytest --cov=agentu
196
+ ```
197
+
198
+ ## License
199
+
200
+ MIT
@@ -0,0 +1,17 @@
1
+ """Serve agent as REST API."""
2
+ from agentu import Agent, serve
3
+
4
+
5
+ def get_status(order_id: str) -> dict:
6
+ """Get order status."""
7
+ return {"order_id": order_id, "status": "shipped"}
8
+
9
+
10
+ # Create agent
11
+ agent = Agent("support").with_tools([get_status])
12
+
13
+ # Serve on port 8000
14
+ # curl -X POST http://localhost:8000/execute \
15
+ # -H "Content-Type: application/json" \
16
+ # -d '{"tool_name": "get_status", "parameters": {"order_id": "12345"}}'
17
+ serve(agent, port=8000)
@@ -0,0 +1,29 @@
1
+ """Basic agent with tools."""
2
+ import asyncio
3
+ from agentu import Agent
4
+
5
+
6
+ def add(x: int, y: int) -> int:
7
+ """Add two numbers."""
8
+ return x + y
9
+
10
+
11
+ def multiply(x: int, y: int) -> int:
12
+ """Multiply two numbers."""
13
+ return x * y
14
+
15
+
16
+ async def main():
17
+ # Create agent and add tools
18
+ agent = Agent("calculator").with_tools([add, multiply])
19
+
20
+ # Direct execution (no LLM needed)
21
+ result = await agent.call("add", {"x": 5, "y": 3})
22
+ print(f"5 + 3 = {result}")
23
+
24
+ result = await agent.call("multiply", {"x": 5, "y": 3})
25
+ print(f"5 * 3 = {result}")
26
+
27
+
28
+ if __name__ == "__main__":
29
+ asyncio.run(main())
@@ -0,0 +1,25 @@
1
+ """Agent with memory."""
2
+ import asyncio
3
+ from agentu import Agent
4
+
5
+
6
+ async def main():
7
+ agent = Agent("assistant", enable_memory=True)
8
+
9
+ # Store facts
10
+ agent.remember("User prefers email", memory_type="fact", importance=0.8)
11
+ agent.remember("Customer ordered item #12345", memory_type="conversation")
12
+
13
+ # Recall
14
+ memories = agent.recall(query="email", limit=5)
15
+ for mem in memories:
16
+ print(f"- {mem.content}")
17
+
18
+ # Stats
19
+ stats = agent.get_memory_stats()
20
+ print(f"\nShort-term: {stats['short_term_size']}")
21
+ print(f"Long-term: {stats['long_term_size']}")
22
+
23
+
24
+ if __name__ == "__main__":
25
+ asyncio.run(main())
@@ -0,0 +1,33 @@
1
+ """Workflow composition examples."""
2
+ import asyncio
3
+ from agentu import Agent
4
+
5
+
6
+ def research(topic: str) -> dict:
7
+ """Research a topic."""
8
+ return {"topic": topic, "findings": f"Findings about {topic}"}
9
+
10
+
11
+ def analyze(data: str) -> dict:
12
+ """Analyze data."""
13
+ return {"analysis": "Mock analysis", "confidence": 0.85}
14
+
15
+
16
+ async def main():
17
+ # Create agents
18
+ researcher = Agent("researcher").with_tools([research])
19
+ analyst = Agent("analyst").with_tools([analyze])
20
+
21
+ # Sequential workflow
22
+ workflow = researcher("Research AI trends") >> analyst("Analyze findings")
23
+ result = await workflow.run()
24
+ print(f"Sequential result: {result}")
25
+
26
+ # Parallel workflow
27
+ workflow = researcher("AI") & researcher("ML") & researcher("Crypto")
28
+ results = await workflow.run()
29
+ print(f"Parallel results: {len(results)} tasks completed")
30
+
31
+
32
+ if __name__ == "__main__":
33
+ asyncio.run(main())