Spaces:
Sleeping
Sleeping
davidm
commited on
Commit
•
27ee478
1
Parent(s):
a5c1cf7
remove main
Browse files
app.py
CHANGED
@@ -2,40 +2,39 @@ import numpy as np
|
|
2 |
import requests
|
3 |
import streamlit as st
|
4 |
|
5 |
-
def main():
|
6 |
-
|
7 |
|
8 |
-
|
9 |
-
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
# User search
|
18 |
-
user_input = st.text_area("Question Generator",
|
19 |
-
"""Black holes are the most \
|
20 |
-
gravitationally dense objects in the universe.""")
|
21 |
|
22 |
-
|
23 |
-
|
|
|
24 |
|
25 |
-
|
26 |
-
|
27 |
|
28 |
-
|
|
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
"inputs": user_input,
|
34 |
-
"temperature":temperature,
|
35 |
-
"wait_for_model":True})
|
36 |
|
37 |
-
|
|
|
|
|
|
|
38 |
|
|
|
39 |
|
40 |
-
|
41 |
-
|
|
|
|
2 |
import requests
|
3 |
import streamlit as st
|
4 |
|
5 |
+
#def main():
|
6 |
+
st.title("Scientific Question Generation")
|
7 |
|
8 |
+
API_URL = "https://api-inference.huggingface.co/models/dhmeltzer/bart-large_askscience-qg"
|
9 |
+
headers = {"Authorization": "Bearer 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"}
|
10 |
|
11 |
+
def query(payload):
|
12 |
+
response = requests.post(API_URL,
|
13 |
+
headers=headers,
|
14 |
+
json=payload)
|
15 |
+
return response.json()
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
# User search
|
18 |
+
user_input = st.text_area("Question Generator",
|
19 |
+
"""Black holes are the most gravitationally dense objects in the universe.""")
|
20 |
|
21 |
+
# Filters
|
22 |
+
st.sidebar.markdown("**Filters**")
|
23 |
|
24 |
+
temperature = st.sidebar.slider("Temperature", 0.0, 1.0, 0.0,.1)
|
25 |
+
num_results = st.sidebar.slider("Number of search results", 1, 50, 1)
|
26 |
|
27 |
+
vector = query([user_input])
|
28 |
|
29 |
+
if user_input:
|
|
|
|
|
|
|
30 |
|
31 |
+
output = query({
|
32 |
+
"inputs": user_input,
|
33 |
+
"temperature":temperature,
|
34 |
+
"wait_for_model":True})
|
35 |
|
36 |
+
st.write(output)
|
37 |
|
38 |
+
|
39 |
+
#if __name__ == "__main__":
|
40 |
+
# main()
|