Spaces:
Running
Running
fix Qwen endpoint URL and Jina document format
Browse files
app.py
CHANGED
|
@@ -19,8 +19,8 @@ JINA_KEY = os.environ.get("JINA_KEY", "")
|
|
| 19 |
DEVICE = "cpu"
|
| 20 |
|
| 21 |
# ββ Correct API endpoints ββ
|
| 22 |
-
QWEN_VL_URL = "https://api-inference.huggingface.co/
|
| 23 |
-
QWEN_LM_URL = "https://api-inference.huggingface.co/
|
| 24 |
JINA_URL = "https://api.jina.ai/v1/rerank"
|
| 25 |
HF_HEADERS = {"Authorization": "Bearer " + HF_TOKEN, "Content-Type": "application/json"}
|
| 26 |
JINA_HEADERS = {"Authorization": "Bearer " + JINA_KEY, "Content-Type": "application/json"}
|
|
@@ -130,16 +130,8 @@ def compute_jina_scores(image, captions):
|
|
| 130 |
try:
|
| 131 |
payload = {
|
| 132 |
"model": "jina-reranker-m0",
|
| 133 |
-
"query":
|
| 134 |
-
|
| 135 |
-
"text" : cap
|
| 136 |
-
},
|
| 137 |
-
"documents": [
|
| 138 |
-
{
|
| 139 |
-
"type" : "image_url",
|
| 140 |
-
"image_url": {"url": "data:image/jpeg;base64," + img_b64}
|
| 141 |
-
}
|
| 142 |
-
],
|
| 143 |
"top_n": 1
|
| 144 |
}
|
| 145 |
response = requests.post(
|
|
|
|
| 19 |
DEVICE = "cpu"
|
| 20 |
|
| 21 |
# ββ Correct API endpoints ββ
|
| 22 |
+
QWEN_VL_URL = "https://api-inference.huggingface.co/v1/chat/completions"
|
| 23 |
+
QWEN_LM_URL = "https://api-inference.huggingface.co/v1/chat/completions"
|
| 24 |
JINA_URL = "https://api.jina.ai/v1/rerank"
|
| 25 |
HF_HEADERS = {"Authorization": "Bearer " + HF_TOKEN, "Content-Type": "application/json"}
|
| 26 |
JINA_HEADERS = {"Authorization": "Bearer " + JINA_KEY, "Content-Type": "application/json"}
|
|
|
|
| 130 |
try:
|
| 131 |
payload = {
|
| 132 |
"model": "jina-reranker-m0",
|
| 133 |
+
"query": cap,
|
| 134 |
+
"documents": ["data:image/jpeg;base64," + img_b64],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
"top_n": 1
|
| 136 |
}
|
| 137 |
response = requests.post(
|