Spaces:
Sleeping
Sleeping
File size: 1,272 Bytes
c9720d8 34047bf c9720d8 34047bf c9720d8 78c8fe7 c9720d8 3bdda07 c9720d8 9ab0242 c9720d8 9ab0242 c9720d8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# import openai
import streamlit as st
from Models import HFAgent
def initMessages():
if "messages" not in st.session_state:
st.session_state["messages"] = [{"role": "assistant", "content": "Hello, Sir. How can I assist you today, Sir?"}]
def showMessages():
for msg in st.session_state.messages:
st.chat_message(msg["role"]).write(msg["content"])
# def sidebar():
# with st.sidebar:
# st.title("Settings")
def appendMessage(role, content):
st.session_state.messages.append({"role": role, "content": content})
def writeMessage(role, content):
st.chat_message(role).write(content)
def generateHFResponse():
if "agent" not in st.session_state:
st.session_state["agent"] = HFAgent.HFAgent()
agent = st.session_state.agent
new_messages = agent(st.session_state.messages)
return new_messages[-1]
def app():
# sidebar()
st.title("🗨️ Chatbot with Stark Model")
initMessages()
showMessages()
if prompt := st.chat_input():
appendMessage("user", prompt)
writeMessage("user", prompt)
msg = generateHFResponse()
appendMessage(msg["role"], msg["content"])
writeMessage(msg["role"], msg["content"])
if __name__ == "__main__":
app() |