Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,22 +5,27 @@ from langchain_community.llms import HuggingFaceEndpoint
|
|
| 5 |
#Taking question as input from user
|
| 6 |
def load_answer(question):
|
| 7 |
llm=HuggingFaceEndpoint(repo_id="mistralai/Mistral-7B-Instruct-v0.2")
|
| 8 |
-
answer=llm.invoke(
|
| 9 |
return answer
|
| 10 |
|
| 11 |
-
|
| 12 |
-
st.
|
|
|
|
| 13 |
|
|
|
|
| 14 |
def get_text():
|
| 15 |
-
input_text = st.text_input("
|
| 16 |
return input_text
|
| 17 |
|
| 18 |
|
| 19 |
-
user_input
|
| 20 |
response = load_answer(user_input)
|
| 21 |
|
| 22 |
-
submit = st.button(
|
| 23 |
|
|
|
|
| 24 |
if submit:
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
st.write(response)
|
|
|
|
| 5 |
#Taking question as input from user
|
| 6 |
def load_answer(question):
|
| 7 |
llm=HuggingFaceEndpoint(repo_id="mistralai/Mistral-7B-Instruct-v0.2")
|
| 8 |
+
answer=llm.invoke(question)
|
| 9 |
return answer
|
| 10 |
|
| 11 |
+
#App UI starts here
|
| 12 |
+
st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
|
| 13 |
+
st.header("LangChain Demo")
|
| 14 |
|
| 15 |
+
#Gets the user input
|
| 16 |
def get_text():
|
| 17 |
+
input_text = st.text_input("You: ", key="input")
|
| 18 |
return input_text
|
| 19 |
|
| 20 |
|
| 21 |
+
user_input=get_text()
|
| 22 |
response = load_answer(user_input)
|
| 23 |
|
| 24 |
+
submit = st.button('Generate')
|
| 25 |
|
| 26 |
+
#If generate button is clicked
|
| 27 |
if submit:
|
| 28 |
+
|
| 29 |
+
st.subheader("Answer:")
|
| 30 |
+
|
| 31 |
st.write(response)
|