import json import requests import gradio as gr import typesense from urllib.parse import quote import os def getWordVec(content): content=quote(content,'utf-8') #print(content) xurl=os.getenv("emburl") print(xurl) url=xurl +content #print(url) response = requests.get(url) jsonar=json.loads(response.text).get("embed") #print(len(jsonar)) return jsonar typesenseserver=os.getenv("typesenseserver") typesenseport=os.getenv("typesenseport") typesensekey=os.getenv("typesensekey") typesensecolname=os.getenv("typesensecolname") confignode={} confignode['host']=typesenseserver confignode['port']=typesenseport confignode['protocol']='http' nodes=[] nodes.append(confignode) nodeconfig={} nodeconfig["nodes"]=nodes nodeconfig["api_key"]=typesensekey print(nodeconfig) client = typesense.Client(nodeconfig) def queryimgage(text): html="
img | \score | \
---|---|
\ | "+ str(score)+" | " html=html+"