m-ric HF Staff commited on
Commit
5749cc3
·
1 Parent(s): e165edc

Clarify logs

Browse files
Files changed (1) hide show
  1. e2bqwen.py +18 -26
e2bqwen.py CHANGED
@@ -113,7 +113,6 @@ class E2BVisionAgent(CodeAgent):
113
  # Set up temp directory
114
  os.makedirs(self.data_dir, exist_ok=True)
115
  print(f"Screenshots and steps will be saved to: {self.data_dir}")
116
- print(f"Verbosity level set to {verbosity_level}")
117
 
118
  # Initialize base agent
119
  super().__init__(
@@ -133,11 +132,9 @@ class E2BVisionAgent(CodeAgent):
133
 
134
 
135
  # Add default tools
136
- self._setup_desktop_tools()
137
  self.logger.log("Setting up agent tools...")
 
138
  self.step_callbacks.append(self.take_screenshot_callback)
139
- self.logger.log("Studying an action plan... that will take a bit.")
140
-
141
  self.final_answer_checks = [self.store_metadata_to_file]
142
 
143
  def _setup_desktop_tools(self):
@@ -316,7 +313,6 @@ class E2BVisionAgent(CodeAgent):
316
  self.logger.log(self.log_path, "Analyzing screen content...")
317
 
318
  current_step = memory_step.step_number
319
- print(f"Taking screenshot for step {current_step}")
320
 
321
  time.sleep(2.0) # Let things happen on the desktop
322
  screenshot_bytes = self.desktop.screenshot()
@@ -325,7 +321,7 @@ class E2BVisionAgent(CodeAgent):
325
  # Create a filename with step number
326
  screenshot_path = os.path.join(self.data_dir, f"step_{current_step:03d}.png")
327
  image.save(screenshot_path)
328
- print(f"Saved screenshot to {screenshot_path}")
329
 
330
  for (
331
  previous_memory_step
@@ -345,10 +341,8 @@ class E2BVisionAgent(CodeAgent):
345
  def close(self):
346
  """Clean up resources"""
347
  if self.desktop:
348
- print("Stopping e2b stream...")
349
  self.desktop.stream.stop()
350
-
351
- print("Killing e2b sandbox...")
352
  self.desktop.kill()
353
  print("E2B sandbox terminated")
354
 
@@ -460,12 +454,11 @@ class QwenVLAPIModel(Model):
460
 
461
  # Initialize HF OpenAI-compatible client if token is provided
462
  self.hf_client = None
463
- if hf_token:
464
- from openai import OpenAI
465
- self.hf_client = OpenAI(
466
- base_url=self.hf_base_url + "/v1/",
467
- api_key=self.hf_token
468
- )
469
 
470
  def __call__(
471
  self,
@@ -479,17 +472,16 @@ class QwenVLAPIModel(Model):
479
  formatted_messages = self._format_messages(messages)
480
 
481
  # First try the HF endpoint if available - THIS ALWAYS FAILS SO SKIPPING
482
- # if self.hf_client:
483
- # try:
484
- # completion = self._call_hf_endpoint(
485
- # formatted_messages,
486
- # stop_sequences,
487
- # **kwargs
488
- # )
489
- # return ChatMessage(role=MessageRole.ASSISTANT, content=completion)
490
- # except Exception as e:
491
- # print(f"HF endpoint failed with error: {e}. Falling back to hyperbolic.")
492
- # # Continue to fallback
493
 
494
  # Fallback to hyperbolic
495
  try:
 
113
  # Set up temp directory
114
  os.makedirs(self.data_dir, exist_ok=True)
115
  print(f"Screenshots and steps will be saved to: {self.data_dir}")
 
116
 
117
  # Initialize base agent
118
  super().__init__(
 
132
 
133
 
134
  # Add default tools
 
135
  self.logger.log("Setting up agent tools...")
136
+ self._setup_desktop_tools()
137
  self.step_callbacks.append(self.take_screenshot_callback)
 
 
138
  self.final_answer_checks = [self.store_metadata_to_file]
139
 
140
  def _setup_desktop_tools(self):
 
313
  self.logger.log(self.log_path, "Analyzing screen content...")
314
 
315
  current_step = memory_step.step_number
 
316
 
317
  time.sleep(2.0) # Let things happen on the desktop
318
  screenshot_bytes = self.desktop.screenshot()
 
321
  # Create a filename with step number
322
  screenshot_path = os.path.join(self.data_dir, f"step_{current_step:03d}.png")
323
  image.save(screenshot_path)
324
+ print(f"Saved screenshot for step {current_step} to {screenshot_path}")
325
 
326
  for (
327
  previous_memory_step
 
341
  def close(self):
342
  """Clean up resources"""
343
  if self.desktop:
344
+ print("Stopping e2b stream and killing sandbox...")
345
  self.desktop.stream.stop()
 
 
346
  self.desktop.kill()
347
  print("E2B sandbox terminated")
348
 
 
454
 
455
  # Initialize HF OpenAI-compatible client if token is provided
456
  self.hf_client = None
457
+ from openai import OpenAI
458
+ self.hf_client = OpenAI(
459
+ base_url=self.hf_base_url + "/v1/",
460
+ api_key=self.hf_token
461
+ )
 
462
 
463
  def __call__(
464
  self,
 
472
  formatted_messages = self._format_messages(messages)
473
 
474
  # First try the HF endpoint if available - THIS ALWAYS FAILS SO SKIPPING
475
+ try:
476
+ completion = self._call_hf_endpoint(
477
+ formatted_messages,
478
+ stop_sequences,
479
+ **kwargs
480
+ )
481
+ return ChatMessage(role=MessageRole.ASSISTANT, content=completion)
482
+ except Exception as e:
483
+ print(f"HF endpoint failed with error: {e}. Falling back to hyperbolic.")
484
+ # Continue to fallback
 
485
 
486
  # Fallback to hyperbolic
487
  try: