-
Notifications
You must be signed in to change notification settings - Fork 209
/
Copy pathbot.py
40 lines (31 loc) · 1.06 KB
/
bot.py
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
import streamlit as st
from utils import write_message
# Page Config
st.set_page_config("Ebert", page_icon=":movie_camera:")
# Set up Session State
if "messages" not in st.session_state:
st.session_state.messages = [
{"role": "assistant", "content": "Hi, I'm the GraphAcademy Chatbot! How can I help you?"},
]
# Submit handler
def handle_submit(message):
"""
Submit handler:
You will modify this method to talk with an LLM and provide
context using data from Neo4j.
"""
# Handle the response
with st.spinner('Thinking...'):
# # TODO: Replace this with a call to your LLM
from time import sleep
sleep(1)
write_message('assistant', message)
# Display messages in Session State
for message in st.session_state.messages:
write_message(message['role'], message['content'], save=False)
# Handle any user input
if question := st.chat_input("What is up?"):
# Display user message in chat message container
write_message('user', question)
# Generate a response
handle_submit(question)