Spaces:
Paused
Paused
Commit
·
4e62a86
1
Parent(s):
7a692a6
why aren't you working
Browse files
web2json/__pycache__/ai_extractor.cpython-311.pyc
CHANGED
|
Binary files a/web2json/__pycache__/ai_extractor.cpython-311.pyc and b/web2json/__pycache__/ai_extractor.cpython-311.pyc differ
|
|
|
web2json/ai_extractor.py
CHANGED
|
@@ -224,7 +224,7 @@ class NvidiaLLMClient(LLMClient):
|
|
| 224 |
"""
|
| 225 |
self.model_name = model_name
|
| 226 |
|
| 227 |
-
@retry_on_ratelimit(max_retries=
|
| 228 |
def call_api(self, prompt: str) -> str:
|
| 229 |
"""
|
| 230 |
Call the NVIDIA API with the given prompt (non-streaming).
|
|
@@ -241,7 +241,8 @@ class NvidiaLLMClient(LLMClient):
|
|
| 241 |
messages=[{"role": "user", "content": prompt}],
|
| 242 |
temperature=self.temperature,
|
| 243 |
top_p=self.top_p,
|
| 244 |
-
max_tokens=self.max_tokens
|
|
|
|
| 245 |
# stream is omitted (defaults to False)
|
| 246 |
)
|
| 247 |
# print("DONE")
|
|
@@ -262,6 +263,7 @@ class NvidiaLLMClient(LLMClient):
|
|
| 262 |
idx = futures[fut]
|
| 263 |
try:
|
| 264 |
results[idx] = fut.result()
|
|
|
|
| 265 |
except RateLimitError:
|
| 266 |
# You could set results[idx] = None or a default string
|
| 267 |
results[idx] = f"<failed after retries>"
|
|
@@ -367,6 +369,7 @@ class ModalRerankerClient(RerankerClient):
|
|
| 367 |
scores = np.array([p["score"] for p in ranked], dtype=float)
|
| 368 |
# Max normalization
|
| 369 |
max_score = scores.max() if len(scores) > 0 else 1.0
|
|
|
|
| 370 |
if max_score == 0:
|
| 371 |
norm_scores = np.zeros_like(scores)
|
| 372 |
else:
|
|
@@ -381,6 +384,7 @@ class ModalRerankerClient(RerankerClient):
|
|
| 381 |
for p, norm in filtered
|
| 382 |
]
|
| 383 |
|
|
|
|
| 384 |
|
| 385 |
return docs
|
| 386 |
|
|
|
|
| 224 |
"""
|
| 225 |
self.model_name = model_name
|
| 226 |
|
| 227 |
+
@retry_on_ratelimit(max_retries=20, base_delay=0.5, max_delay=5.0)
|
| 228 |
def call_api(self, prompt: str) -> str:
|
| 229 |
"""
|
| 230 |
Call the NVIDIA API with the given prompt (non-streaming).
|
|
|
|
| 241 |
messages=[{"role": "user", "content": prompt}],
|
| 242 |
temperature=self.temperature,
|
| 243 |
top_p=self.top_p,
|
| 244 |
+
max_tokens=self.max_tokens,
|
| 245 |
+
extra_body={"chat_template_kwargs": {"thinking":True}},
|
| 246 |
# stream is omitted (defaults to False)
|
| 247 |
)
|
| 248 |
# print("DONE")
|
|
|
|
| 263 |
idx = futures[fut]
|
| 264 |
try:
|
| 265 |
results[idx] = fut.result()
|
| 266 |
+
print("DONE")
|
| 267 |
except RateLimitError:
|
| 268 |
# You could set results[idx] = None or a default string
|
| 269 |
results[idx] = f"<failed after retries>"
|
|
|
|
| 369 |
scores = np.array([p["score"] for p in ranked], dtype=float)
|
| 370 |
# Max normalization
|
| 371 |
max_score = scores.max() if len(scores) > 0 else 1.0
|
| 372 |
+
# max_score = 1
|
| 373 |
if max_score == 0:
|
| 374 |
norm_scores = np.zeros_like(scores)
|
| 375 |
else:
|
|
|
|
| 384 |
for p, norm in filtered
|
| 385 |
]
|
| 386 |
|
| 387 |
+
# docs.reverse()
|
| 388 |
|
| 389 |
return docs
|
| 390 |
|