keithhon's picture
Update app.py
5465c46
raw
history blame contribute delete
728 Bytes
import requests
import json
import gradio as gr
url = "https://demo-cas.jina.ai:8443/post"
headers = {
'Content-Type': 'application/json'
}
def rank(uri, options):
matches = []
for option in options:
matches.append({"text": option})
payload = json.dumps({
"data": [
{
"uri": uri,
"matches": matches
}
],
"execEndpoint": "/rank"
})
response = requests.request("POST", url, headers=headers, data=payload)
return response.text
examples = [["https://picsum.photos/id/102/300/300", "three berry, four berries, ten berries"]]
iface = gr.Interface(fn=rank, inputs=["text", "text"], outputs="text", examples=examples)
iface.launch()