Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,44 +3,38 @@ from langchain.llms import HuggingFaceHub
|
|
3 |
from langchain.chains import LLMChain
|
4 |
from langchain.prompts import PromptTemplate
|
5 |
|
6 |
-
#Function to return the response
|
7 |
def generate_answer(query):
|
8 |
llm = HuggingFaceHub(
|
9 |
-
repo_id
|
10 |
-
model_kwargs={"temperature": 0.7, "max_length": 64,"max_new_tokens":512}
|
11 |
)
|
12 |
-
|
13 |
-
template = """Question: {query}
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
17 |
|
18 |
-
prompt= PromptTemplate(template=template, input_variables=["query"])
|
19 |
llm_chain = LLMChain(prompt=prompt, llm=llm)
|
20 |
result = llm_chain.run(query)
|
21 |
return result
|
22 |
-
|
23 |
-
|
24 |
-
#App UI starts here
|
25 |
-
st.set_page_config(page_title = "LangChain Demo", page_icon = ":robot:")
|
26 |
-
st.header("LangChain Demo")
|
27 |
|
|
|
|
|
|
|
28 |
|
29 |
-
#Gets User Input
|
30 |
def get_text():
|
31 |
input_text = st.text_input("You: ", key="input")
|
32 |
return input_text
|
33 |
|
34 |
-
|
35 |
user_input = get_text()
|
36 |
response = generate_answer(user_input)
|
37 |
|
38 |
submit = st.button("Generate")
|
39 |
|
40 |
-
#If the button clicked
|
41 |
if submit:
|
42 |
-
st.subheader("
|
43 |
-
st.write(response)
|
44 |
-
|
45 |
-
|
46 |
-
|
|
|
3 |
from langchain.chains import LLMChain
|
4 |
from langchain.prompts import PromptTemplate
|
5 |
|
6 |
+
# Function to return the response
|
7 |
def generate_answer(query):
|
8 |
llm = HuggingFaceHub(
|
9 |
+
repo_id="google/flan-t5-xxl",
|
10 |
+
model_kwargs={"temperature": 0.7, "max_length": 64, "max_new_tokens": 512}
|
11 |
)
|
|
|
|
|
12 |
|
13 |
+
template = """Patient's Question: {query}
|
14 |
+
|
15 |
+
Doctor's Answer: Let's consider your symptoms. Can you provide more details about your symptoms and how long you've been experiencing them?
|
16 |
+
"""
|
17 |
|
18 |
+
prompt = PromptTemplate(template=template, input_variables=["query"])
|
19 |
llm_chain = LLMChain(prompt=prompt, llm=llm)
|
20 |
result = llm_chain.run(query)
|
21 |
return result
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
+
# App UI starts here
|
24 |
+
st.set_page_config(page_title="Doctor Assistant Demo", page_icon=":robot:")
|
25 |
+
st.header("Doctor Assistant Demo")
|
26 |
|
27 |
+
# Gets User Input
|
28 |
def get_text():
|
29 |
input_text = st.text_input("You: ", key="input")
|
30 |
return input_text
|
31 |
|
|
|
32 |
user_input = get_text()
|
33 |
response = generate_answer(user_input)
|
34 |
|
35 |
submit = st.button("Generate")
|
36 |
|
37 |
+
# If the button clicked
|
38 |
if submit:
|
39 |
+
st.subheader("Doctor's Response:")
|
40 |
+
st.write(response)
|
|
|
|
|
|