File size: 1,040 Bytes
5120311 |
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 34 35 36 37 38 39 40 41 |
import requests
import json
URL_EMBBED_ZH = "http://10.9.3.239:1999/api/v1/extract_feature_zh"
URL_EMBBED_EN = "http://10.9.3.239:1999/api/v1/extract_feature_en"
URL_EMBBED_BGE = "http://10.9.3.240:5045/api/v1/embedding"
def embbeded_zh(text: list):
try:
r = requests.post(URL_EMBBED_ZH, data = json.dumps({
"text": text
}))
embs = r.json()["vectors"]
return embs
except Exception as ve:
print(ve)
return []
def embbeded_en(text: list):
try:
r = requests.post(URL_EMBBED_EN, data = json.dumps({
"text": text
}))
embs = r.json()["vectors"]
return embs
except Exception as ve:
print(ve)
return []
def embedded_bge(text: list):
try:
r = requests.post(URL_EMBBED_BGE, data = json.dumps({
"text": text
}))
embs = r.json()["embeddings"]
return embs
except Exception as ve:
print(ve)
return [] |