import streamlit as st from streamlit.components.v1 import components import json from dataclasses import dataclass from typing import Literal from utils import Agent agent = Agent() @dataclass class Message: origin: Literal["human", "ai"] message: str confidence:int def load_css(): with open('./static/style.css') as fp: css = f"" st.markdown(css, unsafe_allow_html=True) def initialize_session_state(): if "history" not in st.session_state: st.session_state.history = [] def on_click_call_back(): human_prompt = st.session_state.human_prompt agent_response, confidence = agent.agent_response(human_prompt) st.session_state.history.append(Message(origin='human', message=human_prompt, confidence=None)) st.session_state.history.append(Message(origin='ai', message=agent_response, confidence=confidence)) st.title("Shopping agent Demo 🤖") load_css() initialize_session_state() chat_placeholder = st.container() prompt_placeholder = st.form(key="chat-form ") with chat_placeholder: for chat in st.session_state.history: msg = f"""