slimx 0.5.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 (74) hide show
  1. slimx-0.5.0/.github/workflows/ci.yml +20 -0
  2. slimx-0.5.0/.github/workflows/docs.yml +55 -0
  3. slimx-0.5.0/.gitignore +120 -0
  4. slimx-0.5.0/CHANGELOG.md +21 -0
  5. slimx-0.5.0/CONTRIBUTING.md +10 -0
  6. slimx-0.5.0/LICENSE +21 -0
  7. slimx-0.5.0/PKG-INFO +179 -0
  8. slimx-0.5.0/README.md +138 -0
  9. slimx-0.5.0/docs/api/high.md +10 -0
  10. slimx-0.5.0/docs/api/low.md +14 -0
  11. slimx-0.5.0/docs/api/providers.md +3 -0
  12. slimx-0.5.0/docs/assets/A_detailed_flowchart_diagram_showcases_the_SlimX_l.png +0 -0
  13. slimx-0.5.0/docs/assets/A_flowchart_diagram_visually_represents_the_class_.png +0 -0
  14. slimx-0.5.0/docs/concepts/architecture.md +9 -0
  15. slimx-0.5.0/docs/concepts/high_vs_low.md +3 -0
  16. slimx-0.5.0/docs/concepts/plugins.md +3 -0
  17. slimx-0.5.0/docs/concepts/provider-capabilities.md +7 -0
  18. slimx-0.5.0/docs/concepts/provider-neutral-calls.md +11 -0
  19. slimx-0.5.0/docs/concepts/providers.md +3 -0
  20. slimx-0.5.0/docs/concepts/slimx-rag.md +11 -0
  21. slimx-0.5.0/docs/concepts/streaming.md +16 -0
  22. slimx-0.5.0/docs/concepts/structured_output.md +18 -0
  23. slimx-0.5.0/docs/concepts/tools.md +16 -0
  24. slimx-0.5.0/docs/concepts/types.md +51 -0
  25. slimx-0.5.0/docs/concepts/vision.md +3 -0
  26. slimx-0.5.0/docs/contributing.md +3 -0
  27. slimx-0.5.0/docs/index.md +11 -0
  28. slimx-0.5.0/docs/quickstart.md +18 -0
  29. slimx-0.5.0/examples/async_stream_openai.py +11 -0
  30. slimx-0.5.0/examples/quickstart_anthropic.py +4 -0
  31. slimx-0.5.0/examples/quickstart_google.py +13 -0
  32. slimx-0.5.0/examples/quickstart_ollama.py +4 -0
  33. slimx-0.5.0/examples/quickstart_openai.py +6 -0
  34. slimx-0.5.0/examples/stream_openai.py +7 -0
  35. slimx-0.5.0/examples/tools_openai.py +11 -0
  36. slimx-0.5.0/mkdocs.yml +34 -0
  37. slimx-0.5.0/pyproject.toml +43 -0
  38. slimx-0.5.0/slimx/__init__.py +99 -0
  39. slimx-0.5.0/slimx/errors.py +7 -0
  40. slimx-0.5.0/slimx/high/__init__.py +2 -0
  41. slimx-0.5.0/slimx/high/api.py +148 -0
  42. slimx-0.5.0/slimx/low/__init__.py +32 -0
  43. slimx-0.5.0/slimx/low/client.py +137 -0
  44. slimx-0.5.0/slimx/low/providers/__init__.py +6 -0
  45. slimx-0.5.0/slimx/low/types.py +24 -0
  46. slimx-0.5.0/slimx/messages.py +89 -0
  47. slimx-0.5.0/slimx/providers/__init__.py +13 -0
  48. slimx-0.5.0/slimx/providers/_defaults.py +100 -0
  49. slimx-0.5.0/slimx/providers/anthropic.py +54 -0
  50. slimx-0.5.0/slimx/providers/anthropic_async.py +58 -0
  51. slimx-0.5.0/slimx/providers/base.py +58 -0
  52. slimx-0.5.0/slimx/providers/google.py +422 -0
  53. slimx-0.5.0/slimx/providers/google_async.py +119 -0
  54. slimx-0.5.0/slimx/providers/ollama.py +96 -0
  55. slimx-0.5.0/slimx/providers/ollama_async.py +100 -0
  56. slimx-0.5.0/slimx/providers/openai.py +100 -0
  57. slimx-0.5.0/slimx/providers/openai_async.py +104 -0
  58. slimx-0.5.0/slimx/providers/plugins.py +17 -0
  59. slimx-0.5.0/slimx/providers/registry.py +36 -0
  60. slimx-0.5.0/slimx/schema.py +75 -0
  61. slimx-0.5.0/slimx/tooling.py +34 -0
  62. slimx-0.5.0/slimx/types.py +172 -0
  63. slimx-0.5.0/slimx/utils/__init__.py +0 -0
  64. slimx-0.5.0/slimx/utils/ndjson.py +28 -0
  65. slimx-0.5.0/slimx/utils/retry.py +16 -0
  66. slimx-0.5.0/slimx/utils/sse.py +17 -0
  67. slimx-0.5.0/slimx/utils/sse_async.py +17 -0
  68. slimx-0.5.0/tests/fakes.py +41 -0
  69. slimx-0.5.0/tests/test_client_runtime.py +77 -0
  70. slimx-0.5.0/tests/test_google_provider.py +413 -0
  71. slimx-0.5.0/tests/test_ollama_provider.py +62 -0
  72. slimx-0.5.0/tests/test_schema.py +17 -0
  73. slimx-0.5.0/tests/test_tooling.py +9 -0
  74. slimx-0.5.0/uv.lock +1185 -0
