tiny-agent-os 0.0.1__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 (111) hide show
  1. tiny_agent_os-0.0.1/.aider.conf.yml +36 -0
  2. tiny_agent_os-0.0.1/.envexample +9 -0
  3. tiny_agent_os-0.0.1/.gitignore +122 -0
  4. tiny_agent_os-0.0.1/LICENSE +53 -0
  5. tiny_agent_os-0.0.1/MANIFEST.in +4 -0
  6. tiny_agent_os-0.0.1/PKG-INFO +377 -0
  7. tiny_agent_os-0.0.1/README.md +347 -0
  8. tiny_agent_os-0.0.1/config.yml +99 -0
  9. tiny_agent_os-0.0.1/documentation/agents.md +326 -0
  10. tiny_agent_os-0.0.1/documentation/agentsarefunction.md +72 -0
  11. tiny_agent_os-0.0.1/documentation/automatic_tool_selection.md +128 -0
  12. tiny_agent_os-0.0.1/documentation/best_practice_tool_chains.md +63 -0
  13. tiny_agent_os-0.0.1/documentation/factory.md +175 -0
  14. tiny_agent_os-0.0.1/documentation/factory_pattern_vs_manual.md +86 -0
  15. tiny_agent_os-0.0.1/documentation/orchestration.md +220 -0
  16. tiny_agent_os-0.0.1/documentation/orchestrator_overview.md +76 -0
  17. tiny_agent_os-0.0.1/documentation/tiny_chain_implementaion.md +228 -0
  18. tiny_agent_os-0.0.1/documentation/tiny_chain_overview.md +68 -0
  19. tiny_agent_os-0.0.1/documentation/tinyagent_flow.md +129 -0
  20. tiny_agent_os-0.0.1/documentation/triage_tiny_chain.md +460 -0
  21. tiny_agent_os-0.0.1/documentation/why_tool_wrappers_exist.md +48 -0
  22. tiny_agent_os-0.0.1/external_tools/text_rank/Makefile +9 -0
  23. tiny_agent_os-0.0.1/external_tools/text_rank/README.md +103 -0
  24. tiny_agent_os-0.0.1/external_tools/text_rank/manifest.json +30 -0
  25. tiny_agent_os-0.0.1/external_tools/text_rank/test.sh +36 -0
  26. tiny_agent_os-0.0.1/external_tools/text_rank/test_integration.py +59 -0
  27. tiny_agent_os-0.0.1/external_tools/text_rank/text_rank +0 -0
  28. tiny_agent_os-0.0.1/external_tools/text_rank/text_rank.c +509 -0
  29. tiny_agent_os-0.0.1/mcp/client.js +68 -0
  30. tiny_agent_os-0.0.1/mcp/client.ts +68 -0
  31. tiny_agent_os-0.0.1/mcp/index.ts +382 -0
  32. tiny_agent_os-0.0.1/mcp/package-lock.json +1185 -0
  33. tiny_agent_os-0.0.1/mcp/package.json +23 -0
  34. tiny_agent_os-0.0.1/mcp/server.js +168 -0
  35. tiny_agent_os-0.0.1/mcp/tsconfig.json +19 -0
  36. tiny_agent_os-0.0.1/pyproject.toml +60 -0
  37. tiny_agent_os-0.0.1/pytest.ini +8 -0
  38. tiny_agent_os-0.0.1/requirements.txt +52 -0
  39. tiny_agent_os-0.0.1/scripts/pip_smoke_test.sh +53 -0
  40. tiny_agent_os-0.0.1/scripts/publish_to_pip.sh +109 -0
  41. tiny_agent_os-0.0.1/setup.cfg +4 -0
  42. tiny_agent_os-0.0.1/src/tiny_agent_os.egg-info/PKG-INFO +377 -0
  43. tiny_agent_os-0.0.1/src/tiny_agent_os.egg-info/SOURCES.txt +109 -0
  44. tiny_agent_os-0.0.1/src/tiny_agent_os.egg-info/dependency_links.txt +1 -0
  45. tiny_agent_os-0.0.1/src/tiny_agent_os.egg-info/entry_points.txt +2 -0
  46. tiny_agent_os-0.0.1/src/tiny_agent_os.egg-info/requires.txt +13 -0
  47. tiny_agent_os-0.0.1/src/tiny_agent_os.egg-info/top_level.txt +1 -0
  48. tiny_agent_os-0.0.1/src/tinyagent/__init__.py +75 -0
  49. tiny_agent_os-0.0.1/src/tinyagent/_version.py +21 -0
  50. tiny_agent_os-0.0.1/src/tinyagent/agent.py +957 -0
  51. tiny_agent_os-0.0.1/src/tinyagent/chat/__init__.py +12 -0
  52. tiny_agent_os-0.0.1/src/tinyagent/chat/chat_mode.py +291 -0
  53. tiny_agent_os-0.0.1/src/tinyagent/cli/__init__.py +16 -0
  54. tiny_agent_os-0.0.1/src/tinyagent/cli/colors.py +104 -0
  55. tiny_agent_os-0.0.1/src/tinyagent/cli/main.py +664 -0
  56. tiny_agent_os-0.0.1/src/tinyagent/cli/spinner.py +94 -0
  57. tiny_agent_os-0.0.1/src/tinyagent/cli.py +47 -0
  58. tiny_agent_os-0.0.1/src/tinyagent/config/__init__.py +14 -0
  59. tiny_agent_os-0.0.1/src/tinyagent/config/config.py +258 -0
  60. tiny_agent_os-0.0.1/src/tinyagent/decorators.py +187 -0
  61. tiny_agent_os-0.0.1/src/tinyagent/exceptions.py +85 -0
  62. tiny_agent_os-0.0.1/src/tinyagent/factory/__init__.py +18 -0
  63. tiny_agent_os-0.0.1/src/tinyagent/factory/agent_factory.py +439 -0
  64. tiny_agent_os-0.0.1/src/tinyagent/factory/dynamic_agent_factory.py +561 -0
  65. tiny_agent_os-0.0.1/src/tinyagent/factory/orchestrator.py +1514 -0
  66. tiny_agent_os-0.0.1/src/tinyagent/factory/tiny_chain.py +552 -0
  67. tiny_agent_os-0.0.1/src/tinyagent/logging.py +97 -0
  68. tiny_agent_os-0.0.1/src/tinyagent/mcp/__init__.py +14 -0
  69. tiny_agent_os-0.0.1/src/tinyagent/mcp/manager.py +321 -0
  70. tiny_agent_os-0.0.1/src/tinyagent/prompts/README.md +133 -0
  71. tiny_agent_os-0.0.1/src/tinyagent/prompts/default.md +14 -0
  72. tiny_agent_os-0.0.1/src/tinyagent/prompts/prompt_manager.py +206 -0
  73. tiny_agent_os-0.0.1/src/tinyagent/prompts/system/agent.md +50 -0
  74. tiny_agent_os-0.0.1/src/tinyagent/prompts/system/retry.md +55 -0
  75. tiny_agent_os-0.0.1/src/tinyagent/prompts/system/strict_json.md +54 -0
  76. tiny_agent_os-0.0.1/src/tinyagent/prompts/system.md +10 -0
  77. tiny_agent_os-0.0.1/src/tinyagent/prompts/tools/calculator.md +13 -0
  78. tiny_agent_os-0.0.1/src/tinyagent/prompts/tools/weather.md +7 -0
  79. tiny_agent_os-0.0.1/src/tinyagent/prompts/workflows/riv_reflect.md +62 -0
  80. tiny_agent_os-0.0.1/src/tinyagent/prompts/workflows/riv_verify.md +47 -0
  81. tiny_agent_os-0.0.1/src/tinyagent/prompts/workflows/triage.md +129 -0
  82. tiny_agent_os-0.0.1/src/tinyagent/tool.py +185 -0
  83. tiny_agent_os-0.0.1/src/tinyagent/tools/README.md +391 -0
  84. tiny_agent_os-0.0.1/src/tinyagent/tools/__init__.py +39 -0
  85. tiny_agent_os-0.0.1/src/tinyagent/tools/aider.py +122 -0
  86. tiny_agent_os-0.0.1/src/tinyagent/tools/anon_coder.py +296 -0
  87. tiny_agent_os-0.0.1/src/tinyagent/tools/boilerplate_tool.py +147 -0
  88. tiny_agent_os-0.0.1/src/tinyagent/tools/brave_search.py +104 -0
  89. tiny_agent_os-0.0.1/src/tinyagent/tools/codeagent_tool.py +217 -0
  90. tiny_agent_os-0.0.1/src/tinyagent/tools/content_processor.py +285 -0
  91. tiny_agent_os-0.0.1/src/tinyagent/tools/custom_text_browser.py +965 -0
  92. tiny_agent_os-0.0.1/src/tinyagent/tools/duckduckgo_search.py +153 -0
  93. tiny_agent_os-0.0.1/src/tinyagent/tools/external.py +303 -0
  94. tiny_agent_os-0.0.1/src/tinyagent/tools/file_manipulator.py +274 -0
  95. tiny_agent_os-0.0.1/src/tinyagent/tools/final_extractor_tool.py +249 -0
  96. tiny_agent_os-0.0.1/src/tinyagent/tools/llm_serializer.py +124 -0
  97. tiny_agent_os-0.0.1/src/tinyagent/tools/markdown_gen.py +300 -0
  98. tiny_agent_os-0.0.1/src/tinyagent/tools/ripgrep.py +136 -0
  99. tiny_agent_os-0.0.1/src/tinyagent/utils/__init__.py +13 -0
  100. tiny_agent_os-0.0.1/src/tinyagent/utils/json_parser.py +231 -0
  101. tiny_agent_os-0.0.1/src/tinyagent/utils/logging_utils.py +78 -0
  102. tiny_agent_os-0.0.1/src/tinyagent/utils/openrouter_request.py +123 -0
  103. tiny_agent_os-0.0.1/src/tinyagent/utils/serialization.py +185 -0
  104. tiny_agent_os-0.0.1/src/tinyagent/utils/structured_outputs.py +131 -0
  105. tiny_agent_os-0.0.1/src/tinyagent/utils/type_converter.py +134 -0
  106. tiny_agent_os-0.0.1/static/images/func_agent.png +0 -0
  107. tiny_agent_os-0.0.1/static/images/logo.png +0 -0
  108. tiny_agent_os-0.0.1/static/images/tintAgentLogo.png +0 -0
  109. tiny_agent_os-0.0.1/static/images/tinyAgent_logo_v2.png +0 -0
  110. tiny_agent_os-0.0.1/tests/simple_tool_test.py +20 -0
  111. tiny_agent_os-0.0.1/tests/tiny_chain_tooling.py +27 -0
