File size: 622 Bytes
8aca0aa
 
 
182730a
8aca0aa
 
 
 
 
 
 
 
 
 
 
 
 
182730a
8aca0aa
182730a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
API_TOKEN = os.getenv('API_TOKEN')

import gradio as gr
import requests

API_URL = "https://api-inference.huggingface.co/models/tlkh/flan-t5-paraphrase-classify-explain"
headers = {"Authorization": f"Bearer {API_TOKEN}"}

def query(payload):
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.json()

def infer(s1, s2):
    model_input = "Classify and explain the relationship between this pair of sentences: <S1> "+s1+" </S1><S2> "+s2+" </S2>"
    data = query(payload)
    return data

demo = gr.Interface(fn=infer, inputs=["text", "text"], outputs="text")

demo.launch()