Skip to content

Commit

Permalink
remove pills; use df instead
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdai committed Jul 25, 2024
1 parent 3ff04f5 commit e23ae7b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 41 deletions.
16 changes: 1 addition & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ llama-index-llms-openai = "^0.1.27"
llama-index-agent-openai = "^0.2.9"
streamlit = "^1.36.0"
llama-agents = {version = "^0.0.12", extras = ["kafka"]}
streamlit-pills = "^0.3.0"

[tool.poetry.group.dev.dependencies]
mypy = "^1.10.1"
Expand Down
46 changes: 21 additions & 25 deletions snowflake_cybersyn_demo/apps/streamlit.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Any, Generator

import pandas as pd
import streamlit as st
from llama_index.core.llms import ChatMessage, ChatResponseGen
from llama_index.llms.openai import OpenAI
from streamlit_pills import pills


def _llama_index_stream_wrapper(
Expand All @@ -28,7 +28,7 @@ def _handle_task_submission() -> None:
st.session_state["completed_pills"] = []


left, middle, right = st.columns([1, 2, 1], vertical_alignment="bottom")
left, right = st.columns([1, 2], vertical_alignment="bottom")

with left:
task_input = st.text_input(
Expand All @@ -38,7 +38,7 @@ def _handle_task_submission() -> None:
on_change=_handle_task_submission,
)

with middle:
with right:
if "messages" not in st.session_state:
st.session_state.messages = []

Expand All @@ -63,25 +63,21 @@ def _handle_task_submission() -> None:
{"role": "assistant", "content": response}
)

with right:
if st.session_state.submitted_pills:
submitted_pills = st.session_state.submitted_pills
submitted = pills(
"Submitted",
options=submitted_pills,
key="selected_submitted",
)

if st.session_state.human_required_pills:
human_required = pills(
"Human Required",
st.session_state.human_required_pills,
key="selected_human_required",
)

if st.session_state.completed_pills:
completed = pills(
"Completed",
st.session_state.completed_pills,
key="selected_completed",
)
bottom = st.container()
with bottom:
st.text("Task Status")
tasks = (
st.session_state.submitted_pills
+ st.session_state.human_required_pills
+ st.session_state.completed_pills
)
status = (
["submitted"] * len(st.session_state.submitted_pills)
+ ["human_required"] * len(st.session_state.human_required_pills)
+ ["completed"] * len(st.session_state.completed_pills)
)
data = {"tasks": tasks, "status": status}
df = pd.DataFrame(data)
st.dataframe(
df, selection_mode="single-row", use_container_width=True
) # Same as st.write(df)

0 comments on commit e23ae7b

Please sign in to comment.