Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,36 +5,33 @@ import requests
|
|
5 |
API_URL = "https://api-inference.huggingface.co/models/nasa-impact/nasa-smd-ibm-v0.1"
|
6 |
headers = {"Authorization": "Bearer HF_TOKEN"}
|
7 |
|
8 |
-
def query_huggingface(
|
9 |
-
response = requests.post(API_URL, headers=headers, json=payload)
|
10 |
-
return response.json()
|
11 |
-
|
12 |
-
# Function to generate response
|
13 |
-
def generate_response(user_message):
|
14 |
payload = {
|
15 |
-
"inputs":
|
16 |
}
|
|
|
|
|
17 |
|
18 |
-
|
|
|
|
|
19 |
output = response.get('generated_text', 'No response') # Adjust according to the model's response format
|
20 |
-
|
21 |
return output
|
22 |
|
23 |
# Gradio interface
|
24 |
-
def gradio_interface(
|
25 |
-
|
26 |
-
history.append((user_message, response))
|
27 |
-
return history, history
|
28 |
|
29 |
# Define Gradio blocks
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
# Launch the interface
|
39 |
demo.launch()
|
40 |
|
|
|
|
5 |
API_URL = "https://api-inference.huggingface.co/models/nasa-impact/nasa-smd-ibm-v0.1"
|
6 |
headers = {"Authorization": "Bearer HF_TOKEN"}
|
7 |
|
8 |
+
def query_huggingface():
|
|
|
|
|
|
|
|
|
|
|
9 |
payload = {
|
10 |
+
"inputs": "The answer to the universe is <mask>."
|
11 |
}
|
12 |
+
response = requests.post(API_URL, headers=headers, json=payload)
|
13 |
+
return response.json()
|
14 |
|
15 |
+
def get_model_output():
|
16 |
+
response = query_huggingface()
|
17 |
+
# Extract the output from the response
|
18 |
output = response.get('generated_text', 'No response') # Adjust according to the model's response format
|
|
|
19 |
return output
|
20 |
|
21 |
# Gradio interface
|
22 |
+
def gradio_interface():
|
23 |
+
return get_model_output()
|
|
|
|
|
24 |
|
25 |
# Define Gradio blocks
|
26 |
+
demo = gr.Interface(
|
27 |
+
fn=gradio_interface,
|
28 |
+
inputs=[],
|
29 |
+
outputs="text",
|
30 |
+
title="Hugging Face Model Output",
|
31 |
+
description="Feed a hard-coded input to the model and get the output."
|
32 |
+
)
|
33 |
|
34 |
# Launch the interface
|
35 |
demo.launch()
|
36 |
|
37 |
+
|