tinyflow-llm 0.1.0__py3-none-any.whl

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. tinyflow/__init__.py +53 -0
  2. tinyflow/config/helpers.py +62 -0
  3. tinyflow/config/settings.py +80 -0
  4. tinyflow/core/__init__.py +31 -0
  5. tinyflow/core/agent.py +457 -0
  6. tinyflow/core/exceptions.py +63 -0
  7. tinyflow/core/logger.py +13 -0
  8. tinyflow/core/message.py +6 -0
  9. tinyflow/core/protocol.py +81 -0
  10. tinyflow/core/tools.py +200 -0
  11. tinyflow/core/types.py +252 -0
  12. tinyflow/embeddings/__init__.py +4 -0
  13. tinyflow/embeddings/base.py +32 -0
  14. tinyflow/embeddings/factory.py +140 -0
  15. tinyflow/embeddings/local_embedding.py +65 -0
  16. tinyflow/embeddings/openai_embedding.py +70 -0
  17. tinyflow/memory/__init__.py +5 -0
  18. tinyflow/memory/base.py +16 -0
  19. tinyflow/memory/simple.py +34 -0
  20. tinyflow/memory/vector.py +26 -0
  21. tinyflow/providers/anthropic_llm.py +132 -0
  22. tinyflow/providers/base/factory.py +81 -0
  23. tinyflow/providers/base/llm.py +37 -0
  24. tinyflow/providers/gemini_llm.py +130 -0
  25. tinyflow/providers/openai_llm.py +198 -0
  26. tinyflow/tools/builtin/__init__.py +36 -0
  27. tinyflow/tools/builtin/code_execution.py +143 -0
  28. tinyflow/tools/builtin/search.py +145 -0
  29. tinyflow/tools/builtin/web_reader.py +88 -0
  30. tinyflow/vector/__init__.py +4 -0
  31. tinyflow/vector/base.py +65 -0
  32. tinyflow/vector/chroma_db.py +134 -0
  33. tinyflow/vector/factory.py +84 -0
  34. tinyflow/vector/qdrant_db.py +198 -0
  35. tinyflow/workflow/__init__.py +21 -0
  36. tinyflow/workflow/executor.py +272 -0
  37. tinyflow/workflow/hooks.py +191 -0
  38. tinyflow/workflow/state.py +148 -0
  39. tinyflow/workflow/step.py +74 -0
  40. tinyflow_llm-0.1.0.dist-info/METADATA +243 -0
  41. tinyflow_llm-0.1.0.dist-info/RECORD +43 -0
  42. tinyflow_llm-0.1.0.dist-info/WHEEL +4 -0
  43. tinyflow_llm-0.1.0.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,243 @@
