LLM-aware UI focus context for Streamlit — askable Python binding
Project description
askable-streamlit
Streamlit binding for askable — give your Streamlit app LLM awareness.
Install
pip install askable-streamlit
Quick start
import streamlit as st
from askable.streamlit import askable_context
st.title("AI Dashboard")
# Render data with data-askable annotations
st.markdown(
"""
<div data-askable='{"metric":"revenue","period":"Q3","value":"$2.3M"}'>
<h3>Q3 Revenue: $2.3M</h3>
<p>Down 12% month-over-month</p>
</div>
""",
unsafe_allow_html=True,
)
# Get the current focus context
focus = askable_context()
if focus:
st.caption(f"Context: {focus['text'][:80]}...")
if st.button("Ask AI about this"):
prompt_context = (
f"User is focused on: {focus['text']} "
f"(metadata: {focus['meta']})"
)
# Pass prompt_context as your LLM system message
response = call_your_llm(
system=f"UI context: {prompt_context}",
user="What should I know about this?",
)
st.write(response)
How it works
askable_context() renders a hidden zero-height iframe component that:
- Injects
@askable/coreinto the parent Streamlit page via same-origin iframe access - Observes all
[data-askable]elements ondocument.body - When the user clicks, focuses, or hovers an annotated element, sends the focus data back to Python as the component value
The returned dict has the same shape as AskableFocus from the JS core:
{
"meta": {"metric": "revenue", "period": "Q3"}, # parsed from data-askable
"text": "Q3 Revenue: $2.3M", # element text (≤200 chars)
"timestamp": 1711234567890, # unix ms
}
Requirements
- Python ≥ 3.9
- Streamlit ≥ 1.28.0
- Works with all standard Streamlit deployment targets (local, Streamlit Cloud, etc.)
Note: The component injects JS into the parent page via same-origin iframe access. This works in all standard Streamlit deployments because custom component frontends are served from the same origin as the app.
License
MIT
Project details
Release history Release notifications | RSS feed
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 askable_streamlit-0.1.2.tar.gz.
File metadata
- Download URL: askable_streamlit-0.1.2.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
475159b0613f0854189da592c5c4285756bd5e5ff3afdf67f8fd255440ad4d13
|
|
| MD5 |
e673e268a252e6d861866982435e28d5
|
|
| BLAKE2b-256 |
f786b73380495fa9725a995ea2e8abf8711a8e0d44475bb62d3399b5a8c46668
|
Provenance
The following attestation bundles were made for askable_streamlit-0.1.2.tar.gz:
Publisher:
publish-python.yml on askable-ui/askable
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
askable_streamlit-0.1.2.tar.gz -
Subject digest:
475159b0613f0854189da592c5c4285756bd5e5ff3afdf67f8fd255440ad4d13 - Sigstore transparency entry: 1195490983
- Sigstore integration time:
-
Permalink:
askable-ui/askable@9212d62382e5505fa93ffaec667033ab8c232d7e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/askable-ui
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@9212d62382e5505fa93ffaec667033ab8c232d7e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file askable_streamlit-0.1.2-py3-none-any.whl.
File metadata
- Download URL: askable_streamlit-0.1.2-py3-none-any.whl
- Upload date:
- Size: 2.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac0f7fd33a92382f95b8757006399af62681b9d1eb8636ef4b68dcc7e48ddf29
|
|
| MD5 |
7b5cf8e1d01f6e86e954468e4c6e3cfb
|
|
| BLAKE2b-256 |
86b373f4f24348b46b21549182341f7d00737d3e42064e32b0918cc4578cc294
|
Provenance
The following attestation bundles were made for askable_streamlit-0.1.2-py3-none-any.whl:
Publisher:
publish-python.yml on askable-ui/askable
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
askable_streamlit-0.1.2-py3-none-any.whl -
Subject digest:
ac0f7fd33a92382f95b8757006399af62681b9d1eb8636ef4b68dcc7e48ddf29 - Sigstore transparency entry: 1195490993
- Sigstore integration time:
-
Permalink:
askable-ui/askable@9212d62382e5505fa93ffaec667033ab8c232d7e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/askable-ui
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-python.yml@9212d62382e5505fa93ffaec667033ab8c232d7e -
Trigger Event:
workflow_dispatch
-
Statement type: