flashlite 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 (41) hide show
  1. flashlite/__init__.py +169 -0
  2. flashlite/cache/__init__.py +14 -0
  3. flashlite/cache/base.py +194 -0
  4. flashlite/cache/disk.py +285 -0
  5. flashlite/cache/memory.py +157 -0
  6. flashlite/client.py +671 -0
  7. flashlite/config.py +154 -0
  8. flashlite/conversation/__init__.py +30 -0
  9. flashlite/conversation/context.py +319 -0
  10. flashlite/conversation/manager.py +385 -0
  11. flashlite/conversation/multi_agent.py +378 -0
  12. flashlite/core/__init__.py +13 -0
  13. flashlite/core/completion.py +145 -0
  14. flashlite/core/messages.py +130 -0
  15. flashlite/middleware/__init__.py +18 -0
  16. flashlite/middleware/base.py +90 -0
  17. flashlite/middleware/cache.py +121 -0
  18. flashlite/middleware/logging.py +159 -0
  19. flashlite/middleware/rate_limit.py +211 -0
  20. flashlite/middleware/retry.py +149 -0
  21. flashlite/observability/__init__.py +34 -0
  22. flashlite/observability/callbacks.py +155 -0
  23. flashlite/observability/inspect_compat.py +266 -0
  24. flashlite/observability/logging.py +293 -0
  25. flashlite/observability/metrics.py +221 -0
  26. flashlite/py.typed +0 -0
  27. flashlite/structured/__init__.py +31 -0
  28. flashlite/structured/outputs.py +189 -0
  29. flashlite/structured/schema.py +165 -0
  30. flashlite/templating/__init__.py +11 -0
  31. flashlite/templating/engine.py +217 -0
  32. flashlite/templating/filters.py +143 -0
  33. flashlite/templating/registry.py +165 -0
  34. flashlite/tools/__init__.py +74 -0
  35. flashlite/tools/definitions.py +382 -0
  36. flashlite/tools/execution.py +353 -0
  37. flashlite/types.py +233 -0
  38. flashlite-0.1.0.dist-info/METADATA +173 -0
  39. flashlite-0.1.0.dist-info/RECORD +41 -0
  40. flashlite-0.1.0.dist-info/WHEEL +4 -0
  41. flashlite-0.1.0.dist-info/licenses/LICENSE.md +21 -0
