simple_module_ai
AI base module for SimpleModule apps: one provider-configurable service layer (chat + embeddings) that every other module shares, with DB-backed settings, encrypted keys and an admin page.
The module owns connection configuration — provider, endpoint, key, model name. Consuming modules own behaviour — agents, prompts, temperature, retries, streaming.
Install
pip install simple_module_ai
Add simple_module_ai to your host's dependencies; it is discovered at boot
via the simple_module entry point. There are no tables and no migrations.
Usage (consuming from another module)
Declare the dependency in your module's ModuleMeta:
meta = ModuleMeta(name="MyModule", depends_on=["Ai"], ...)
Then resolve connections wherever you need them:
from pydantic_ai import Agent
from sm_ai.contracts import AiNotConfiguredError, resolve_model, resolve_embedder
agent = Agent(instructions="...", output_type=MySchema)
result = await agent.run(text, model=resolve_model())
embedder = resolve_embedder() # raises AiNotConfiguredError until the
result = await embedder.embed_documents(chunks) # embedding slot is set up
resolve_model(model_name=...) overrides the configured model name for
same-endpoint multi-model setups. embedding_dim() returns the configured
vector width. All errors subclass AiError.
The import package is
sm_ai, notai— the bare name belongs to another PyPI project and would collide in hosts that install it.
Settings
Two slots — chat and embeddings — each with provider (anthropic, openai,
google, openai_compatible), model, base URL and API key. The
openai_compatible provider covers vLLM, Ollama and LM Studio (base URL
required; a blank key is replaced by a protocol-satisfying placeholder).
Configure at /ai/ (permission ai.manage) or seed via SM_AI_* env vars
(e.g. SM_AI_CHAT_MODEL); DB values win over env. API keys are encrypted at
rest with a key derived from SM_SECRET_KEY — rotating that secret means
re-entering provider keys (the old ciphertexts surface as unreadable). A
settings save hot-reloads the worker that handled it; other workers pick
the change up on restart.
Routes
| Route | Purpose |
|---|---|
GET /ai/ |
admin settings page |
GET/PUT /api/ai/settings |
read (secrets masked) / update |
POST /api/ai/test |
probe the chat or embedding slot |
Writes require an X-CSRF-Token header bound to the session (the admin page
sends it automatically; the token is mirrored to the sm_ai_csrf cookie).
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simple_module_ai-0.0.6.tar.gz.
File metadata
- Download URL: simple_module_ai-0.0.6.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1eaa8030f73ef7e5100e4f101f595961c4740bc8719b424b6fb0ea05bbaeabd
|
|
| MD5 |
f562641e076cf3391a322f48c83c543c
|
|
| BLAKE2b-256 |
83fac56ea0f69b529f90e9772b454944541467d102475f1e2a0f5377f0d1ca3c
|
Provenance
The following attestation bundles were made for simple_module_ai-0.0.6.tar.gz:
Publisher:
release.yml on antosubash/smpy_modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_ai-0.0.6.tar.gz -
Subject digest:
f1eaa8030f73ef7e5100e4f101f595961c4740bc8719b424b6fb0ea05bbaeabd - Sigstore transparency entry: 2583434514
- Sigstore integration time:
-
Permalink:
antosubash/smpy_modules@bf5c8bfe5f38039b209febce9d43fa5a1d6717ab -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bf5c8bfe5f38039b209febce9d43fa5a1d6717ab -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file simple_module_ai-0.0.6-py3-none-any.whl.
File metadata
- Download URL: simple_module_ai-0.0.6-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
32d95bd48b4ec356f2e48dcfdaeb3c95b1555b9e834a6146355c9c91491775c3
|
|
| MD5 |
013cfff578b9aa06e54375a0e54506e6
|
|
| BLAKE2b-256 |
a08d81c0898bdb7a3ef5c431342a902734b374e3bc5996628a72d54ef2ed2fe8
|
Provenance
The following attestation bundles were made for simple_module_ai-0.0.6-py3-none-any.whl:
Publisher:
release.yml on antosubash/smpy_modules
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
simple_module_ai-0.0.6-py3-none-any.whl -
Subject digest:
32d95bd48b4ec356f2e48dcfdaeb3c95b1555b9e834a6146355c9c91491775c3 - Sigstore transparency entry: 2583434531
- Sigstore integration time:
-
Permalink:
antosubash/smpy_modules@bf5c8bfe5f38039b209febce9d43fa5a1d6717ab -
Branch / Tag:
refs/heads/main - Owner: https://github.com/antosubash
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@bf5c8bfe5f38039b209febce9d43fa5a1d6717ab -
Trigger Event:
workflow_dispatch
-
Statement type: