Spaces:
Runtime error
Runtime error
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() | |