@@ -0,0 +1,20 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: astral-sh/setup-uv@v7
14
+ with:
15
+ enable-cache: true
16
+ - run: uv sync --all-extras
17
+ - run: uv run ruff check .
18
+ - run: uv run pyright
19
+ - run: uv run pytest -q
20
+ - run: uv run python -m build
@@ -0,0 +1,55 @@
1
+ name: Deploy Docs (MkDocs)
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ paths:
7
+ - "docs/**"
8
+ - "mkdocs.yml"
9
+ - "pyproject.toml"
10
+ - "uv.lock"
11
+ - ".github/workflows/docs.yml"
12
+ workflow_dispatch:
13
+
14
+ permissions:
15
+ contents: read
16
+ pages: write
17
+ id-token: write
18
+
19
+ concurrency:
20
+ group: "pages"
21
+ cancel-in-progress: true
22
+
23
+ jobs:
24
+ build:
25
+ runs-on: ubuntu-latest
26
+ steps:
27
+ - name: Checkout
28
+ uses: actions/checkout@v4
29
+
30
+ - name: Set up uv
31
+ uses: astral-sh/setup-uv@v7
32
+ with:
33
+ enable-cache: true
34
+
35
+ - name: Install deps (docs extras)
36
+ run: uv sync --locked --all-extras
37
+
38
+ - name: Build site
39
+ run: uv run python -m mkdocs build --strict
40
+
41
+ - name: Upload Pages artifact
42
+ uses: actions/upload-pages-artifact@v3
43
+ with:
44
+ path: site
45
+
46
+ deploy:
47
+ needs: build
48
+ runs-on: ubuntu-latest
49
+ environment:
50
+ name: github-pages
51
+ url: ${{ steps.deployment.outputs.page_url }}
52
+ steps:
53
+ - name: Deploy to GitHub Pages
54
+ id: deployment
55
+ uses: actions/deploy-pages@v4
slimx-0.5.0/.gitignore ADDED
@@ -0,0 +1,120 @@
1
+ # =========================
2
+ # Python
3
+ # =========================
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+ *.so
8
+
9
+ # Bytecode / compiled / optimized
10
+ *.pyd
11
+ *.pyo
12
+
13
+ # =========================
14
+ # Virtual environments (uv / venv)
15
+ # =========================
16
+ .venv/
17
+ .venv_test/
18
+ venv/
19
+ ENV/
20
+ env/
21
+
22
+ # =========================
23
+ # Environment variables / secrets
24
+ # =========================
25
+ .env
26
+ .env.*
27
+ !.env.example
28
+ *.key
29
+ *.pem
30
+
31
+ # =========================
32
+ # Packaging / build artifacts
33
+ # =========================
34
+ build/
35
+ dist/
36
+ *.egg-info/
37
+ .eggs/
38
+ pip-wheel-metadata/
39
+ wheelhouse/
40
+
41
+ # PEP 582 (if someone uses it)
42
+ __pypackages__/
43
+
44
+ # =========================
45
+ # Test / coverage / profiling
46
+ # =========================
47
+ .pytest_cache/
48
+ .coverage
49
+ .coverage.*
50
+ htmlcov/
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pyre/
56
+ .dmypy.json
57
+ .prof
58
+ .profraw
59
+
60
+ # =========================
61
+ # Type checkers / linters / formatters
62
+ # =========================
63
+ .mypy_cache/
64
+ .ruff_cache/
65
+ .pyright/
66
+ .pytype/
67
+ .pylint.d/
68
+
69
+ # =========================
70
+ # IDEs / editors
71
+ # =========================
72
+ .vscode/
73
+ .idea/
74
+ *.sublime-project
75
+ *.sublime-workspace
76
+
77
+ # =========================
78
+ # Jupyter / notebooks
79
+ # =========================
80
+ .ipynb_checkpoints/
81
+
82
+ # =========================
83
+ # OS files
84
+ # =========================
85
+ .DS_Store
86
+ .DS_Store?
87
+ Thumbs.db
88
+ ehthumbs.db
89
+ Desktop.ini
90
+
91
+ # =========================
92
+ # MkDocs / docs build output
93
+ # =========================
94
+ site/
95
+
96
+ # =========================
97
+ # Logs and internal docs
98
+ # =========================
99
+ *.log
100
+ internal_docs/
101
+
102
+ # =========================
103
+ # Local caches / temp
104
+ # =========================
105
+ .cache/
106
+ .tmp/
107
+ tmp/
108
+ *.tmp
109
+ *.swp
110
+ *.swo
111
+
112
+ # =========================
113
+ # Node (in case mkdocs-material or tooling pulls nodeenv)
114
+ # =========================
115
+ node_modules/
116
+
117
+ # =========================
118
+ # Local overrides
119
+ # =========================
120
+ *.local
@@ -0,0 +1,21 @@
1
+ # Changelog
2
+
3
+ ## v0.4.0 (2026-01-03)
4
+
5
+ - Multi-provider support (OpenAI, Anthropic, Ollama)
6
+ - Provider registry + plugin loading via entry points
7
+ - Sync + async clients and streaming
8
+ - Tool calling + optional auto tool loop (sync + async)
9
+ - Structured JSON output parsing (dataclasses)
10
+ - MkDocs docs scaffold + GitHub Actions CI/docs/publish
11
+
12
+ ## v0.5.0 (2026-06-03)
13
+
14
+ - Added built-in Google Gemini provider support.
15
+ - Added synchronous and asynchronous Google provider implementations.
16
+ - Added Google Gemini streaming support.
17
+ - Added Google Gemini structured JSON output mapping.
18
+ - Added Google Gemini tool/function-call mapping.
19
+ - Added Google provider tests with fake HTTP clients.
20
+ - Added Google Gemini quickstart example.
21
+ - Updated provider documentation to include Google Gemini.
@@ -0,0 +1,10 @@
1
+ # Contributing to SlimX
2
+
3
+ ## Dev setup (uv)
4
+
5
+ ```bash
6
+ uv sync --all-extras
7
+ uv run pytest
8
+ uv run ruff check .
9
+ uv run pyright
10
+ ```
slimx-0.5.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SlimX
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.
slimx-0.5.0/PKG-INFO ADDED
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: slimx
3
+ Version: 0.5.0
4
+ Summary: A slim, intuitive, lightweight Python library for calling LLMs (high-level + low-level) with multi-provider support.
5
+ Author: SlimX Contributors
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 SlimX
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
+ License-File: LICENSE
28
+ Keywords: anthropic,llm,ollama,openai,sdk,streaming,tools
29
+ Requires-Python: >=3.10
30
+ Requires-Dist: httpx>=0.27.0
31
+ Provides-Extra: dev
32
+ Requires-Dist: build>=1.2.0; extra == 'dev'
33
+ Requires-Dist: pyright>=1.1.0; extra == 'dev'
34
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
35
+ Requires-Dist: ruff>=0.6.0; extra == 'dev'
36
+ Requires-Dist: twine>=5.0.0; extra == 'dev'
37
+ Provides-Extra: docs
38
+ Requires-Dist: mkdocs-material>=9.5.0; extra == 'docs'
39
+ Requires-Dist: mkdocs>=1.6.0; extra == 'docs'
40
+ Description-Content-Type: text/markdown
41
+
42
+ # SlimX (`slimx`) — v0.5.0
43
+
44
+ SlimX is a **slim, intuitive, lightweight** Python library for calling LLMs and building LLM systems.
45
+
46
+ It is intentionally designed around **two clearly separated APIs**:
47
+
48
+ - **High-level API** (`slimx`) — “1‑minute productivity”: `llm(...)`, `.stream(...)`, `.json(...)`, tools, retries.
49
+ - **Low-level API** (`slimx.low`) — “systems builder primitives”: explicit `Client`, `ChatRequest`, `Message`, provider registry, middleware.
50
+
51
+ SlimX also supports **multiple providers** (OpenAI, Anthropic, Ollama, Google) and **provider plugins** (3rd-party providers without modifying core).
52
+
53
+ ---
54
+
55
+ ## Install (using `uv`)
56
+
57
+ On Debian/Ubuntu you may hit `externally-managed-environment` (PEP 668) if you try to use system `pip`.
58
+ Use **uv**, which manages an isolated environment cleanly.
59
+
60
+ ### Option A — contributors / repo setup (recommended)
61
+ ```bash
62
+ git clone https://github.com/slimx-ai/slimx.git
63
+ cd slimx
64
+ uv sync --all-extras
65
+ ```
66
+
67
+ ### Option B — quick test from an extracted zip
68
+ ```bash
69
+ unzip slimx_v0_4.zip
70
+ cd slimx_v0_4
71
+ uv sync --all-extras
72
+ uv run python examples/quickstart_openai.py
73
+ ```
74
+
75
+ > `uv sync` reads `pyproject.toml` and (optionally) `uv.lock`.
76
+ > If `uv.lock` is present and committed, installs are reproducible.
77
+
78
+ ---
79
+
80
+ ## Configure providers
81
+
82
+ ### OpenAI
83
+ ```bash
84
+ export OPENAI_API_KEY="..."
85
+ # optional:
86
+ export OPENAI_BASE_URL="https://api.openai.com/v1"
87
+ ```
88
+
89
+ ### Google Gemini
90
+
91
+ ```bash
92
+ export GOOGLE_API_KEY="..."
93
+ # or:
94
+ export GEMINI_API_KEY="..."
95
+
96
+ # optional:
97
+ export GOOGLE_BASE_URL="https://generativelanguage.googleapis.com/v1beta"
98
+ ```
99
+
100
+ ### Anthropic
101
+ ```bash
102
+ export ANTHROPIC_API_KEY="..."
103
+ # optional:
104
+ export ANTHROPIC_BASE_URL="https://api.anthropic.com"
105
+ export ANTHROPIC_VERSION="2023-06-01"
106
+ ```
107
+
108
+ ### Ollama (local)
109
+ ```bash
110
+ export OLLAMA_BASE_URL="http://localhost:11434"
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Quickstart (high-level)
116
+
117
+ ```python
118
+ from slimx import llm
119
+ m = llm("openai:gpt-4.1-nano", temperature=0.2)
120
+ res = m("Write a haiku about fog and streetlights.")
121
+ print(res.text)
122
+ ```
123
+
124
+ ```python
125
+ from slimx import llm
126
+
127
+ m = llm("google:gemini-3.5-flash", temperature=0.2)
128
+ res = m("Write a haiku about small, inspectable AI software.")
129
+ print(res.text)
130
+ ```
131
+
132
+ Streaming:
133
+
134
+ ```python
135
+ for ev in m.stream("Tell a short story in 5 lines."):
136
+ if ev.type == "text_delta":
137
+ print(ev.text, end="", flush=True)
138
+ print()
139
+ ```
140
+
141
+ Tools (auto-loop):
142
+
143
+ ```python
144
+ from slimx import llm, tool
145
+
146
+ @tool
147
+ def add(a: int, b: int) -> int:
148
+ "Add two integers."
149
+ return a + b
150
+
151
+ m = llm("openai:gpt-4.1-nano", tools=[add], tool_runtime="auto")
152
+ print(m("What is 12 + 30?").text)
153
+ ```
154
+
155
+ Structured output:
156
+
157
+ ```python
158
+ from dataclasses import dataclass
159
+ from slimx import llm
160
+
161
+ @dataclass
162
+ class City:
163
+ name: str
164
+ country: str
165
+
166
+ m = llm("openai:gpt-4.1-nano")
167
+ res = m.json("Paris is in France.", schema=City)
168
+ print(res.data)
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Repo automation
174
+
175
+ This bundle includes GitHub Actions:
176
+ - CI (`.github/workflows/ci.yml`)
177
+ - Docs deploy to GitHub Pages (`docs.yml`)
178
+
179
+ See `README.md` and `docs/` for details.
slimx-0.5.0/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # SlimX (`slimx`) — v0.5.0
2
+
3
+ SlimX is a **slim, intuitive, lightweight** Python library for calling LLMs and building LLM systems.
4
+
5
+ It is intentionally designed around **two clearly separated APIs**:
6
+
7
+ - **High-level API** (`slimx`) — “1‑minute productivity”: `llm(...)`, `.stream(...)`, `.json(...)`, tools, retries.
8
+ - **Low-level API** (`slimx.low`) — “systems builder primitives”: explicit `Client`, `ChatRequest`, `Message`, provider registry, middleware.
9
+
10
+ SlimX also supports **multiple providers** (OpenAI, Anthropic, Ollama, Google) and **provider plugins** (3rd-party providers without modifying core).
11
+
12
+ ---
13
+
14
+ ## Install (using `uv`)
15
+
16
+ On Debian/Ubuntu you may hit `externally-managed-environment` (PEP 668) if you try to use system `pip`.
17
+ Use **uv**, which manages an isolated environment cleanly.
18
+
19
+ ### Option A — contributors / repo setup (recommended)
20
+ ```bash
21
+ git clone https://github.com/slimx-ai/slimx.git
22
+ cd slimx
23
+ uv sync --all-extras
24
+ ```
25
+
26
+ ### Option B — quick test from an extracted zip
27
+ ```bash
28
+ unzip slimx_v0_4.zip
29
+ cd slimx_v0_4
30
+ uv sync --all-extras
31
+ uv run python examples/quickstart_openai.py
32
+ ```
33
+
34
+ > `uv sync` reads `pyproject.toml` and (optionally) `uv.lock`.
35
+ > If `uv.lock` is present and committed, installs are reproducible.
36
+
37
+ ---
38
+
39
+ ## Configure providers
40
+
41
+ ### OpenAI
42
+ ```bash
43
+ export OPENAI_API_KEY="..."
44
+ # optional:
45
+ export OPENAI_BASE_URL="https://api.openai.com/v1"
46
+ ```
47
+
48
+ ### Google Gemini
49
+
50
+ ```bash
51
+ export GOOGLE_API_KEY="..."
52
+ # or:
53
+ export GEMINI_API_KEY="..."
54
+
55
+ # optional:
56
+ export GOOGLE_BASE_URL="https://generativelanguage.googleapis.com/v1beta"
57
+ ```
58
+
59
+ ### Anthropic
60
+ ```bash
61
+ export ANTHROPIC_API_KEY="..."
62
+ # optional:
63
+ export ANTHROPIC_BASE_URL="https://api.anthropic.com"
64
+ export ANTHROPIC_VERSION="2023-06-01"
65
+ ```
66
+
67
+ ### Ollama (local)
68
+ ```bash
69
+ export OLLAMA_BASE_URL="http://localhost:11434"
70
+ ```
71
+
72
+ ---
73
+
74
+ ## Quickstart (high-level)
75
+
76
+ ```python
77
+ from slimx import llm
78
+ m = llm("openai:gpt-4.1-nano", temperature=0.2)
79
+ res = m("Write a haiku about fog and streetlights.")
80
+ print(res.text)
81
+ ```
82
+
83
+ ```python
84
+ from slimx import llm
85
+
86
+ m = llm("google:gemini-3.5-flash", temperature=0.2)
87
+ res = m("Write a haiku about small, inspectable AI software.")
88
+ print(res.text)
89
+ ```
90
+
91
+ Streaming:
92
+
93
+ ```python
94
+ for ev in m.stream("Tell a short story in 5 lines."):
95
+ if ev.type == "text_delta":
96
+ print(ev.text, end="", flush=True)
97
+ print()
98
+ ```
99
+
100
+ Tools (auto-loop):
101
+
102
+ ```python
103
+ from slimx import llm, tool
104
+
105
+ @tool
106
+ def add(a: int, b: int) -> int:
107
+ "Add two integers."
108
+ return a + b
109
+
110
+ m = llm("openai:gpt-4.1-nano", tools=[add], tool_runtime="auto")
111
+ print(m("What is 12 + 30?").text)
112
+ ```
113
+
114
+ Structured output:
115
+
116
+ ```python
117
+ from dataclasses import dataclass
118
+ from slimx import llm
119
+
120
+ @dataclass
121
+ class City:
122
+ name: str
123
+ country: str
124
+
125
+ m = llm("openai:gpt-4.1-nano")
126
+ res = m.json("Paris is in France.", schema=City)
127
+ print(res.data)
128
+ ```
129
+
130
+ ---
131
+
132
+ ## Repo automation
133
+
134
+ This bundle includes GitHub Actions:
135
+ - CI (`.github/workflows/ci.yml`)
136
+ - Docs deploy to GitHub Pages (`docs.yml`)
137
+
138
+ See `README.md` and `docs/` for details.
@@ -0,0 +1,10 @@
1
+ # High-level API
2
+
3
+ The high-level API is optimized for quick productivity:
4
+
5
+ - `llm("provider:model")`
6
+ - `model(prompt)`
7
+ - `model.stream(prompt)`
8
+ - `model.json(prompt, schema=...)`
9
+
10
+ High-level calls still return normalized `Result` objects with text, usage, tool calls, parsed data, and trace metadata.
@@ -0,0 +1,14 @@
1
+ # Low-level API
2
+
3
+ Use the low-level API when building systems such as RAG and agents:
4
+
5
+ ```python
6
+ from slimx import Client, Message
7
+ from slimx.low import ChatRequest
8
+ from slimx.providers import get_provider
9
+
10
+ client = Client(get_provider("openai"), timeout=30)
11
+ result = client.chat(ChatRequest(model="gpt-4.1-nano", messages=[Message.user("Hello")]))
12
+ ```
13
+
14
+ The low-level API keeps request objects, provider selection, retries, timeouts, and traces explicit.
@@ -0,0 +1,3 @@
1
+ # Providers API
2
+
3
+ See `slimx/providers/*`.
@@ -0,0 +1,9 @@
1
+ # Architecture
2
+
3
+ ## High-level view
4
+
5
+ ![SlimX class relationships](../assets/A_flowchart_diagram_visually_represents_the_class_.png)
6
+
7
+ ## Detailed view
8
+
9
+ ![SlimX detailed class relationships](../assets/A_detailed_flowchart_diagram_showcases_the_SlimX_l.png)
@@ -0,0 +1,3 @@
1
+ # High vs Low
2
+
3
+ High-level: `llm()` convenience. Low-level: explicit `Client` + `ChatRequest`.
@@ -0,0 +1,3 @@
1
+ # Plugins
2
+
3
+ Register providers via entry points group `slimx.providers`.
@@ -0,0 +1,7 @@
1
+ # Provider Capabilities And Fallbacks
2
+
3
+ Every provider exposes a small capability object describing whether it supports tools, structured output, streaming, async chat, and async streaming.
4
+
5
+ Use this in demo diagnostics and production checks to avoid pretending every provider supports every feature equally.
6
+
7
+ OpenAI currently supports tools, structured output, and streaming. Ollama is treated as a strong local streaming fallback. Anthropic support is available for chat, with streaming currently implemented as a compatibility wrapper.
@@ -0,0 +1,11 @@
1
+ # Provider-neutral Calls
2
+
3
+ SlimX model IDs use `provider:model` strings. Providers are selected through adapters, while application code keeps using the same request and result shapes.
4
+
5
+ Examples:
6
+
7
+ - `openai:gpt-4.1-nano`
8
+ - `anthropic:claude-3-5-haiku-latest`
9
+ - `ollama:llama3.1`
10
+
11
+ Provider-neutral calls let demos and deployments switch between hosted API models and local sovereignty fallbacks.
@@ -0,0 +1,3 @@
1
+ # Providers
2
+
3
+ Use prefixes like `openai:`, `anthropic:`, `ollama:`.
@@ -0,0 +1,11 @@
1
+ # Using SlimX Inside SlimX-RAG
2
+
3
+ SlimX-RAG handles deterministic retrieval. SlimX handles provider-neutral generation.
4
+
5
+ The customer-demo flow is:
6
+
7
+ ```text
8
+ question -> retrieve chunks -> build grounded prompt -> SlimX model call -> cited answer + trace
9
+ ```
10
+
11
+ This keeps the retrieval trace and model trace separate, which makes the system easier to debug and explain to customers.
@@ -0,0 +1,16 @@
1
+ # Streaming Event Contract
2
+
3
+ SlimX normalizes provider streaming into `StreamEvent` records.
4
+
5
+ Event types:
6
+
7
+ - `text_delta`
8
+ - `tool_call`
9
+ - `done`
10
+ - `error`
11
+
12
+ ```python
13
+ for event in model.stream("Tell a short story."):
14
+ if event.type == "text_delta":
15
+ print(event.text, end="", flush=True)
16
+ ```