Python (pip)
YuktAI for Python
The yuktai package adds YuktAI to pages made by Django, Flask or FastAPI in one line: the ♿ accessibility widget, the 🛠 page tools and everything in window.yuktai. YuktAI still runs in the visitor's browser. The package only writes the right script tags for you.
- No dependencies, Python 3.9 or newer.
- No API keys, no server calls, no telemetry.
- Same features and options as the npm package and the script tag.
1. Install
pip install yuktaiOn PyPI: pypi.org/project/yuktai (opens in a new tab)
2. Flask
from flask import Flask
import yuktai
app = Flask(__name__)
yuktai.init_app(app, position="right", show_page_tools=True){{ yuktai_script() }}3. FastAPI
from fastapi.templating import Jinja2Templates
import yuktai
templates = Jinja2Templates(directory="templates")
yuktai.init_jinja(templates.env, show_page_tools=True){{ yuktai_script() }}4. Django
INSTALLED_APPS = [
# ...
"yuktai",
]
# optional defaults for every page
YUKTAI = {"position": "right", "show_page_tools": True}{% load yuktai_tags %}
{% yuktai_script %}Change options for one page: {% yuktai_script default_tab="ask" %}
5. Any other Python code
import yuktai
html = yuktai.script_tag(position="right", show_page_tools=True, voice_lang="te-IN")
# put html just before </body>The result is ready HTML: a small window.YUKTAI_CONFIG script (only when you pass options) and the YuktAI script from jsDelivr.
Options
| Option | What it does |
|---|---|
| version | YuktAI release to load. The package pins a tested release; "latest" follows new releases. |
| position | "left" or "right" |
| primary_color | Button colour, for example "#0a4a85" |
| title | Title of the settings dialog (Telugu works) |
| show_page_tools | Adds the 🛠 page tools button |
| default_tab | copilot, qa, forms, design, ask or voice |
| voice_lang | Speech language, for example "te-IN" |
| auto_fix, show_skip_links | Accessibility engine options |
| extra | Any other YUKTAI_CONFIG key, as a dict |
| cdn | "jsdelivr" (default) or "unpkg" |
| nonce | For pages with a Content Security Policy |
Safe by design
Safe JSON
Options are written as JSON with <, > and & escaped, so a value like </script> can't break out of the tag.
Checked values
Position, colour, tab, version, CDN and nonce are checked. A wrong value raises ValueError instead of writing broken HTML.
CSP ready
Pass nonce= and both script tags get it. Add cdn.jsdelivr.net to script-src, and 'wasm-unsafe-eval' for the Rust engines.
Not escaped twice
The tag is marked safe for Jinja2 and Django, so autoescaping does not turn it into text.
Coming next
Version 0.2 brings YuktAI's Rust engines to Python: fast grid search and the BM25 index for page RAG, with the same results as in the browser.