aquibmoin commited on
Commit
70991a4
·
verified ·
1 Parent(s): 7e6c312

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -11
app.py CHANGED
@@ -5,26 +5,22 @@ 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
- 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",
@@ -35,3 +31,4 @@ demo = gr.Interface(
35
  demo.launch()
36
 
37
 
 
 
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(payload):
 
 
 
9
  response = requests.post(API_URL, headers=headers, json=payload)
10
  return response.json()
11
 
12
  def get_model_output():
13
+ payload = {
14
+ "inputs": "The answer to the universe is <mask>."
15
+ }
16
+ response = query(payload)
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
+ # Define Gradio interface
 
 
 
 
22
  demo = gr.Interface(
23
+ fn=get_model_output,
24
  inputs=[],
25
  outputs="text",
26
  title="Hugging Face Model Output",
 
31
  demo.launch()
32
 
33
 
34
+