MuhammadSaad1234 commited on
Commit
e30e36a
·
0 Parent(s):

General health chatbot

Browse files
Files changed (2) hide show
  1. app.py +31 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ from huggingface_hub import InferenceClient
4
+
5
+ st.title("🩺 Health Assistant AI")
6
+ st.caption("A helpful medical information chatbot")
7
+
8
+ HF_TOKEN = st.secrets["HF_TOKEN"]
9
+ client = InferenceClient(api_key=HF_TOKEN)
10
+
11
+ if "messages" not in st.session_state:
12
+ st.session_state.messages = [{"role": "system", "content": "You are a helpful medical assistant. Always include a disclaimer."}]
13
+
14
+ for message in st.session_state.messages[1:]:
15
+ with st.chat_message(message["role"]):
16
+ st.markdown(message["content"])
17
+
18
+ if prompt := st.chat_input("How can I help you today?"):
19
+ st.session_state.messages.append({"role": "user", "content": prompt})
20
+ with st.chat_message("user"):
21
+ st.markdown(prompt)
22
+
23
+ with st.chat_message("assistant"):
24
+ response = client.chat.completions.create(
25
+ model="Qwen/Qwen2.5-72B-Instruct",
26
+ messages=st.session_state.messages,
27
+ max_tokens=500
28
+ )
29
+ full_response = response.choices[0].message.content
30
+ st.markdown(full_response)
31
+ st.session_state.messages.append({"role": "assistant", "content": full_response})
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ huggingface-hub