streamlit-coco
on a client engagement. Companion files: doc/training/*.md.
pip install streamlit-coco[sdk]| Without streamlit-coco | With streamlit-coco |
|---|---|
| Wire CoCo yourself across Streamlit reruns | Session + fragment polling that keeps streaming |
| Raw JSON tool dumps | Meaningful cards (Glob, Grep, Read, Write, SQL, AskUser…) |
| Hope the agent behaves | require_approval_for + HITL UI |
| Chat-only demos | Structured callbacks into your own widgets |
check_environment() → verify SDK / CLI / Snowflake connection are ready, without starting an agentrender_start_gate() → shows status, only starts the session after you click "Start"get_or_create_session() → creates/retrieves a CocoSession tied to a Streamlit session keypanel() + chat_input_bar() → renders the streaming transcript and your input, survives Streamlit rerunscopilot_rail() → wraps that panel as a right-rail Copilot (connection, queued jobs, compact transcript) — make tableau-semantic
| Capability | Entry points |
|---|---|
| Native panel + approvals | panel(), chat_input_bar(), render_approvals() |
| Tool cards & AskUser / plan UI | doc/features/tools-display/ |
| Session & options | CocoSession, CocoOptions, get_or_create_session |
| Headless events | query(), CocoSession.stream(), execute_plan() |
| File upload into cwd (0.1.5) | upload_to_cwd(), cwd_uploader() |
| Copilot rail (0.1.6) | copilot_rail(), transcript_view_pills() |
| Legacy CCv2 | chat() |
uv installed~/.snowflake/connections.toml (or CLI default connection)cortex) installed and on PATHDevoteamSP/streamlit-coco-devgit clone https://github.com/DevoteamSP/streamlit-coco-dev.git cd streamlit-coco-dev make install # uv sync --extra dev cortex --version # verify CoCo CLI
~/.snowflake/connections.toml:[connections.analytics] account = "xy12345" user = "you@company.com" authenticator = "externalbrowser"
import streamlit_coco as c; print(c.__version__) prints 0.1.6cortex --version succeedscheck_environment(...).ready is Truemake check passes with no failuresmake chat opens a working app with a streamed response + tool cardmake chat # runs examples/chat_app.py
make structured # runs examples/structured_output.py
def render(data: dict, result: st_coco.CocoChatResult) -> None:
st.dataframe(data.get("selected_features", []))
st_coco.panel(session=session, on_structured_output=render)
import asyncio
import streamlit_coco as coco
async def run():
async for event in coco.query("Profile ANALYTICS.CUSTOMERS"):
if event.type == "result":
print(event.structured_output)
asyncio.run(run()) # or: make headless
streamlit import anywhere — same query(), same event types, works in CI/scriptsopts = st_coco.CocoOptions(
connection="analytics", cwd=".",
allowed_tools=["Read", "Glob", "Grep"],
require_approval_for=["Edit", "Write", "Bash"],
)
env = st_coco.check_environment(connection=opts.connection)
if not st_coco.render_start_gate(opts, session_key="copilot", env=env):
st.stop()
session = st_coco.get_or_create_session(opts, key="copilot")
st_coco.panel(session=session, warm_up=True, show_status=True)
st_coco.chat_input_bar(session, placeholder="Ask CoCo…")
cortex --version succeeds; make check passesexamples/chat_app.py (~20 lines) → run make chat → ask about TPCH_SF1 tablesmake structured → "Give me a breakdown of orders by status" → renders as a chartmake headless → terminal streams events, no browserpip install streamlit-coco[sdk] — 5 minutes to first working appallowed_tools and require_approval_for — don't overlap themcheck_environment() and debugging a stuck session blind — always check readiness first| Does it work with SiS? | Not yet — pure Python, waiting on the CoCo API path; see roadmap. |
| What LLM does it use? | Whatever Cortex Code uses under the hood — no config needed. |
| Can I customize approvals? | Yes — allowed_tools / require_approval_for in CocoOptions. |
| Is it production-ready? | Alpha (0.1.6) — fine for internal tools; production readiness targeted at N1. |
| Vs. the CoCo CLI directly? | This library owns the Streamlit-specific plumbing (session, streaming, cards, approvals) — the CLI alone has none of that. |
setup-guide.mdhands-on-lab.mddemo-script.mdquiz.md
README.md (quickstart)doc/deployment/local.mddoc/api.md · doc/roadmap.mddoc/marketing/demo.md (source of truth for the client demo)
doc/training/quiz.md — score 8/10 or higher and you're considered trained for this asset's N0→N1 gate item.