Enhance tool normalization and API integration across modules

- Introduced normalization functions for tool statistics and error counts to ensure consistent schema across all trajectory entries, facilitating compatibility with HuggingFace datasets.
- Updated batch processing to utilize normalized tool stats and error counts, improving data integrity.
- Refactored vision tools and mixture of agents tool to integrate with OpenRouter API, replacing Nous Research API references and updating model configurations.
- Enabled reasoning capabilities in API calls for enhanced response quality across various tools.
- Improved error handling and API key validation for OpenRouter integration.
This commit is contained in:
teknium 2026-01-14 13:40:10 +00:00
parent 66daebe88f
commit 13d360030f
6 changed files with 172 additions and 61 deletions

View file

@ -555,9 +555,22 @@ class AIAgent:
"timeout": 600.0 # 10 minute timeout for very long responses
}
# Add provider preferences for OpenRouter via extra_body
# Add extra_body for OpenRouter (provider preferences + reasoning)
extra_body = {}
# Add provider preferences if specified
if provider_preferences:
api_kwargs["extra_body"] = {"provider": provider_preferences}
extra_body["provider"] = provider_preferences
# Enable reasoning with xhigh effort for OpenRouter
if "openrouter" in self.base_url.lower():
extra_body["reasoning"] = {
"enabled": True,
"effort": "xhigh"
}
if extra_body:
api_kwargs["extra_body"] = extra_body
response = self.client.chat.completions.create(**api_kwargs)