Feat/monitor (#254)
* feat: add claude support * feat: add script for end-to-end evaluation with logging and task distribution * feat&fix: add tool result handling and update model default in evaluation script * chore: remove run_test_env.py script * feat&fix: implement action parsing for tool calls and update default action space * fix: update text formatting in action parsing and replace logger import * feat&fix: implement action parsing for tool calls and add screen size handling * feat: add setup instructions for Anthropic API integration * feat: add notice about image size limitations for Anthropic API * Delete test_env/logger.py * Delete test_env/utils.py * fix: update logger usage to use global logger and improve error handling * feat&fix: add configuration management API endpoints and update UI for configuration selection * feat&fix: update environment configuration, enhance task statistics, and improve UI responsiveness * feat&fix: add configuration toggle button in UI and improve task loading performance * feat&fix: add accuracy percentage display to score and style updates for UI
This commit is contained in:
@@ -369,9 +369,10 @@ class AnthropicAgent:
|
||||
)
|
||||
|
||||
except (APIError, APIStatusError, APIResponseValidationError) as e:
|
||||
self.logger.exception(f"Anthropic API error: {str(e)}")
|
||||
logger.exception(f"Anthropic API error: {str(e)}")
|
||||
try:
|
||||
self.logger.warning("Retrying with backup API key...")
|
||||
logger.warning("Retrying with backup API key...")
|
||||
|
||||
backup_client = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY_BACKUP"), max_retries=4)
|
||||
|
||||
if self.model_name == "claude-3-7-sonnet-20250219" or self.model_name == "claude-4-opus-20250514" or self.model_name == "claude-4-sonnet-20250514":
|
||||
@@ -393,13 +394,13 @@ class AnthropicAgent:
|
||||
tools=tools,
|
||||
betas=betas,
|
||||
)
|
||||
self.logger.info("Successfully used backup API key")
|
||||
logger.info("Successfully used backup API key")
|
||||
except Exception as backup_e:
|
||||
self.logger.exception(f"Backup API call also failed: {str(backup_e)}")
|
||||
logger.exception(f"Backup API call also failed: {str(backup_e)}")
|
||||
return None, None
|
||||
|
||||
except Exception as e:
|
||||
self.logger.exception(f"Error in Anthropic API: {str(e)}")
|
||||
logger.exception(f"Error in Anthropic API: {str(e)}")
|
||||
return None, None
|
||||
|
||||
response_params = _response_to_params(response)
|
||||
@@ -434,9 +435,15 @@ class AnthropicAgent:
|
||||
actions = ["DONE"]
|
||||
return reasonings, actions
|
||||
|
||||
def reset(self, *args, **kwargs):
|
||||
def reset(self, _logger = None, *args, **kwargs):
|
||||
"""
|
||||
Reset the agent's state.
|
||||
"""
|
||||
global logger
|
||||
if _logger:
|
||||
logger = _logger
|
||||
else:
|
||||
logger = logging.getLogger("desktopenv.agent")
|
||||
self.messages = []
|
||||
self.logger.info(f"{self.class_name} reset.")
|
||||
logger.info(f"{self.class_name} reset.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user