File size: 934 Bytes
0ee1d88
 
 
af9ec9a
0ee1d88
 
 
 
f7f5d71
 
af9ec9a
9463770
bb9d070
6e1ab1e
af9ec9a
31267be
a01cd5c
af9ec9a
e64d9b1
 
 
af9ec9a
69e6331
 
0ee1d88
af9ec9a
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
import gradio as gr
import requests


API_URL = "https://api-inference.huggingface.co/models/tiiuae/falcon-7b-instruct"
headers = {"Authorization": "Bearer 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"}
API_URL2 = "https://api-inference.huggingface.co/models/valhalla/longformer-base-4096-finetuned-squadv1"
headers2 = {"Authorization": "Bearer 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"}
def query(q):
    payload2 = "whats the context of the question " + q + " :"
    response = requests.post(API_URL, headers=headers, json=payload2)
    return response #.json() #['answer']
def query2(q, c):
    payload = {"question": q, "context": c}
    response = requests.post(API_URL2, headers=headers2, json=payload)
    return response.json()['answer']

iface = gr.Interface(
    fn=query,
    inputs=[gr.Textbox("question")],
    outputs=gr.Textbox("context"),
    title="AI Interface",
    description="Ask the AI model anything!",
)

iface.launch()