ff-aitoolkit 0.2.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.
- aitoolkit/__init__.py +66 -0
- aitoolkit/config.py +107 -0
- aitoolkit/embeddings/__init__.py +5 -0
- aitoolkit/embeddings/client.py +133 -0
- aitoolkit/exceptions.py +35 -0
- aitoolkit/integrations/__init__.py +1 -0
- aitoolkit/integrations/langchain.py +69 -0
- aitoolkit/llm/__init__.py +5 -0
- aitoolkit/llm/client.py +230 -0
- aitoolkit/py.typed +0 -0
- aitoolkit/rag/__init__.py +25 -0
- aitoolkit/rag/agent.py +165 -0
- aitoolkit/rag/query_expansion.py +147 -0
- aitoolkit/rag/retriever.py +141 -0
- aitoolkit/rag/vector_store.py +245 -0
- aitoolkit/retry.py +51 -0
- aitoolkit/stt/__init__.py +5 -0
- aitoolkit/stt/client.py +147 -0
- aitoolkit/tts/__init__.py +10 -0
- aitoolkit/tts/audio.py +68 -0
- aitoolkit/tts/client.py +219 -0
- aitoolkit/types.py +66 -0
- ff_aitoolkit-0.2.0.dist-info/METADATA +159 -0
- ff_aitoolkit-0.2.0.dist-info/RECORD +26 -0
- ff_aitoolkit-0.2.0.dist-info/WHEEL +4 -0
- ff_aitoolkit-0.2.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ff-aitoolkit
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Centralized AI clients (LLM, embeddings, STT, TTS, RAG) for self-hosted OpenAI-compatible GPU services.
|
|
5
|
+
Project-URL: Homepage, https://github.com/CNIT-Organization/aitoolkit
|
|
6
|
+
Project-URL: Repository, https://github.com/CNIT-Organization/aitoolkit
|
|
7
|
+
Project-URL: Issues, https://github.com/CNIT-Organization/aitoolkit/issues
|
|
8
|
+
Author: Faisal Fida
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,embeddings,llm,openai,rag,self-hosted,stt,tts
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Typing :: Typed
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Requires-Dist: httpx>=0.27
|
|
23
|
+
Requires-Dist: loguru>=0.7
|
|
24
|
+
Requires-Dist: openai>=1.50
|
|
25
|
+
Requires-Dist: pydantic-settings>=2.3
|
|
26
|
+
Requires-Dist: pydantic>=2.7
|
|
27
|
+
Provides-Extra: all
|
|
28
|
+
Requires-Dist: langchain-core>=0.3; extra == 'all'
|
|
29
|
+
Requires-Dist: langchain-openai>=0.2; extra == 'all'
|
|
30
|
+
Requires-Dist: qdrant-client>=1.12; extra == 'all'
|
|
31
|
+
Requires-Dist: redis>=5.0; extra == 'all'
|
|
32
|
+
Provides-Extra: cache
|
|
33
|
+
Requires-Dist: redis>=5.0; extra == 'cache'
|
|
34
|
+
Provides-Extra: langchain
|
|
35
|
+
Requires-Dist: langchain-core>=0.3; extra == 'langchain'
|
|
36
|
+
Requires-Dist: langchain-openai>=0.2; extra == 'langchain'
|
|
37
|
+
Provides-Extra: rag
|
|
38
|
+
Requires-Dist: qdrant-client>=1.12; extra == 'rag'
|
|
39
|
+
Description-Content-Type: text/markdown
|
|
40
|
+
|
|
41
|
+
# aitoolkit
|
|
42
|
+
|
|
43
|
+
Centralized AI clients — **LLM, Embeddings, Speech-to-Text, Text-to-Speech, and
|
|
44
|
+
RAG** — targeting self-hosted, OpenAI-compatible services. Reusable across
|
|
45
|
+
projects via a single git install.
|
|
46
|
+
|
|
47
|
+
## Why
|
|
48
|
+
|
|
49
|
+
Replaces scattered, provider-specific AI code (cloud-LLM wrappers, local Whisper,
|
|
50
|
+
ad-hoc LangChain) with one thin, stable, dependency-light package. The core is
|
|
51
|
+
**100% LangChain-free**; LangChain is an opt-in extra used only where LangGraph
|
|
52
|
+
orchestration needs it.
|
|
53
|
+
|
|
54
|
+
## Design principles
|
|
55
|
+
|
|
56
|
+
1. **Depend on stable interfaces, hide volatile implementations.** The public API
|
|
57
|
+
is a small set of clients + plain types; provider SDKs stay internal.
|
|
58
|
+
2. **Core is dependency-light and LangChain-free.** Heavy/optional things (qdrant,
|
|
59
|
+
redis, langchain) live behind extras and import lazily.
|
|
60
|
+
3. **No project specifics in the package.** Hosts, model ids, voices, collection
|
|
61
|
+
names, and keywords are parameters/config — never hardcoded.
|
|
62
|
+
4. **OpenAI-compatible first.** LLM, embeddings and STT use the `openai` SDK; only
|
|
63
|
+
TTS is a small custom `httpx` client.
|
|
64
|
+
5. **Async-first**, with sync convenience wrappers where ergonomics demand it.
|
|
65
|
+
|
|
66
|
+
## Install
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# core only (LLM, embeddings, STT, TTS)
|
|
70
|
+
pip install "aitoolkit @ git+https://github.com/CNIT-Organization/aitoolkit.git@v0.2.0"
|
|
71
|
+
|
|
72
|
+
# with RAG (Qdrant) + caching + LangChain bridge
|
|
73
|
+
pip install "aitoolkit[all] @ git+https://github.com/CNIT-Organization/aitoolkit.git@v0.2.0"
|
|
74
|
+
|
|
75
|
+
# pick exactly what a service needs
|
|
76
|
+
pip install "aitoolkit[rag,cache] @ git+...@v0.2.0"
|
|
77
|
+
pip install "aitoolkit[rag,langchain] @ git+...@v0.2.0"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Extras: `rag` (qdrant-client) · `cache` (redis) · `langchain` (langchain-core +
|
|
81
|
+
langchain-openai) · `all`.
|
|
82
|
+
|
|
83
|
+
## Configuration
|
|
84
|
+
|
|
85
|
+
All config is environment-driven (`AITOOLKIT_*`, see [.env.example](.env.example)),
|
|
86
|
+
but every client also accepts explicit overrides, so no env is strictly required.
|
|
87
|
+
|
|
88
|
+
## Quick start
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
import asyncio
|
|
92
|
+
from aitoolkit import get_llm_client, get_embeddings_client, get_stt_client, get_tts_client
|
|
93
|
+
|
|
94
|
+
async def main():
|
|
95
|
+
llm = get_llm_client()
|
|
96
|
+
print(await llm.chat("Say hello in one short sentence."))
|
|
97
|
+
|
|
98
|
+
async for tok in llm.stream("Count to five."):
|
|
99
|
+
print(tok, end="", flush=True)
|
|
100
|
+
|
|
101
|
+
emb = get_embeddings_client()
|
|
102
|
+
vecs = await emb.aembed_documents(["first document", "second document"])
|
|
103
|
+
print("dim:", emb.dimension)
|
|
104
|
+
|
|
105
|
+
stt = get_stt_client()
|
|
106
|
+
result = await stt.transcribe("audio.wav", language="en")
|
|
107
|
+
print(result.text)
|
|
108
|
+
|
|
109
|
+
tts = get_tts_client()
|
|
110
|
+
audio = await tts.synthesize("Hello world", voice="your-voice-id")
|
|
111
|
+
open("out.wav", "wb").write(audio)
|
|
112
|
+
|
|
113
|
+
# multi-speaker: synthesize each turn with its own voice and stitch to one WAV
|
|
114
|
+
dialogue = await tts.synthesize_dialogue([
|
|
115
|
+
{"voice_id": "voice-a", "text": "Welcome to the overview."},
|
|
116
|
+
{"voice_id": "voice-b", "text": "Let's dive in."},
|
|
117
|
+
])
|
|
118
|
+
open("dialogue.wav", "wb").write(dialogue)
|
|
119
|
+
|
|
120
|
+
asyncio.run(main())
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Structured output
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from pydantic import BaseModel
|
|
127
|
+
class Flashcard(BaseModel):
|
|
128
|
+
question: str
|
|
129
|
+
answer: str
|
|
130
|
+
|
|
131
|
+
card = await get_llm_client().chat_structured(Flashcard, "Make a flashcard about the water cycle.")
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### RAG (`aitoolkit[rag]`)
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from aitoolkit.rag import get_rag_agent
|
|
138
|
+
agent = get_rag_agent(collection_name="documents")
|
|
139
|
+
await agent.add_documents(["chunk 1", "chunk 2"], file_id="doc-42")
|
|
140
|
+
answer = await agent.answer_question("What does the document say about safety?")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### LangChain bridge (`aitoolkit[langchain]`)
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from aitoolkit.integrations.langchain import to_chat_model, LangChainEmbeddings
|
|
147
|
+
chat_model = to_chat_model(temperature=0.3) # a LangChain BaseChatModel for LangGraph
|
|
148
|
+
embeddings = LangChainEmbeddings() # a LangChain Embeddings
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Testing
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
pip install -e ".[all]" --group dev
|
|
155
|
+
pytest # unit tests (mocked)
|
|
156
|
+
AITOOLKIT_RUN_LIVE=1 pytest # also run live smoke tests against your endpoints
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Live tests auto-skip when the configured endpoints are unreachable.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
aitoolkit/__init__.py,sha256=eWgfulOl0Z2HqF8tt4OCFpvdlidBwFhDEEl8TK5At-Q,1639
|
|
2
|
+
aitoolkit/config.py,sha256=Yu2CbR0xgjJ5RC13cmWhp0NZWhgTqqM2dh40PuXeVk0,4191
|
|
3
|
+
aitoolkit/exceptions.py,sha256=WBkCTPcUTC-klYjoyhMl8TPdXjlDEu4PoP-NfbdNLq0,903
|
|
4
|
+
aitoolkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
|
+
aitoolkit/retry.py,sha256=iGNzowLcZu-ddgJjGJwM3H3tZ8Y584-OCLWHbLSUYQg,1805
|
|
6
|
+
aitoolkit/types.py,sha256=iEbyE4Ci4Si6NyGiKmApOvNv2UM4x3j1esxk7SjYXbs,1670
|
|
7
|
+
aitoolkit/embeddings/__init__.py,sha256=hdc4XgF4IfPyz5BKFQZkWL90F8yzZBKC3Wqeolne3Qw,211
|
|
8
|
+
aitoolkit/embeddings/client.py,sha256=_Y_ePyXPN0YLtdq0aL6jX_TOHqPDOhWjcOdgiiI_JcM,5214
|
|
9
|
+
aitoolkit/integrations/__init__.py,sha256=MJtAdOuWTh3wORjWMS2ymJ5z_gu6dQ6udKZkSaTZl0s,75
|
|
10
|
+
aitoolkit/integrations/langchain.py,sha256=3YFf8VQ2JmpDWtyGHYajkIo4GI-YetWWRcfgFUpblUc,2408
|
|
11
|
+
aitoolkit/llm/__init__.py,sha256=zCvyG6D5l6FaQmnfXUMc_zPHn0i4KLfTMpR5jN0olvc,186
|
|
12
|
+
aitoolkit/llm/client.py,sha256=w0lupU6tc0zD_ER4REn47Uzn6_v2Wvz_CH4B3WLA6-Y,8561
|
|
13
|
+
aitoolkit/rag/__init__.py,sha256=_kL9QJHufhtbsMkEekzzW_d2SbeqjdqOG-bt_SIYHbE,784
|
|
14
|
+
aitoolkit/rag/agent.py,sha256=g1YroDZVCKypkjsJWO2nZv2vxpt1SN3jNl8o-xnnKjM,5585
|
|
15
|
+
aitoolkit/rag/query_expansion.py,sha256=mKSgB83KXiAYtfp2xrMxiX2r_Vv4azZzN3hwWFStEkQ,5493
|
|
16
|
+
aitoolkit/rag/retriever.py,sha256=UfeB4GhC-m3UUBBWvc6_pHCdBAzCZwAPp-gutZzpXFE,4930
|
|
17
|
+
aitoolkit/rag/vector_store.py,sha256=y2zy4CAc1iuWKy1oiex4WKWo4XGvlkPo4XZA4LMTCsU,9017
|
|
18
|
+
aitoolkit/stt/__init__.py,sha256=6msmtOtLBZRtgNTOCk35S-psM6Ymd-fGQoTf-ynQP6M,180
|
|
19
|
+
aitoolkit/stt/client.py,sha256=PBnV-2AYtFV2HL869CFoG926O1rp0ZeupeGWqmmKwq4,5227
|
|
20
|
+
aitoolkit/tts/__init__.py,sha256=YnRvBdoT47HvHpHYEOqDO26NZ0_pzWQHcBUcNFC16mM,397
|
|
21
|
+
aitoolkit/tts/audio.py,sha256=duQOpdUw1XVaUycyESCaReVVHE-KATUGPz01_8UgBJQ,2606
|
|
22
|
+
aitoolkit/tts/client.py,sha256=yMQD859fz9J50QeI4td8eBGX2w9ZSVxgann1DHGznCU,8466
|
|
23
|
+
ff_aitoolkit-0.2.0.dist-info/METADATA,sha256=-8XfYbp_ARcFhD-69oAf2rcsSS4kCwO4RSeiVjvs6Es,5687
|
|
24
|
+
ff_aitoolkit-0.2.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
25
|
+
ff_aitoolkit-0.2.0.dist-info/licenses/LICENSE,sha256=Ez7zdj8WqKy4Em_RWPGp-cIX7PuHTk2yqh38ahms7KI,1068
|
|
26
|
+
ff_aitoolkit-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Faisal Fida
|
|
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.
|