First commit
Browse files
app.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import AutoModel, AutoTokenizer
|
3 |
+
|
4 |
+
# Load BioMistral model and tokenizer
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("BioMistral/BioMistral-7B")
|
6 |
+
model = AutoModel.from_pretrained("BioMistral/BioMistral-7B")
|
7 |
+
|
8 |
+
def generate_response(input_text):
|
9 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
10 |
+
outputs = model.generate(**inputs, max_length=200, do_sample=True, top_p=0.95, top_k=50, num_return_sequences=1)
|
11 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
12 |
+
return response
|
13 |
+
|
14 |
+
def main():
|
15 |
+
st.title("Doctor AI App")
|
16 |
+
|
17 |
+
# Get user input
|
18 |
+
symptoms = st.text_area("Enter your symptoms", height=150)
|
19 |
+
medical_history = st.text_area("Enter your medical history", height=150)
|
20 |
+
allergies = st.text_area("Enter your allergies (if any)", height=150)
|
21 |
+
|
22 |
+
if st.button("Get Diagnosis and Recommendations"):
|
23 |
+
# Prepare input for BioMistral
|
24 |
+
input_text = f"Based on the following information:\n\nSymptoms: {symptoms}\nMedical History: {medical_history}\nAllergies: {allergies}\n\nPlease provide a diagnosis and recommend medications or treatments."
|
25 |
+
|
26 |
+
# Generate response using BioMistral
|
27 |
+
response = generate_response(input_text)
|
28 |
+
|
29 |
+
st.write(response)
|
30 |
+
|
31 |
+
if __name__ == "__main__":
|
32 |
+
main()
|