1
+ Metadata-Version: 2.4
2
+ Name: tinyflow-llm
3
+ Version: 0.1.0
4
+ Summary: A lightweight, extensible, and provider-agnostic Python framework for building LLM agents.
5
+ Project-URL: Homepage, https://github.com/your-username/tinyflow
6
+ Project-URL: Repository, https://github.com/your-username/tinyflow
7
+ Project-URL: Issues, https://github.com/your-username/tinyflow/issues
8
+ Author-email: Your Name <your.email@example.com>
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.12
18
+ Requires-Dist: anthropic>=0.78.0
19
+ Requires-Dist: google-genai>=1.62.0
20
+ Requires-Dist: google-generativeai>=0.8.6
21
+ Requires-Dist: httpx>=0.28.1
22
+ Requires-Dist: openai>=2.16.0
23
+ Requires-Dist: pydantic-settings>=2.12.0
24
+ Requires-Dist: pydantic>=2.12.5
25
+ Requires-Dist: python-dotenv>=1.2.1
26
+ Requires-Dist: rich>=14.3.2
27
+ Requires-Dist: tavily>=1.1.0
28
+ Requires-Dist: tenacity>=9.1.3
29
+ Provides-Extra: dev
30
+ Requires-Dist: basedpyright>=1.37.4; extra == 'dev'
31
+ Requires-Dist: black>=26.1.0; extra == 'dev'
32
+ Requires-Dist: pyright>=1.1.408; extra == 'dev'
33
+ Requires-Dist: pytest-asyncio>=1.3.0; extra == 'dev'
34
+ Requires-Dist: pytest>=9.0.2; extra == 'dev'
35
+ Requires-Dist: ruff>=0.15.0; extra == 'dev'
36
+ Provides-Extra: local
37
+ Requires-Dist: onnxruntime<1.24.1; extra == 'local'
38
+ Requires-Dist: sentence-transformers<3.0,>=2.2.0; extra == 'local'
39
+ Requires-Dist: torch==2.2.2; extra == 'local'
40
+ Provides-Extra: vector
41
+ Requires-Dist: chromadb>=1.4.1; extra == 'vector'
42
+ Requires-Dist: qdrant-client>=1.16.2; extra == 'vector'
43
+ Description-Content-Type: text/markdown
44
+
45
+ # TinyFlow
46
+
47
+ **TinyFlow** is a lightweight, extensible, and provider-agnostic Python framework for building LLM agents. It provides a clean abstraction layer over major LLM providers (OpenAI, Anthropic, Gemini), embedding models, and vector databases, enabling you to build complex agentic workflows with ease.
48
+
49
+ ## ๐Ÿš€ Key Features
50
+
51
+ - **Provider Agnostic**: Switch seamlessly between OpenAI, Anthropic, and Google Gemini models using a unified `LLMFactory`.
52
+ - **Agentic Workflow**: Built-in "Thinking -> Acting -> Observing" loop for autonomous task execution.
53
+ - **Tool Support**: Easy-to-use `@tool` decorator to give your agents capabilities (web search, code execution, etc.).
54
+ - **Memory & RAG**: Integrated Vector Database support (ChromaDB, Qdrant) and Embedding abstraction (OpenAI, SentenceTransformers).
55
+ - **Unified Configuration**: flexible configuration system supporting parameters, environment variables, and settings files with clear precedence.
56
+ - **Streaming UI**: Rich streaming support for building interactive chat interfaces, including reasoning steps and tool execution visibility.
57
+ - **Modern Stack**: Built with Python 3.12+, Pydantic, Asyncio, and managed with `uv`.
58
+
59
+ ## ๐Ÿ“ฆ Installation
60
+
61
+ You can install TinyFlow using `pip` or `uv`.
62
+
63
+ ### Using pip
64
+
65
+ ```bash
66
+ pip install tinyflow-llm
67
+ ```
68
+
69
+ ### Using uv (Recommended)
70
+
71
+ ```bash
72
+ uv add tinyflow-llm
73
+ ```
74
+
75
+ ### Installation with Extras
76
+
77
+ TinyFlow supports optional dependencies for specific features:
78
+
79
+ - **Local Embeddings**: `pip install "tinyflow-llm[local]"`
80
+ - **Vector Databases**: `pip install "tinyflow-llm[vector]"` (includes ChromaDB and Qdrant)
81
+
82
+ ## โš™๏ธ Configuration
83
+
84
+ TinyFlow uses a unified configuration system. You can configure providers via:
85
+
86
+ 1. **Explicit Parameters** (passed to Factory `create` methods) - _Highest Priority_
87
+ 2. **Environment Variables** - _Medium Priority_
88
+ 3. **Settings / Defaults** - _Lowest Priority_
89
+
90
+ ### Common Environment Variables
91
+
92
+ | Category | Variable | Description |
93
+ | -------------- | -------------------- | ------------------------------------------------ |
94
+ | **LLM** | `LLM_PROVIDER` | `openai`, `anthropic`, or `gemini` |
95
+ | | `LLM_API_KEY` | API Key for the selected provider |
96
+ | | `LLM_MODEL` | Model name (e.g., `gpt-4o`, `claude-3-5-sonnet`) |
97
+ | | `LLM_BASE_URL` | Optional custom base URL (e.g., for proxies) |
98
+ | **Embeddings** | `EMBEDDING_PROVIDER` | `openai`, `local`, or `sentence-transformers` |
99
+ | | `EMBEDDING_API_KEY` | API Key for embedding provider |
100
+ | | `EMBEDDING_MODEL` | Model name (e.g., `text-embedding-3-small`) |
101
+ | **Vector DB** | `VECTOR_DB_PROVIDER` | `chroma` or `qdrant` |
102
+ | | `VECTOR_DB_PATH` | Path for local ChromaDB persistence |
103
+ | | `VECTOR_DB_URL` | URL for remote Vector DB (e.g., Qdrant Cloud) |
104
+ | | `VECTOR_DB_API_KEY` | API Key for remote Vector DB |
105
+
106
+ ## ๐Ÿ’ก Usage
107
+
108
+ ### 1. Basic LLM Usage
109
+
110
+ Use the `LLMFactory` to create a provider instance. It automatically handles configuration.
111
+
112
+ ```python
113
+ import asyncio
114
+ from tinyflow.providers.base.factory import LLMFactory
115
+ from tinyflow.core.types import Message
116
+
117
+ async def main():
118
+ # Automatically loads config from env vars
119
+ llm = LLMFactory.create()
120
+
121
+ # Or specify explicitly
122
+ # llm = LLMFactory.create(provider="anthropic", model="claude-3-opus-20240229")
123
+
124
+ messages = [
125
+ Message(role="system", content="You are a helpful assistant."),
126
+ Message(role="user", content="Explain quantum computing in one sentence.")
127
+ ]
128
+
129
+ response = await llm.generate(messages)
130
+ print(response.content)
131
+
132
+ if __name__ == "__main__":
133
+ asyncio.run(main())
134
+ ```
135
+
136
+ ### 2. Building an Agent with Tools
137
+
138
+ Create an `Agent` equipped with custom tools.
139
+
140
+ ```python
141
+ import asyncio
142
+ from tinyflow.core.agent import Agent
143
+ from tinyflow.providers.base.factory import LLMFactory
144
+ from tinyflow.core.tools import tool
145
+
146
+ # Define a tool
147
+ @tool
148
+ def get_weather(location: str, unit: str = "celsius") -> str:
149
+ """Get the current weather for a location."""
150
+ # In a real app, call a weather API here
151
+ return f"The weather in {location} is 25ยฐ{unit.upper()} and sunny."
152
+
153
+ async def main():
154
+ # 1. Initialize LLM
155
+ llm = LLMFactory.create()
156
+
157
+ # 2. Create Agent with tools
158
+ agent = Agent(
159
+ llm=llm,
160
+ tools=[get_weather],
161
+ system_prompt="You are a helpful assistant with access to weather tools."
162
+ )
163
+
164
+ # 3. Run Agent
165
+ response = await agent.run("What's the weather like in Paris?")
166
+ print(response)
167
+
168
+ if __name__ == "__main__":
169
+ asyncio.run(main())
170
+ ```
171
+
172
+ ### 3. Using Vector Memory
173
+
174
+ Integrate RAG (Retrieval-Augmented Generation) capabilities.
175
+
176
+ ```python
177
+ from tinyflow.vector.factory import VectorDBFactory
178
+ from tinyflow.embeddings.factory import EmbeddingFactory
179
+ from tinyflow.memory.vector import VectorMemory
180
+
181
+ # Initialize components
182
+ embedding_model = EmbeddingFactory.create()
183
+ vector_db = VectorDBFactory.create()
184
+
185
+ # Create memory interface
186
+ memory = VectorMemory(
187
+ vector_db=vector_db,
188
+ embedding_model=embedding_model
189
+ )
190
+
191
+ # Use in Agent
192
+ agent = Agent(
193
+ llm=llm,
194
+ memory=memory,
195
+ system_prompt="Use your memory to answer questions."
196
+ )
197
+ ```
198
+
199
+ ## ๐Ÿ—๏ธ Project Structure
200
+
201
+ ```
202
+ tinyflow/
203
+ โ”œโ”€โ”€ tinyflow/
204
+ โ”‚ โ”œโ”€โ”€ config/ # Configuration and helper utilities
205
+ โ”‚ โ”œโ”€โ”€ core/ # Core abstractions (Agent, Tools, Types)
206
+ โ”‚ โ”œโ”€โ”€ providers/ # LLM Provider implementations (OpenAI, Anthropic, Gemini)
207
+ โ”‚ โ”œโ”€โ”€ embeddings/ # Embedding models (OpenAI, Local)
208
+ โ”‚ โ”œโ”€โ”€ vector/ # Vector Database adapters (Chroma, Qdrant)
209
+ โ”‚ โ””โ”€โ”€ memory/ # Memory implementations
210
+ โ”œโ”€โ”€ tests/ # Unit and integration tests
211
+ โ”œโ”€โ”€ main.py # Entry point example
212
+ โ””โ”€โ”€ pyproject.toml # Project dependencies and config
213
+ ```
214
+
215
+ ## ๐Ÿงช Development
216
+
217
+ ### Running Tests
218
+
219
+ TinyFlow uses `pytest` for testing.
220
+
221
+ ```bash
222
+ # Run all tests
223
+ uv run pytest
224
+
225
+ # Run specific test file
226
+ uv run pytest tests/test_factories.py -v
227
+ ```
228
+
229
+ ### Code Style
230
+
231
+ The project uses `ruff` for linting and formatting.
232
+
233
+ ```bash
234
+ # Lint
235
+ uv run ruff check .
236
+
237
+ # Format
238
+ uv run ruff format .
239
+ ```
240
+
241
+ ## ๐Ÿ“„ License
242
+
243
+ [MIT License](LICENSE)
@@ -0,0 +1,43 @@
1
+ tinyflow/__init__.py,sha256=JjvZNmhlebmCdwcaKEZUKU_hivWFFTXQowvZaTqLEFo,1315
2
+ tinyflow/config/helpers.py,sha256=Q9vGX6LrWqrORWsFgQVhpiCJ9Op0McrL7uglpetotjQ,2022
3
+ tinyflow/config/settings.py,sha256=VyVFhqMDYP1iglaJoAav2wuZjbn6qXlqt7g3EOdrh5U,2902
4
+ tinyflow/core/__init__.py,sha256=ppLaYPNv9NNNCbhn30HgsONF6i79reFyFHqvb9R5r7M,667
5
+ tinyflow/core/agent.py,sha256=XIOf1c69XrbAp3szSnLlOW4JX22S3nskIJGq5p9CxDI,18845
6
+ tinyflow/core/exceptions.py,sha256=ff_KYeCNlfCgBUXkTAZo2jipUvKur2boboImu5OzmMc,1469
7
+ tinyflow/core/logger.py,sha256=DaXcv7_0xJv7Af1YUQBuc9Y4w9y0nzCa6gyiWafuDlI,408
8
+ tinyflow/core/message.py,sha256=VvJFlV5dXk-cysGlFcIICltOanwzDb5dczOK7YZOcqY,241
9
+ tinyflow/core/protocol.py,sha256=6LHOZbdTMojIiQIlRZXNk2uI43s7EkMJktUYP1k76r0,3502
10
+ tinyflow/core/tools.py,sha256=JYk1IfmhXvuJDYqPNOkQUsR94JtREiW4vn5S9Yp6aPg,7434
11
+ tinyflow/core/types.py,sha256=oODX-N8OpyIdtJA0MxVbphLUGcct3oikfzDiAlb8fE8,7049
12
+ tinyflow/embeddings/__init__.py,sha256=OI_uoOZ_IloSsAPiqZBs3JE7q_Ei4TKQV_05uL5A4KE,77
13
+ tinyflow/embeddings/base.py,sha256=at7_uvr2GuZlXsCMKNieiBR6rh0YxUjtquHhWCkz5w4,643
14
+ tinyflow/embeddings/factory.py,sha256=tzGIkx0vHV-3BdAVNbTmQdm0LgyyodbGZV73h0BQoKA,5098
15
+ tinyflow/embeddings/local_embedding.py,sha256=xeQIl0UdeEFvWJFjdzihSRz5bqSmm8eB8EOk_2ZPmAA,2079
16
+ tinyflow/embeddings/openai_embedding.py,sha256=5Io3sz5wMlUEo1bRi_uy5HB5YT8lpza46f-FUb6sjjA,2202
17
+ tinyflow/memory/__init__.py,sha256=PtT0bM8wF4Jpoq7pIX0g27fbSI2AoMv6D3mn_3sM6Vk,153
18
+ tinyflow/memory/base.py,sha256=9IgmOjlQb06iY17l66pnAlIatEKvISJZQ8hQxvYl-vs,309
19
+ tinyflow/memory/simple.py,sha256=fTmI3qXtISQhS00rY6P8fbLIhSoxxs8VkTnT_MkhnNk,969
20
+ tinyflow/memory/vector.py,sha256=gReV9WeA9a64rogI5266g7BZ8jZIPDfs9Xupl7ZoAkA,756
21
+ tinyflow/providers/anthropic_llm.py,sha256=kzMxz7FljBCxZBIdke4FzPe4zSPDlgN3yXDUSjt2ARk,4153
22
+ tinyflow/providers/gemini_llm.py,sha256=1IJf97cN6xilyQmmJF5X_ojYnWVPUSBl6SrDs_1O7K8,4694
23
+ tinyflow/providers/openai_llm.py,sha256=WXD9eKzOmpAbuDFIdPRxYhRacP1lAR84IcSYTVMKCoI,7297
24
+ tinyflow/providers/base/factory.py,sha256=C-g826n3Vr5PPNxQNVSaQa01t0UENVvfV4POSI1o5M4,3022
25
+ tinyflow/providers/base/llm.py,sha256=TKOjsMl8iQFveW3dR0qfMfWDjmhMWx5nLpKZ1Gg84zI,1314
26
+ tinyflow/tools/builtin/__init__.py,sha256=UPAhiAW5VQHhx7NQ4v6Gbo8WqcW6Djrt723FUfsY4Qk,946
27
+ tinyflow/tools/builtin/code_execution.py,sha256=vhM602O0SGLSPt_w2sb7DHv4OhMFtSJskk07yP0dWks,4534
28
+ tinyflow/tools/builtin/search.py,sha256=0NhHcKB5ba252MWK3Xt6hEJuXQVPlG31wwKMSmMuIMM,4796
29
+ tinyflow/tools/builtin/web_reader.py,sha256=3A-ammXOf4MCcRLmeRVfewifubG55Sz3YfJ_TDmQNao,2777
30
+ tinyflow/vector/__init__.py,sha256=Vi8ViT7r8lR--vxVZ1IG2icHclKGg4Wdcfv3AQuBpAg,83
31
+ tinyflow/vector/base.py,sha256=R6zJgrOmTO3a6oh1c9-VC-7Yfe6mM5OMXli_bkMbV2o,1620
32
+ tinyflow/vector/chroma_db.py,sha256=N7UjEIIpVWaQ5w1RUrRZ1q2X7D-fsKTSrMG5y7i7Skw,4528
33
+ tinyflow/vector/factory.py,sha256=8MECybeXBZa_UfPdxV6hv5871quYiNL7NBMYVNsDhH0,2720
34
+ tinyflow/vector/qdrant_db.py,sha256=6OMElLG06H9zjhuLFTF7_2fGNYgaV0MgjWaZE_LIfY0,6190
35
+ tinyflow/workflow/__init__.py,sha256=h4v14_ebYxawVcPXQNiJQ_Tw6uq5EX-1O_IqbOk2vwc,457
36
+ tinyflow/workflow/executor.py,sha256=v4Sdj7751-cKaJBQ8A6tBkDMhM5IncIGACuxxY9GGV4,10516
37
+ tinyflow/workflow/hooks.py,sha256=xh06rCQZMBLvasHI2dKvbyjPPpSxYeTDn7q_1Ve2LAk,5773
38
+ tinyflow/workflow/state.py,sha256=WQK_jYTbZfo4jnT0U1LVgv9svUa2sqNXNcsvRuH8vqw,4822
39
+ tinyflow/workflow/step.py,sha256=J4DrMNQgUEjU0sFlDuPE6YdebXPmbmDmpuvTsaKlLwk,2574
40
+ tinyflow_llm-0.1.0.dist-info/METADATA,sha256=fHPuT60gj6_KX8Z4MMHHLjrJo2LJ5J8YRI-ojg8dtJs,8279
41
+ tinyflow_llm-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
42
+ tinyflow_llm-0.1.0.dist-info/licenses/LICENSE,sha256=v2spsd7N1pKFFh2G8wGP_45iwe5S0DYiJzG4im8Rupc,1066
43
+ tinyflow_llm-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.28.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Your Name
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.