File size: 728 Bytes
592a383
 
 
 
 
 
 
 
 
 
 
 
5465c46
592a383
5465c46
592a383
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
27
28
29
30
31
32
33
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()