Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,44 +1,38 @@
|
|
1 |
import streamlit as st
|
2 |
from langchain.llms import HuggingFaceHub
|
3 |
|
4 |
-
#Function to return the response
|
5 |
def generate_answer(query):
|
6 |
llm = HuggingFaceHub(
|
7 |
-
repo_id
|
8 |
-
model_kwargs={"temperature": 0.5, "max_length": 64,"max_new_tokens":512}
|
9 |
)
|
10 |
prompt = f"""
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
result = llm.predict(prompt)
|
19 |
return result
|
20 |
-
|
21 |
|
22 |
-
#App UI starts here
|
23 |
-
st.set_page_config(page_title
|
24 |
st.header("LangChain Demo")
|
25 |
|
26 |
-
|
27 |
-
#Gets User Input
|
28 |
def get_text():
|
29 |
input_text = st.text_input("You: ", key="input")
|
30 |
return input_text
|
31 |
|
32 |
-
|
33 |
user_input = get_text()
|
34 |
response = generate_answer(user_input)
|
35 |
|
36 |
submit = st.button("Generate")
|
37 |
|
38 |
-
#If the button clicked
|
39 |
if submit:
|
40 |
-
st.subheader("Answer:
|
41 |
-
st.write(response)
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
1 |
import streamlit as st
|
2 |
from langchain.llms import HuggingFaceHub
|
3 |
|
4 |
+
# Function to return the response
|
5 |
def generate_answer(query):
|
6 |
llm = HuggingFaceHub(
|
7 |
+
repo_id="TheBloke/goliath-120b-GGUF",
|
8 |
+
model_kwargs={"temperature": 0.5, "max_length": 64, "max_new_tokens": 512}
|
9 |
)
|
10 |
prompt = f"""
|
11 |
+
You are a helpful AI assistant.
|
12 |
+
|
13 |
+
USER:
|
14 |
+
{query}
|
15 |
+
|
16 |
+
ASSISTANT:
|
17 |
+
"""
|
18 |
result = llm.predict(prompt)
|
19 |
return result
|
|
|
20 |
|
21 |
+
# App UI starts here
|
22 |
+
st.set_page_config(page_title="LangChain Demo", page_icon=":robot:")
|
23 |
st.header("LangChain Demo")
|
24 |
|
25 |
+
# Gets User Input
|
|
|
26 |
def get_text():
|
27 |
input_text = st.text_input("You: ", key="input")
|
28 |
return input_text
|
29 |
|
|
|
30 |
user_input = get_text()
|
31 |
response = generate_answer(user_input)
|
32 |
|
33 |
submit = st.button("Generate")
|
34 |
|
35 |
+
# If the button is clicked
|
36 |
if submit:
|
37 |
+
st.subheader("Answer:")
|
38 |
+
st.write(response)
|
|
|
|
|
|