Update e2bqwen.py
Browse files- e2bqwen.py +1 -41
e2bqwen.py
CHANGED
|
@@ -456,44 +456,4 @@ class E2BVisionAgent(CodeAgent):
|
|
| 456 |
print("Stopping e2b stream and killing sandbox...")
|
| 457 |
self.desktop.stream.stop()
|
| 458 |
self.desktop.kill()
|
| 459 |
-
print("E2B sandbox terminated")
|
| 460 |
-
|
| 461 |
-
|
| 462 |
-
class QwenVLAPIModel(Model):
|
| 463 |
-
"""Model wrapper for Qwen2.5VL API with fallback mechanism"""
|
| 464 |
-
|
| 465 |
-
def __init__(
|
| 466 |
-
self,
|
| 467 |
-
model_id: str = "Qwen/Qwen2.5-VL-72B-Instruct",
|
| 468 |
-
hf_token: str = None,
|
| 469 |
-
):
|
| 470 |
-
super().__init__()
|
| 471 |
-
self.model_id = model_id
|
| 472 |
-
self.base_model = HfApiModel(
|
| 473 |
-
model_id="https://n5wr7lfx6wp94tvl.us-east-1.aws.endpoints.huggingface.cloud",
|
| 474 |
-
token=hf_token,
|
| 475 |
-
max_tokens=4096,
|
| 476 |
-
)
|
| 477 |
-
self.fallback_model = HfApiModel(
|
| 478 |
-
model_id="https://ahbeihft09ulicbf.us-east-1.aws.endpoints.huggingface.cloud",
|
| 479 |
-
token=hf_token,
|
| 480 |
-
max_tokens=4096,
|
| 481 |
-
)
|
| 482 |
-
|
| 483 |
-
def __call__(
|
| 484 |
-
self,
|
| 485 |
-
messages: List[Dict[str, Any]],
|
| 486 |
-
stop_sequences: Optional[List[str]] = None,
|
| 487 |
-
**kwargs,
|
| 488 |
-
) -> ChatMessage:
|
| 489 |
-
try:
|
| 490 |
-
message = self.base_model(messages, stop_sequences, **kwargs)
|
| 491 |
-
return message
|
| 492 |
-
except Exception as e:
|
| 493 |
-
print(f"Base model failed with error: {e}. Calling fallback model.")
|
| 494 |
-
# Continue to fallback
|
| 495 |
-
try:
|
| 496 |
-
message = self.fallback_model(messages, stop_sequences, **kwargs)
|
| 497 |
-
return message
|
| 498 |
-
except Exception as e:
|
| 499 |
-
raise Exception(f"Both endpoints failed. Last error: {e}")
|
|
|
|
| 456 |
print("Stopping e2b stream and killing sandbox...")
|
| 457 |
self.desktop.stream.stop()
|
| 458 |
self.desktop.kill()
|
| 459 |
+
print("E2B sandbox terminated")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|