wop commited on
Commit
0ee1d88
1 Parent(s): b1da779

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -0
app.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+
4
+
5
+ API_URL = "https://api-inference.huggingface.co/models/tiiuae/falcon-7b-instruct"
6
+ headers = {"Authorization": "Bearer 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"}
7
+ API_URL2 = "https://api-inference.huggingface.co/models/valhalla/longformer-base-4096-finetuned-squadv1"
8
+ headers2 = {"Authorization": "Bearer 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"}
9
+ def query(payload):
10
+ response = requests.post(API_URL, headers=headers, json=payload)
11
+ return response.json()
12
+ def query2(payload):
13
+ response = requests.post(API_URL2, headers=headers2, json=payload)
14
+ return response.json()
15
+
16
+ iface = gr.Interface(
17
+ fn=query2,
18
+ inputs=[gr.Textbox("question"), gr.Textbox("context")],
19
+ outputs=gr.Textbox("answer"),
20
+ title="AI Interface",
21
+ description="Ask the AI model anything!",
22
+ )
23
+
24
+ iface.launch()