DoHTestApp / app.py
davidfearne's picture
Upload 2 files
90dab6e
raw
history blame
2.31 kB
import streamlit as st
from streamlit_chat import message
import requests
st.set_page_config(layout="wide")
API_URL = "https://virtual-medical-api.greensea-b20be511.northeurope.azurecontainerapps.io/api"
headers = {"Content-Type": "application/json"}
def query(payload):
response = requests.post(API_URL, headers=headers, json=payload)
return response.json()
def generate_response(user,prompt):
output = query({"id":user, "messages":[{"role":user, "content": prompt}]})
return output
#Creating the chatbot interface
st.title("AI Clinical Expert")
st.caption("AI Clinical Expert that asks questions and makes clinical diagnoses is a powerful tool that combines natural language understanding, medical knowledge, and machine learning to assist healthcare professionals in providing accurate and efficient diagnoses and treatment recommendations for patients. It streamlines the diagnostic process, enhances clinical decision-making, and improves patient outcomes while maintaining a strong emphasis on data privacy and collaboration with human experts.")
col1, col2 = st.columns(2)
# Storing the chat
if 'generated' not in st.session_state:
st.session_state['generated'] = []
if 'past' not in st.session_state:
st.session_state['past'] = []
with col1:
with st.form(key='my_form'):
User = st.text_input("What's your name?","", key="user")
input_text = st.text_input("Tell us how you're feeling","", key="input")
submit_button = st.form_submit_button(label='Submit')
if submit_button:
output = generate_response(User,input_text)
# store the output
st.session_state.past.append(input_text)
st.session_state.generated.append(output['res'])
# Layout the columns
button = st.button("Completed", key=None, help="Use this button when you have finished describing your symptoms", on_click=None, args=None)
if st.session_state['generated']:
for i in range(len(st.session_state['generated'])-1, -1, -1):
with col2:
message(st.session_state["generated"][i], key=str(i),avatar_style="identicon",seed="Socks")
message(st.session_state['past'][i], is_user=True, key=str(i) + '_user',avatar_style="identicon",seed="Mittens")