@@ -0,0 +1,173 @@
1
+ Metadata-Version: 2.4
2
+ Name: flashlite
3
+ Version: 0.1.0
4
+ Summary: Batteries-included wrapper for litellm with rate limiting, retries, templating, and more
5
+ Author-email: ndalton12 <niall.dalton12@gmail.com>
6
+ License-File: LICENSE.md
7
+ Requires-Python: >=3.13
8
+ Requires-Dist: jinja2>=3.1.0
9
+ Requires-Dist: litellm>=1.55.0
10
+ Requires-Dist: pydantic>=2.0
11
+ Requires-Dist: python-dotenv>=1.0.0
12
+ Requires-Dist: tenacity>=8.0.0
13
+ Provides-Extra: dev
14
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
15
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
16
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
17
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
18
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
19
+ Description-Content-Type: text/markdown
20
+
21
+ # Flashlite
22
+
23
+ A batteries-included wrapper for [litellm](https://github.com/BerriAI/litellm) designed for high-volume prompting workloads like evals, agentic loops, and social simulations.
24
+
25
+ ## Features
26
+
27
+ - **Rate Limiting** - Token bucket algorithm for RPM and TPM limits
28
+ - **Retries** - Exponential backoff with jitter via tenacity
29
+ - **Jinja Templating** - Prompt templates with custom filters
30
+ - **Caching** - In-memory LRU and SQLite disk caching
31
+ - **Structured Outputs** - Native Pydantic model parsing without instructor
32
+ - **Tool/Function Calling** - `@tool` decorator and execution loops
33
+ - **Multi-Turn Conversations** - Conversation management with branching
34
+ - **Cost Tracking** - Token counting and budget limits
35
+ - **Observability** - Structured logging and Inspect framework integration
36
+ - **Async-First** - Native async with sync wrappers
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ pip install flashlite
42
+ # or with uv
43
+ uv add flashlite
44
+ ```
45
+
46
+ ## Quick Start
47
+
48
+ ```python
49
+ from flashlite import Flashlite
50
+
51
+ # Create client (loads .env automatically)
52
+ client = Flashlite(default_model="gpt-4o")
53
+
54
+ # Simple completion
55
+ response = await client.complete(
56
+ messages="What is the capital of France?"
57
+ )
58
+ print(response.content)
59
+
60
+ # Sync version
61
+ response = client.complete_sync(messages="Hello!")
62
+ ```
63
+
64
+ ### Structured Outputs
65
+
66
+ ```python
67
+ from pydantic import BaseModel, Field
68
+ from flashlite import Flashlite
69
+
70
+ class Sentiment(BaseModel):
71
+ label: str = Field(description="positive, negative, or neutral")
72
+ confidence: float = Field(ge=0, le=1)
73
+
74
+ client = Flashlite(default_model="gpt-4o")
75
+
76
+ result: Sentiment = await client.complete(
77
+ messages="Analyze: 'I love this product!'",
78
+ response_model=Sentiment,
79
+ )
80
+ print(f"{result.label} ({result.confidence:.0%})")
81
+ ```
82
+
83
+ ### Tool/Function Calling
84
+
85
+ ```python
86
+ from flashlite import Flashlite, tool, run_tool_loop
87
+
88
+ @tool()
89
+ def get_weather(location: str) -> str:
90
+ """Get weather for a location."""
91
+ return f"Weather in {location}: 72°F, sunny"
92
+
93
+ client = Flashlite(default_model="gpt-4o")
94
+
95
+ result = await run_tool_loop(
96
+ client=client,
97
+ messages=[{"role": "user", "content": "What's the weather in NYC?"}],
98
+ tools=[get_weather],
99
+ )
100
+ print(result.content)
101
+ ```
102
+
103
+ ### Parallel Processing
104
+
105
+ ```python
106
+ # Process many requests with concurrency control
107
+ responses = await client.complete_many(
108
+ requests=[
109
+ {"messages": f"Summarize: {doc}"}
110
+ for doc in documents
111
+ ],
112
+ max_concurrency=10,
113
+ )
114
+ ```
115
+
116
+ ### Caching
117
+
118
+ ```python
119
+ from flashlite import Flashlite, MemoryCache, DiskCache
120
+
121
+ # In-memory caching
122
+ client = Flashlite(
123
+ cache=MemoryCache(max_size=1000),
124
+ default_model="gpt-4o",
125
+ )
126
+
127
+ # Or persistent disk cache
128
+ client = Flashlite(
129
+ cache=DiskCache("./cache.db"),
130
+ default_model="gpt-4o",
131
+ )
132
+ ```
133
+
134
+ ### Reasoning Models
135
+
136
+ ```python
137
+ from flashlite import Flashlite, thinking_enabled
138
+
139
+ client = Flashlite()
140
+
141
+ # OpenAI o1/o3
142
+ response = await client.complete(
143
+ model="o3",
144
+ messages="Solve this complex problem...",
145
+ reasoning_effort="high",
146
+ )
147
+
148
+ # Anthropic Claude extended thinking
149
+ response = await client.complete(
150
+ model="anthropic/claude-sonnet-4-5-20250929",
151
+ messages="Complex reasoning task...",
152
+ thinking=thinking_enabled(10000),
153
+ )
154
+ ```
155
+
156
+ ## Documentation
157
+
158
+ - [Quick Start Guide](QUICK_START.md) - Detailed examples for all features
159
+ - [Development Guide](DEV.md) - Setup and contributing
160
+ - [Implementation Plan](plan.md) - Architecture and roadmap
161
+
162
+ ## Requirements
163
+
164
+ - Python 3.13+
165
+ - litellm
166
+ - pydantic>=2.0
167
+ - jinja2
168
+ - tenacity
169
+ - python-dotenv
170
+
171
+ ## License
172
+
173
+ MIT
@@ -0,0 +1,41 @@
1
+ flashlite/__init__.py,sha256=RlXjsK7zvZXStMvfz4FGqBxTWHev9VkyHYy-35TuTuM,3585
2
+ flashlite/client.py,sha256=zQH_eLWZxnkX9acwI-y9c3uxeGybA-C0I9UPU6HrzvI,25081
3
+ flashlite/config.py,sha256=3RMEIAejBPlBG_VOgD8mpZKEDNZvK0k0cVv3vMM9kW8,4818
4
+ flashlite/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ flashlite/types.py,sha256=Odh18srphi8KhE8DSg9TW4nDCy_mNhFZowEjarirz3o,6392
6
+ flashlite/cache/__init__.py,sha256=T8O7oiZ0U181_tacJzfK6IGEAt1m3NdaIlBjq9wmB44,325
7
+ flashlite/cache/base.py,sha256=IaDAI4EzewhJe0quh2JQK9-BxQxGxUDwrsd9BCaHFFc,5663
8
+ flashlite/cache/disk.py,sha256=pGPI7eJW6RqVCQC4laTYhQr0iU-AkjA4aFFYt-wg8ls,8777
9
+ flashlite/cache/memory.py,sha256=_A4F7NTR9da2KDQW7fcKnUWrC-W_JpaYmb3d6rovX3w,4416
10
+ flashlite/conversation/__init__.py,sha256=zSgC4G697mx3T5bKn8WUEkSaSkMQQeHJsfyLdRUM30w,694
11
+ flashlite/conversation/context.py,sha256=NQMLi5_WiN1zDYaPZTO9uJG_dJ3JJiVmAFfGAPM4X6c,10164
12
+ flashlite/conversation/manager.py,sha256=dSQDgtzNt_6T8S1sHSAXKcS3DoBQ2vI9Ig1PZKaTh48,11644
13
+ flashlite/conversation/multi_agent.py,sha256=t1jZD1VS3NOcAJtjQTMtvjEZCVTlFGy3SOxE_jjAtuo,11591
14
+ flashlite/core/__init__.py,sha256=nWbMMPED_HsD62hkIYv45DDR6zX2_cDWCMPDTNfqSu4,315
15
+ flashlite/core/completion.py,sha256=NTtAJzJ3ba0N0xVs8lCN5htme0SWEMxYroGjI63crw4,3847
16
+ flashlite/core/messages.py,sha256=-EUtEjFjSNY1Lzfrynb9xtYw4FZRKnfFoYQqgsUcQZQ,3848
17
+ flashlite/middleware/__init__.py,sha256=T8Z4uSqjkuAcf5u5FuUBNfKyL5sqp4Iw4sov_xiU3fI,490
18
+ flashlite/middleware/base.py,sha256=LC_IL96jWWPdE0o_PBGPvSylmyLmob20LBVvGkfUS3g,2691
19
+ flashlite/middleware/cache.py,sha256=R1YwAZBg5YJGTiqgNWdkl7VSN1xpmqmupTSBQnpyH-s,4032
20
+ flashlite/middleware/logging.py,sha256=D3x8X1l1LN1Um_qOWuELyO8Fgo9WulFJTIx6s94Ure4,4919
21
+ flashlite/middleware/rate_limit.py,sha256=nf0-Ul0CGnX0VRKtxB2dfoplkBin3P2cMLrbks76lcg,7059
22
+ flashlite/middleware/retry.py,sha256=_3Lz9Gmes2sNk6rO10WamH6yrwJy8TQi-esIl8NIMag,4832
23
+ flashlite/observability/__init__.py,sha256=5896gbmuAY3qHZzcu9UwsrGd9Umq2AkaUrufX-72Epo,852
24
+ flashlite/observability/callbacks.py,sha256=yz1oZh7f7WVxvKmt7XyHbj4WDC2xnvM3SJiTSxfAkoQ,4897
25
+ flashlite/observability/inspect_compat.py,sha256=1bEowfjBdkvbo7nmWXYJMw9mRIfHSKaT2Cj9zBynRRA,7812
26
+ flashlite/observability/logging.py,sha256=UxBH2RN8rNcGZHYgC_QYiuEpaIRXEQFs1OjiKjxbuf0,9273
27
+ flashlite/observability/metrics.py,sha256=blRx5N3uN4ilnPpxBe7k_uDhYV3GmQWXoKPLVxnk8_s,7466
28
+ flashlite/structured/__init__.py,sha256=9k5bwkzFo_JD3WZ1Tm4iyZqoZ1A51EIINI8N1H2_2ew,750
29
+ flashlite/structured/outputs.py,sha256=Q_isfrtKJGybBadGMKmfo5UJ5vMaUQRCRgFpjGWZOF8,5070
30
+ flashlite/structured/schema.py,sha256=XxUvs4B8PE9CYd-Ui6XmWMFXU6VmX_6DSXMXkSEJTNQ,5052
31
+ flashlite/templating/__init__.py,sha256=zUsTkbFIglJHg6z3pdF7n9EgfSWcYMfi47W2IPjOQ6w,250
32
+ flashlite/templating/engine.py,sha256=KJCwnPIDDXceEl5jmr6YDwUugef6eEZGxZzRpB6MuO0,6630
33
+ flashlite/templating/filters.py,sha256=Cr3JjhN-I-LUY0H8jxPkCRrp0VNJIYWTjIH4voICUeo,3761
34
+ flashlite/templating/registry.py,sha256=wp8RaibHKNyu5q4tCdOXJ0B4tey7bv-c0qb9h1a7L0o,5021
35
+ flashlite/tools/__init__.py,sha256=zpQ5KyvZwZaVvaulnpMmL_JjCnMfD08nD_foI95TjVg,1791
36
+ flashlite/tools/definitions.py,sha256=cqyk6GR1qeMkTPFqsadnJc-YkCG15QVafiaf-OjGYNU,11519
37
+ flashlite/tools/execution.py,sha256=iQC7V3R5Tx19suISnnuaDpjpgl8wURwOHmKZbsHL16s,10814
38
+ flashlite-0.1.0.dist-info/METADATA,sha256=Wmpytj9YfLQpYccBCJ9po6Jx_bCD51z4-7VRC6LFcgk,4220
39
+ flashlite-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
40
+ flashlite-0.1.0.dist-info/licenses/LICENSE.md,sha256=z2KZcyoH16ayjxlbeBM01uD-bXn1WTcKFab5ZKBhfJE,1068
41
+ flashlite-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 Niall Dalton
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.