forked from vvrahul11/llm_chatbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstreamlit_app.py
More file actions
35 lines (27 loc) · 1.07 KB
/
streamlit_app.py
File metadata and controls
35 lines (27 loc) · 1.07 KB
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
"""Module to create a chatbot interface, accept user input and generate output"""
import streamlit as st
from streamlit_chat import message
from gpt import generate_response, get_text
st.set_page_config(
page_title="LLM Chatbot"
)
st.header("Biomedical LLM Chatbot")
st.sidebar.header("Instructions")
st.sidebar.info(
'''This is a web application that allows you to interact with an PubMed articles knowledge graph.'''
)
st.sidebar.info('''Enter a query in the text box and press enter
to receive a response''')
if 'generated' not in st.session_state:
st.session_state['generated'] = []
if 'past' not in st.session_state:
st.session_state['past'] = []
user_input = get_text()
if user_input:
output = generate_response(user_input)
st.session_state.past.append(user_input)
st.session_state.generated.append(output)
if st.session_state['generated']:
for i in range(len(st.session_state['generated'])-1, -1, -1):
message(st.session_state["generated"][i], key=str(i))
message(st.session_state['past'][i], is_user=True, key=str(i) + '_user')