Spaces:
Sleeping
Sleeping
Commit
·
a4f4174
1
Parent(s):
0e879ae
Delete doctor.py
Browse files
doctor.py
DELETED
|
@@ -1,49 +0,0 @@
|
|
| 1 |
-
from langchain.chat_models import ChatOpenAI
|
| 2 |
-
from langchain.prompts.chat import ChatPromptTemplate
|
| 3 |
-
from langchain.schema import BaseOutputParser
|
| 4 |
-
|
| 5 |
-
from dotenv import load_dotenv
|
| 6 |
-
from properties import *
|
| 7 |
-
|
| 8 |
-
import streamlit as st
|
| 9 |
-
import os
|
| 10 |
-
|
| 11 |
-
#streamlit UI
|
| 12 |
-
|
| 13 |
-
load_dotenv() # get the environment variable from .env
|
| 14 |
-
print(os.getenv("OPENAI_API_KEY"))
|
| 15 |
-
chatllm=ChatOpenAI(temperature=0.6,model='gpt-3.5-turbo')
|
| 16 |
-
|
| 17 |
-
class NewLineSeparatedOutput(BaseOutputParser):
|
| 18 |
-
def parse(self, text: str):
|
| 19 |
-
lines = text.strip().split("\n")
|
| 20 |
-
return ' '.join(lines)
|
| 21 |
-
|
| 22 |
-
template = "Your are an AI Doctor assistant. A user will give an input of what he is suffering from or what health problem he has, you should suggest the user with correct medicine and tell the user how to recover fastly from it. Gve a short and sharp answer. If the input is different from a body or health issue or any other medical issues, tell the user who you are and ask the user to provide the appropriate input."
|
| 23 |
-
|
| 24 |
-
human_template = "{text}"
|
| 25 |
-
chat_prompt = ChatPromptTemplate.from_messages([
|
| 26 |
-
("system", template),
|
| 27 |
-
("human", human_template)
|
| 28 |
-
])
|
| 29 |
-
|
| 30 |
-
chain = chat_prompt | chatllm | NewLineSeparatedOutput()
|
| 31 |
-
|
| 32 |
-
# Define the Streamlit app
|
| 33 |
-
def main():
|
| 34 |
-
st.title("AI Doctor Assistant")
|
| 35 |
-
|
| 36 |
-
# Get user input
|
| 37 |
-
user_input = st.text_input("Enter your health issue:")
|
| 38 |
-
|
| 39 |
-
# Display a submit button
|
| 40 |
-
if st.button("Submit"):
|
| 41 |
-
# Invoke the chatbot chain when the button is clicked
|
| 42 |
-
output = chain.invoke({"text": user_input})
|
| 43 |
-
|
| 44 |
-
# Display the output
|
| 45 |
-
st.write("AI Doctor Assistant:", output)
|
| 46 |
-
|
| 47 |
-
# Run the Streamlit app
|
| 48 |
-
if __name__ == "__main__":
|
| 49 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|