Afsha001 commited on
Commit
81617eb
Β·
1 Parent(s): bdb5d8d

fix Qwen endpoint URL and Jina document format

Browse files
Files changed (1) hide show
  1. app.py +4 -12
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/models/Qwen/Qwen2-VL-2B-Instruct/v1/chat/completions"
23
- QWEN_LM_URL = "https://api-inference.huggingface.co/models/Qwen/Qwen2.5-1.5B-Instruct/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,16 +130,8 @@ def compute_jina_scores(image, captions):
130
  try:
131
  payload = {
132
  "model": "jina-reranker-m0",
133
- "query": {
134
- "type" : "text",
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(