一键导入
add-webapp-page
Step-by-step procedure to create a new Streamlit page in a genai-tk project and register it in the webapp navigation.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Step-by-step procedure to create a new Streamlit page in a genai-tk project and register it in the webapp navigation.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Build or modify LangChain, DeepAgent, DeerFlow profiles, agent tools, middleware, checkpointing, skills wiring, and the shared harness layer in genai-tk.
Work on BAML structured extraction, BAML CLI commands, processors, utilities, and Prefect BAML workflow integration in genai-tk.
Work on browser automation, sandbox browser tools, direct Playwright tools, AioSandbox backend, and sandbox CLI support in genai-tk.
Add or modify genai-tk Typer CLI commands, dynamic command registration, project scaffolding, and generated Copilot/agent support files.
Work on genai-tk OmegaConf configuration, profiles, overrides, env substitution, and config discovery. Use when editing config/*.yaml or genai_tk.config_mgmt.config_mngr.
Work on core LLM, embeddings, vector store, provider, cache, prompt, and retriever factories in genai-tk. Use when editing genai_tk/core or provider configuration.
| name | add-webapp-page |
| description | Step-by-step procedure to create a new Streamlit page in a genai-tk project and register it in the webapp navigation. |
Follow these steps to add a new Streamlit page to a genai-tk project.
cli init (has config/webapp.yaml)<package>/webapp/pages/ directoryCreate a new file in <package>/webapp/pages/demos/my_page.py:
"""My custom Streamlit page."""
import streamlit as st
from streamlit import session_state as sss
from genai_tk.core.factories.llm_factory import get_llm
from genai_tk.webapp.ui_components.llm_selector import render_llm_selector
st.set_page_config(page_title="My Page", page_icon="🔧", layout="wide")
st.title("🔧 My Page")
st.caption("Description of what this page does")
# ── Sidebar ─────────────────────────────────────────────────────────────
with st.sidebar:
llm_id = render_llm_selector(key="my_page_llm")
# ── Main content ────────────────────────────────────────────────────────
if "my_messages" not in sss:
sss.my_messages = []
# Display existing messages
for msg in sss.my_messages:
with st.chat_message(msg["role"]):
st.markdown(msg["content"])
# Chat input
if prompt := st.chat_input("Ask me anything..."):
sss.my_messages.append({"role": "user", "content": prompt})
with st.chat_message("user"):
st.markdown(prompt)
with st.chat_message("assistant"):
with st.spinner("Thinking..."):
llm = get_llm(llm_id or "default")
result = llm.invoke(prompt)
answer = result.content
st.markdown(answer)
sss.my_messages.append({"role": "assistant", "content": answer})
Edit config/webapp.yaml to add the page to navigation:
ui:
pages_dir: <package_name>/webapp/pages
navigation:
demos:
- demos/my_page.py
# ... other pages ...
settings:
- settings/configuration.py
just webapp
# Navigate to the new page in the sidebar
st.set_page_config() at the top of each pagerender_llm_selector() for model selection in sidebarstreamlit.session_state (aliased as sss) for state persistencelanggraph.prebuilt.create_react_agent() with toolsst.chat_message() and st.chat_input()genai_tk:// prefix in navigationfrom genai_tk.webapp.ui_components.llm_selector import render_llm_selector
from genai_tk.webapp.ui_components.agent_layout import render_agent_sidebar
from genai_tk.webapp.ui_components.message_renderer import render_message_with_mermaid
# For agent pages: build a BaseHarness (LangChainHarness / DeerFlowHarness or
# create_harness(profile_key)) and render it with the shared workbench —
# see docs/harness.md and the built-in reAct_agent.py / deer_flow_agent.py pages.
from genai_tk.agents.harness import create_harness
from genai_tk.webapp.ui_components.harness_workbench import (
render_trace_panel,
render_artifact,
render_artifact_gallery,
stream_harness_turn,
)