File size: 1,160 Bytes
dfbe641
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import numpy as np
import requests
import streamlit as st

def main():
    st.title("Scientific Question Generation")

    API_URL = "https://api-inference.huggingface.co/models/dhmeltzer/bart-large_askscience-qg"
    headers = {"Authorization": "Bearer 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"}

    def query(payload):
        response = requests.post(API_URL, 
                                 headers=headers, 
                                 json=payload)
        return response.json()
    
    # User search
    user_input = st.text_area("Question Generator", 
                              """Black holes are the most \
                                gravitationally dense objects in the universe.""")

    # Filters
    st.sidebar.markdown("**Filters**")

    temperature = st.sidebar.slider("Temperature", 0.0, 1.0, 0.0,.1)
    num_results = st.sidebar.slider("Number of search results", 1, 50, 1)

    vector = query([user_input])

    if user_input:

        output = query({
	        "inputs": user_input,
            "temperature":temperature,
            "wait_for_model":True})

        st.write(output)


if __name__ == "__main__":
    main()