@@ -0,0 +1,36 @@
1
+ ##########################################################
2
+ # Aider Configuration
3
+ ##########################################################
4
+
5
+ # this is just an example aider configs are highly configurable please take the time to learn this
6
+ # Model settings
7
+ model: openrouter/deepseek/deepseek-chat
8
+ timeout: 120
9
+
10
+ # API settings/Same as openrouter
11
+ env-file: .env
12
+
13
+ # Cache settings
14
+ cache-prompts: True
15
+ cache-keepalive-pings: 2
16
+
17
+ # History Files
18
+ input-history-file: .aider.input.history
19
+ chat-history-file: .aider.chat.history.md
20
+ restore-chat-history: false
21
+ llm-history-file: .aider.llm.history
22
+
23
+ # Output settings
24
+ dark-mode: True
25
+
26
+ # Git settings
27
+ gitignore: true
28
+ auto-commits: true
29
+ dirty-commits: true
30
+
31
+ # Model aliases
32
+ alias:
33
+ - "c:openrouter/anthropic/claude-3.5-sonnet"
34
+ - "d:openrouter/deepseek/deepseek-chat"
35
+
36
+
@@ -0,0 +1,9 @@
1
+ # API Keys - Replace with your actual keys
2
+ OPENROUTER_API_KEY=your_openrouter_key_here
3
+ BRAVE=your_brave_key_here
4
+
5
+ TINYAGENT_PROXY_USERNAME=proxyuser
6
+ TINYAGENT_PROXY_PASSWORD=proxyuser_pw
7
+ TINYAGENT_PROXY_COUNTRY=US
8
+
9
+
@@ -0,0 +1,122 @@
1
+ # Environment and configuration
2
+ .pypirc
3
+ .aider*
4
+ .env
5
+ .env.*
6
+ .conf
7
+ config.local.yml
8
+ api-key
9
+ openrouter=*
10
+ *.pem
11
+ *.key
12
+ secrets/
13
+
14
+ # Project specific
15
+ tinyAgent_output/
16
+ downloads/
17
+ **/node_modules/
18
+ EVAL/
19
+ uv.lock
20
+
21
+ # Python
22
+ __pycache__/
23
+ *.py[cod]
24
+ *$py.class
25
+ *.so
26
+ .Python
27
+ env/
28
+ build/
29
+ develop-eggs/
30
+ dist/
31
+ downloads/
32
+ eggs/
33
+ .eggs/
34
+ lib/
35
+ lib64/
36
+ parts/
37
+ sdist/
38
+ var/
39
+ *.egg-info/
40
+ .installed.cfg
41
+ *.egg
42
+ .pytest_cache/
43
+ pytest_cache/
44
+ .coverage.*
45
+ coverage.*
46
+ output/
47
+
48
+ # Virtual Environment
49
+ venv/
50
+ ENV/
51
+ env.bak/
52
+ venv.bak/
53
+ .venv/
54
+ virtualenv/
55
+ .python-version
56
+
57
+ # IDEs and editors
58
+ .idea/
59
+ .vscode/
60
+ *.swp
61
+ *.swo
62
+ *~
63
+ .DS_Store
64
+ .project
65
+ .classpath
66
+ .c9/
67
+ *.launch
68
+ .settings/
69
+ *.sublime-workspace
70
+ *.sublime-project
71
+
72
+ # Visual artifacts and UI
73
+ node_modules/
74
+ *.log
75
+ logs/
76
+ *.sqlite
77
+ *.db
78
+ *.out
79
+ .cache/
80
+ tmp/
81
+ temp/
82
+ .tmp/
83
+
84
+ # Jupyter Notebook
85
+ .ipynb_checkpoints
86
+
87
+ # Testing
88
+ .coverage
89
+ htmlcov/
90
+ .tox/
91
+ .nox/
92
+ .hypothesis/
93
+ .pytest_cache/
94
+ orgDeploy.sh
95
+
96
+ # Compiled files
97
+ *.com
98
+ *.class
99
+ *.dll
100
+ *.exe
101
+ *.o
102
+ *.a
103
+ *.dylib
104
+
105
+ # Package files
106
+ *.7z
107
+ *.dmg
108
+ *.gz
109
+ *.iso
110
+ *.jar
111
+ *.rar
112
+ *.tar
113
+ *.zip
114
+
115
+ # OS generated files
116
+ Thumbs.db
117
+ ehthumbs.db
118
+ Desktop.ini
119
+
120
+ output/research_results/*.json
121
+
122
+
@@ -0,0 +1,53 @@
1
+ # tinyAgent Business Source License 1.1
2
+
3
+ License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
4
+ "Business Source License" is a trademark of MariaDB Corporation Ab.
5
+ Adapted for tinyAgent by Alchemist Studios.
6
+
7
+ ---
8
+
9
+ ## Terms
10
+
11
+ The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, below, permitting limited production use.
12
+
13
+ Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
14
+
15
+ If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
16
+
17
+ All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work, and the Change Date may vary for each version of the Licensed Work released by Licensor.
18
+
19
+ You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
20
+
21
+ Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
22
+
23
+ This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License).
24
+
25
+ THE LICENSED WORK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE LICENSOR BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION WITH THE LICENSED WORK OR THE USE OR OTHER DEALINGS IN THE LICENSED WORK.
26
+
27
+ ---
28
+
29
+ ## Additional Use Grant
30
+
31
+ You may make production use of the Licensed Work, provided such use does not include offering the Licensed Work to third parties on a hosted or embedded basis that is competitive with the Licensor's products.
32
+
33
+ ---
34
+
35
+ ## Change License
36
+
37
+ MIT License
38
+
39
+ ---
40
+
41
+ ## Change Date
42
+
43
+ No Change Date - License does not expire.
44
+
45
+ ---
46
+
47
+ ## Usage Limitation
48
+
49
+ - **Free** for individuals and businesses with annual revenue below $1 million USD.
50
+ - **Paid license required** for businesses with annual revenue exceeding $1 million USD.
51
+ - For commercial licensing inquiries, contact: [admin@alchemiststudios.ai](mailto:admin@alchemiststudios.ai).
52
+
53
+ ---
@@ -0,0 +1,4 @@
1
+ recursive-include src/tinyagent/prompts *.md
2
+ recursive-include src/tinyagent/prompts/system *.md
3
+ recursive-include src/tinyagent/prompts/tools *.md
4
+ recursive-include src/tinyagent/prompts/workflows *.md
@@ -0,0 +1,377 @@
1
+ Metadata-Version: 2.4
2
+ Name: tiny_agent_os
3
+ Version: 0.0.1
4
+ Summary: A streamlined framework for building powerful LLM-powered agents that can solve complex tasks through tool execution, orchestration, and dynamic capability creation.
5
+ Author-email: "(x) @tunahorse21" <info@alchemiststudios.ai>
6
+ License-Expression: BUSL-1.1
7
+ Project-URL: Homepage, https://github.com/alchemiststudiosai/tinyAgent
8
+ Project-URL: Bug Tracker, https://github.com/alchemiststudiosai/tinyAgent/issues
9
+ Project-URL: Documentation, https://github.com/alchemiststudiosai/tinyAgent/blob/main/README.md
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+ Requires-Dist: python-dotenv>=1.0.0
17
+ Requires-Dist: requests>=2.31.0
18
+ Requires-Dist: openai>=1.0.0
19
+ Requires-Dist: pyyaml>=6.0.1
20
+ Requires-Dist: jinja2>=3.1.2
21
+ Requires-Dist: click>=8.1.6
22
+ Requires-Dist: rich>=13.7.1
23
+ Requires-Dist: jsonschema>=4.10.3
24
+ Requires-Dist: typing-extensions>=4.10.0
25
+ Requires-Dist: colorama>=0.4.6
26
+ Requires-Dist: regex>=2023.0.0
27
+ Requires-Dist: beautifulsoup4>=4.12.0
28
+ Requires-Dist: aiohttp>=3.8.0
29
+ Dynamic: license-file
30
+
31
+ ---
32
+
33
+ # tinyAgent 🤖
34
+
35
+ ![tinyAgent Logo](static/images/tinyAgent_logo_v2.png)
36
+
37
+ ```
38
+ __ .__ _____ __
39
+ _/ |_|__| ____ ___.__. / _ \ ____ ____ _____/ |_
40
+ \ __\ |/ < | |/ /_\ \ / ___\_/ __ \ / \ __\
41
+ | | | | | \___ / | \/ /_/ > ___/| | \ |
42
+ |__| |__|___| / ____\____|__ /\___ / \___ >___| /__|
43
+ \/\/ \//_____/ \/ \/
44
+ ```
45
+
46
+ **Made by (x) [@tunahorse21](https://x.com/tunahorse21) | A product of [alchemiststudios.ai](https://alchemiststudios.ai)**
47
+
48
+ ---
49
+
50
+ ## Heads Up
51
+
52
+ tinyAgent is in **BETA** until V1. It's working but still evolving! I can't guarantee it's 100% bug-free, but I'm actively improving it whenever I can between my day job and business.
53
+ Found something that could be better? Show off your skills and open an issue with a fix: I'd genuinely appreciate it!
54
+
55
+ ---
56
+
57
+ ## Overview
58
+
59
+ tinyAgent is a streamlined framework for building powerful, LLM-powered agents that solve complex tasks through tool execution, orchestration, and dynamic capability creation. Convert any Python function into a useful tool and then into an agent with minimal configuration, unlocking a world of scalable, modular possibilities.
60
+
61
+ ---
62
+
63
+ ## Installation
64
+
65
+ ### Via pip (Recommended)
66
+
67
+ ```bash
68
+ pip install tiny_agent_os
69
+ ```
70
+
71
+ ---
72
+
73
+ ## Post-Installation Configuration for Pip Users
74
+
75
+ After installing via `pip`, you'll need to provide your own configuration files. For convenience, you can download the defaults directly:
76
+
77
+ ---
78
+
79
+ ### Download the Configuration File (`config.yml`)
80
+
81
+ **Using `wget`:**
82
+
83
+ ```bash
84
+ wget https://raw.githubusercontent.com/alchemiststudiosDOTai/tinyAgent/v0.65/config.yml
85
+ ```
86
+
87
+ ---
88
+
89
+ ### Download the Environment File (`.env`)
90
+
91
+ Download the example environment file and rename it to `.env`:
92
+
93
+ **Using `wget`:**
94
+
95
+ ```bash
96
+ wget https://raw.githubusercontent.com/alchemiststudiosDOTai/tinyAgent/v0.65/.envexample -O .env
97
+ ```
98
+
99
+ > **Note:** Be sure to edit the `.env` file with your actual API keys and any other required variables.
100
+
101
+ ---
102
+
103
+ ### Cloning for Development
104
+
105
+ ```bash
106
+ git clone https://github.com/alchemiststudiosDOTai/tinyAgent.git
107
+ cd tinyAgent
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Post-Installation Configuration
113
+
114
+ After installing (either via pip or from source), remember to configure your environment and `.env` files with relevant API keys from https://openrouter.ai
115
+
116
+ Both the config.yml and env work out of the box with a openrouter API, you can use any openai API, and the config has an example of a local LLM.
117
+ The /documentation folder has more details and is being updated.
118
+
119
+ ---
120
+
121
+ ## Tools and the `@tool` Decorator
122
+
123
+ In tinyAgent, **any Python function** can be transformed into a usable "tool" by simply decorating it with `@tool`. This makes it discoverable by your agents, allowing them to execute that function in response to natural-language queries.
124
+
125
+ ### Example
126
+
127
+ ```python
128
+ from tinyagent.decorators import tool
129
+
130
+ @tool
131
+ def greet_person(name: str) -> str:
132
+ """Return a friendly greeting."""
133
+ return f"Hello, {name}!"
134
+ ```
135
+
136
+ That's it! Once decorated, `greet_person` can be included in an agent's list of tools, letting your LLM-driven agent call it as needed.
137
+
138
+ ### Example – `calculate_sum` Tool
139
+
140
+ Turn a plain Python function into a natural-language skill with `@tool` and `tiny_agent`.
141
+
142
+ ```python
143
+ from tinyagent.decorators import tool
144
+ from tinyagent.agent import tiny_agent
145
+
146
+ @tool
147
+ def calculate_sum(a: int, b: int) -> int:
148
+ """Return the sum of two integers."""
149
+ return a + b
150
+
151
+ if __name__ == "__main__":
152
+ agent = tiny_agent(tools=[calculate_sum])
153
+ query = "calculate the sum of 5 and 3"
154
+ result = agent.run(query, expected_type=int)
155
+ print(f"Query: '{query}' -> Result: {result}")
156
+ ```
157
+
158
+ Console output:
159
+
160
+ ```
161
+ Validating args for tool: calculate_sum
162
+ Arguments provided: {'a': 5, 'b': 3}
163
+ Query: 'calculate the sum of 5 and 3' -> Result: 8
164
+ ```
165
+
166
+ ---
167
+
168
+ ## Philosophy
169
+
170
+ tinyAgent is built on two core ideas:
171
+
172
+ ### 1. Functions as Agents
173
+
174
+ Any Python function can be turned into a tool—and then seamlessly integrated into an agent. This approach makes extending and innovating simple.
175
+
176
+ ```mermaid
177
+ flowchart LR
178
+ A["Python Function"] --> B["Tool"]
179
+ B --> C["Agent"]
180
+ C --> D["Result"]
181
+ ```
182
+
183
+ ![Function to Agent Flow](static/images/func_agent.png)
184
+
185
+ ```python
186
+ #!/usr/bin/env python3
187
+ """
188
+ Example: Functions as Agents
189
+ """
190
+ from tinyagent.decorators import tool
191
+ from tinyagent.agent import tiny_agent
192
+
193
+ @tool
194
+ def calculate_sum(a: int, b: int) -> int:
195
+ """Calculate the sum of two integers."""
196
+ return a + b
197
+
198
+
199
+ def main():
200
+ # Create an agent with the calculate_sum tool
201
+ agent = tiny_agent(tools=[calculate_sum])
202
+ query = "calculate the sum of 5 and 3"
203
+ result = agent.run(query, expected_type=int)
204
+ print(f"Query: '{query}' -> Result: {result}")
205
+
206
+
207
+ if __name__ == "__main__":
208
+ main()
209
+ ```
210
+
211
+ ### 2. tiny_chain Orchesration
212
+
213
+ - IN BETA
214
+
215
+ tiny_chain is the main engine of tinyAgent's orchestration. It lets your agent solve complex tasks by chaining together multiple tools, using an LLM-powered "triage agent" to plan the best sequence. If the plan fails, tiny_chain falls back to running all tools in sequence, ensuring robustness and reliability.
216
+
217
+ ```mermaid
218
+ flowchart LR
219
+ A["User Query"] --> B["Triage Agent"]
220
+ B --> C["Tool Planning"]
221
+ C --> D["Tool Execution"]
222
+ D --> E["Search"] --> F["Browser"] --> G["Summarize"]
223
+ G --> H["Final Result"]
224
+
225
+ style B fill:#f9f,stroke:#333,stroke-width:2px
226
+ style E fill:#bbf,stroke:#333,stroke-width:2px
227
+ style F fill:#bbf,stroke:#333,stroke-width:2px
228
+ style G fill:#bbf,stroke:#333,stroke-width:2px
229
+ ```
230
+
231
+ - **Simple:** You describe your task in natural language. tiny_chain figures out which tools to use and in what order.
232
+ - **Smart:** The triage agent (an LLM) analyzes your query and suggests a plan—sometimes a single tool, sometimes a multi-step chain.
233
+ - **Robust:** If the triage agent can't make a good plan, tiny_chain just tries all tools, so you always get an answer.
234
+ - **Extensible:** Add new tools or improve the triage agent to handle more complex workflows.
235
+
236
+ **How it works (technical overview):**
237
+
238
+ - When you submit a task, tiny_chain asks the triage agent for a plan (JSON: single tool or sequence).
239
+ - If the plan is valid, tiny_chain executes the tools in order, passing results between them.
240
+ - If the plan is invalid or fails, tiny_chain runs all tools as a fallback.
241
+ - All errors are caught and logged, so you always get feedback.
242
+
243
+ ### tiny_chain Example – "Tariff Research Tool"
244
+
245
+ Use this snippet (or drop-in file) anywhere in your docs to show **exactly how tiny_chain works** end-to-end.
246
+
247
+ ```python
248
+ #!/usr/bin/env python3
249
+ """
250
+ tiny_chain example: automatically find and summarise U.S. import-tariff data
251
+ """
252
+ from tinyagent.factory.tiny_chain import tiny_chain
253
+ from tinyagent.tools.duckduckgo_search import get_tool as search_tool
254
+ from tinyagent.tools.custom_text_browser import get_tool as browser_tool
255
+ from tinyagent.decorators import tool
256
+ from tinyagent.agent import get_llm
257
+
258
+ @tool(name="summarize", description="Summarize input text with the LLM")
259
+ def summarize(text: str) -> str:
260
+ prompt = f"Summarize the following text:\n\n{text}\n\nSummary:"
261
+ return get_llm()(prompt).strip()
262
+
263
+ # 1 – build the chain
264
+ chain = tiny_chain.get_instance(
265
+ tools=[search_tool(), browser_tool(), summarize._tool]
266
+ )
267
+
268
+ # 2 – submit any natural-language task
269
+ task_id = chain.submit_task(
270
+ "Find current US import tariffs and visit official trade websites for details"
271
+ )
272
+
273
+ # 3 – get structured results
274
+ print(chain.get_task_status(task_id).result)
275
+ ```
276
+
277
+ **What it demonstrates**
278
+
279
+ | tiny_chain feature | Visible in run |
280
+ | ----------------------------------------- | -------------------------------------------------- |
281
+ | 🔗 Automatic tool planning (triage agent) | Picks _search → browser → summarize_ |
282
+ | 🛠 Pluggable tools | Search + browser + summarize tools in sequence |
283
+ | 📝 Structured trace | `steps`, `tools_used`, errors if any |
284
+ | 🤖 LLM-powered step | `summarize` converts page content → concise answer |
285
+
286
+ Copy-paste, run, and you have a minimal yet complete example of tiny_chain orchestrating multiple tools to solve a real research task.
287
+
288
+ ### Key links
289
+
290
+ - **Harmonized Tariff Schedule (USITC)**
291
+ <https://hts.usitc.gov/>
292
+
293
+ - **FTA Tariff Tool (International Trade Administration)**
294
+ <https://www.trade.gov/fta-tariff-tool-home>
295
+
296
+ - **CBP – Determining Duty Rates**
297
+ <https://www.cbp.gov/trade/programs-administration/determining-duty-rates>
298
+
299
+ ### Console Output
300
+
301
+ ```text
302
+ ============================================================
303
+ Tariff Research Tool
304
+ ============================================================
305
+
306
+ Researching: 'Find current US import tariffs and use the browser to visit official trade websites to get details'
307
+ ------------------------------------------------------------
308
+
309
+ Tool Chain Steps:
310
+
311
+ === Step 1 ===
312
+ Tool: search
313
+ Top hit → Harmonized Tariff Schedule (hts.usitc.gov)
314
+
315
+ === Step 2 ===
316
+ Tool: browser
317
+ Visited title → Harmonized Tariff Schedule
318
+
319
+ === Step 3 ===
320
+ Tool: summarize
321
+ Result →
322
+ To find current US import tariffs, consult the **Harmonized Tariff Schedule (HTS)**
323
+ on the USITC website.
324
+ For Free‑Trade Agreement rates, use the **FTA Tariff Tool** on trade.gov.
325
+ CBP also provides duty‑rate guidance.
326
+
327
+ ------------------------------------------------------------
328
+ Tools used: search → browser → summarize
329
+ ```
330
+
331
+ **What it demonstrates**
332
+
333
+ | tiny_chain feature | Visible in run |
334
+ | ----------------------------------------- | -------------------------------------------------- |
335
+ | 🔗 Automatic tool planning (triage agent) | Picks _search → browser → summarize_ |
336
+ | 🛠 Pluggable tools | Search + browser + summarize tools in sequence |
337
+ | 📝 Structured trace | `steps`, `tools_used`, errors if any |
338
+ | 🤖 LLM-powered step | `summarize` converts page content → concise answer |
339
+
340
+ Copy-paste, run, and you have a minimal yet complete example of tiny_chain orchestrating multiple tools to solve a real research task.
341
+
342
+ ---
343
+
344
+ ## Features
345
+
346
+ - **Modular Design:** Easily convert any function into a tool.
347
+ - **Flexible Agent Options:** Use the simple orchestrator or advanced `AgentFactory`.
348
+ - **Robust Error Handling:** Improved debugging with custom exceptions.
349
+ - **Structured Output:** Enforce JSON formats for consistent outputs.
350
+
351
+ ---
352
+
353
+ ## Acknowledgments & Inspirations
354
+
355
+ - **my wife**
356
+ - [HuggingFace SmoLAgents](https://github.com/huggingface/smolagents)
357
+ - [Aider-AI](https://github.com/Aider-AI/aider)
358
+ - And many other open-source contributors!
359
+
360
+ ---
361
+
362
+ ## Contact
363
+
364
+ For questions, suggestions, or business inquiries:
365
+
366
+ - **Email**: [info@alchemiststudios.ai](mailto:info@alchemiststudios.ai)
367
+ - **X**: [@tunahorse21](https://x.com/tunahorse21)
368
+ - **Website**: [alchemiststudios.ai](https://alchemiststudios.ai)
369
+
370
+ ---
371
+
372
+ ## License
373
+
374
+ **Business Source License 1.1 (BSL)**
375
+ This project is licensed under the Business Source License 1.1. It is **free for individuals and small businesses** (with annual revenues under $1M).
376
+ For commercial use by larger businesses, an enterprise license is required.
377
+ For licensing or usage inquiries, please contact: [info@alchemiststudios.ai](mailto:info@alchemiststudios.ai)