From 048ebf90bf83b728b7d9e89ae1f46b213835d0ae Mon Sep 17 00:00:00 2001 From: Fahad Date: Fri, 13 Jun 2025 16:05:21 +0400 Subject: [PATCH] Cleanup --- conf/custom_models.json | 20 +++++++++++++++++++- providers/base.py | 4 +--- providers/openai_compatible.py | 6 ++---- providers/openrouter_registry.py | 2 +- simulator_tests/base_test.py | 6 +++++- tests/test_claude_continuation.py | 2 +- tests/test_collaboration.py | 6 +++--- tests/test_custom_provider.py | 4 +++- tests/test_intelligent_fallback.py | 3 --- tests/test_precommit_with_mock_store.py | 6 +++++- tests/test_thinking_modes.py | 6 +++--- tools/base.py | 3 +-- utils/conversation_memory.py | 4 ++-- 13 files changed, 46 insertions(+), 26 deletions(-) diff --git a/conf/custom_models.json b/conf/custom_models.json index 611e4f0..c648ce4 100644 --- a/conf/custom_models.json +++ b/conf/custom_models.json @@ -103,9 +103,27 @@ "supports_function_calling": false, "description": "Meta's Llama 3 70B model" }, + { + "model_name": "openai/gpt-4o", + "aliases": ["gpt4o", "4o", "gpt-4o"], + "context_window": 128000, + "supports_extended_thinking": false, + "supports_json_mode": true, + "supports_function_calling": true, + "description": "OpenAI's GPT-4o model" + }, + { + "model_name": "deepseek/deepseek-coder", + "aliases": ["deepseek-coder", "deepseek", "coder"], + "context_window": 65536, + "supports_extended_thinking": false, + "supports_json_mode": true, + "supports_function_calling": true, + "description": "DeepSeek Coder model for programming tasks" + }, { "model_name": "deepseek/deepseek-r1-0528", - "aliases": ["deepseek-r1", "deepseek", "r1", "deepseek-thinking"], + "aliases": ["deepseek-r1", "r1", "deepseek-thinking"], "context_window": 65536, "supports_extended_thinking": true, "supports_json_mode": true, diff --git a/providers/base.py b/providers/base.py index 7febcb6..5d2b20e 100644 --- a/providers/base.py +++ b/providers/base.py @@ -212,9 +212,7 @@ class ModelProvider(ABC): # Validate temperature min_temp, max_temp = capabilities.temperature_range if not min_temp <= temperature <= max_temp: - raise ValueError( - f"Temperature {temperature} out of range [{min_temp}, {max_temp}] " f"for model {model_name}" - ) + raise ValueError(f"Temperature {temperature} out of range [{min_temp}, {max_temp}] for model {model_name}") @abstractmethod def supports_thinking_mode(self, model_name: str) -> bool: diff --git a/providers/openai_compatible.py b/providers/openai_compatible.py index cdff57c..91d4c0c 100644 --- a/providers/openai_compatible.py +++ b/providers/openai_compatible.py @@ -246,9 +246,7 @@ class OpenAICompatibleProvider(ModelProvider): """ # Validate model name against allow-list if not self.validate_model_name(model_name): - raise ValueError( - f"Model '{model_name}' not in allowed models list. " f"Allowed models: {self.allowed_models}" - ) + raise ValueError(f"Model '{model_name}' not in allowed models list. Allowed models: {self.allowed_models}") # Validate parameters self.validate_parameters(model_name, temperature) @@ -367,7 +365,7 @@ class OpenAICompatibleProvider(ModelProvider): # Check if we're using generic capabilities if hasattr(capabilities, "_is_generic"): logging.debug( - f"Using generic parameter validation for {model_name}. " "Actual model constraints may differ." + f"Using generic parameter validation for {model_name}. Actual model constraints may differ." ) # Validate temperature using parent class method diff --git a/providers/openrouter_registry.py b/providers/openrouter_registry.py index 71536bd..51f754b 100644 --- a/providers/openrouter_registry.py +++ b/providers/openrouter_registry.py @@ -154,7 +154,7 @@ class OpenRouterModelRegistry: if alias_lower in alias_map: existing_model = alias_map[alias_lower] raise ValueError( - f"Duplicate alias '{alias}' found for models " f"'{existing_model}' and '{config.model_name}'" + f"Duplicate alias '{alias}' found for models '{existing_model}' and '{config.model_name}'" ) alias_map[alias_lower] = config.model_name diff --git a/simulator_tests/base_test.py b/simulator_tests/base_test.py index 4844c7e..05be0a0 100644 --- a/simulator_tests/base_test.py +++ b/simulator_tests/base_test.py @@ -138,7 +138,11 @@ class Calculator: # Execute the command result = subprocess.run( - docker_cmd, input=input_data, text=True, capture_output=True, timeout=3600 # 1 hour timeout + docker_cmd, + input=input_data, + text=True, + capture_output=True, + timeout=3600, # 1 hour timeout ) if result.returncode != 0: diff --git a/tests/test_claude_continuation.py b/tests/test_claude_continuation.py index 1de4b45..4f2a20b 100644 --- a/tests/test_claude_continuation.py +++ b/tests/test_claude_continuation.py @@ -284,7 +284,7 @@ I'd be happy to examine the error handling patterns in more detail if that would turns = [ ConversationTurn( role="assistant" if i % 2 else "user", - content=f"Turn {i+1}", + content=f"Turn {i + 1}", timestamp="2023-01-01T00:00:00Z", tool_name="test_continuation", ) diff --git a/tests/test_collaboration.py b/tests/test_collaboration.py index e2e5254..c0159ab 100644 --- a/tests/test_collaboration.py +++ b/tests/test_collaboration.py @@ -246,9 +246,9 @@ class TestCollaborationWorkflow: ) response = json.loads(result[0].text) - assert ( - response["status"] == "requires_clarification" - ), "Should request clarification when asked about dependencies without package files" + assert response["status"] == "requires_clarification", ( + "Should request clarification when asked about dependencies without package files" + ) clarification = json.loads(response["content"]) assert "package.json" in str(clarification["files_needed"]), "Should specifically request package.json" diff --git a/tests/test_custom_provider.py b/tests/test_custom_provider.py index d40fb4c..7e6e660 100644 --- a/tests/test_custom_provider.py +++ b/tests/test_custom_provider.py @@ -95,7 +95,9 @@ class TestCustomProvider: # Call with an alias result = provider.generate_content( - prompt="test prompt", model_name="llama", temperature=0.7 # This is an alias + prompt="test prompt", + model_name="llama", + temperature=0.7, # This is an alias ) # Verify parent method was called with resolved model name diff --git a/tests/test_intelligent_fallback.py b/tests/test_intelligent_fallback.py index 2d9bbca..6118190 100644 --- a/tests/test_intelligent_fallback.py +++ b/tests/test_intelligent_fallback.py @@ -76,7 +76,6 @@ class TestIntelligentFallback: patch("config.DEFAULT_MODEL", "auto"), patch.dict(os.environ, {"OPENAI_API_KEY": "sk-test-key", "GEMINI_API_KEY": ""}, clear=False), ): - ModelProviderRegistry.clear_cache() # Create a context with at least one turn so it doesn't exit early @@ -115,7 +114,6 @@ class TestIntelligentFallback: patch("config.DEFAULT_MODEL", "auto"), patch.dict(os.environ, {"OPENAI_API_KEY": "", "GEMINI_API_KEY": "test-key"}, clear=False), ): - ModelProviderRegistry.clear_cache() from utils.conversation_memory import ConversationTurn @@ -148,7 +146,6 @@ class TestIntelligentFallback: from utils.conversation_memory import ThreadContext, build_conversation_history with patch("config.IS_AUTO_MODE", False), patch("config.DEFAULT_MODEL", "gemini-2.5-pro-preview-06-05"): - from utils.conversation_memory import ConversationTurn context = ThreadContext( diff --git a/tests/test_precommit_with_mock_store.py b/tests/test_precommit_with_mock_store.py index 5a1fe25..8e27228 100644 --- a/tests/test_precommit_with_mock_store.py +++ b/tests/test_precommit_with_mock_store.py @@ -233,7 +233,11 @@ TEMPERATURE_ANALYTICAL = 0.2 # For code review, debugging # Test the centralized file preparation method directly file_content = tool._prepare_file_content_for_prompt( - [config_path], None, "Test files", max_tokens=100000, reserve_tokens=1000 # No continuation + [config_path], + None, + "Test files", + max_tokens=100000, + reserve_tokens=1000, # No continuation ) # Should contain file markers diff --git a/tests/test_thinking_modes.py b/tests/test_thinking_modes.py index 4a623e6..36fbf90 100644 --- a/tests/test_thinking_modes.py +++ b/tests/test_thinking_modes.py @@ -34,9 +34,9 @@ class TestThinkingModes: ] for tool, expected_default in tools: - assert ( - tool.get_default_thinking_mode() == expected_default - ), f"{tool.__class__.__name__} should default to {expected_default}" + assert tool.get_default_thinking_mode() == expected_default, ( + f"{tool.__class__.__name__} should default to {expected_default}" + ) @pytest.mark.asyncio @patch("tools.base.BaseTool.get_model_provider") diff --git a/tools/base.py b/tools/base.py index fbec6f2..59622c6 100644 --- a/tools/base.py +++ b/tools/base.py @@ -58,8 +58,7 @@ class ToolRequest(BaseModel): thinking_mode: Optional[Literal["minimal", "low", "medium", "high", "max"]] = Field( None, description=( - "Thinking depth: minimal (0.5% of model max), low (8%), medium (33%), high (67%), " - "max (100% of model max)" + "Thinking depth: minimal (0.5% of model max), low (8%), medium (33%), high (67%), max (100% of model max)" ), ) use_websearch: Optional[bool] = Field( diff --git a/utils/conversation_memory.py b/utils/conversation_memory.py index 868015e..0ce6ee5 100644 --- a/utils/conversation_memory.py +++ b/utils/conversation_memory.py @@ -372,7 +372,7 @@ def get_conversation_file_list(context: ThreadContext) -> list[str]: for i, turn in enumerate(context.turns): if turn.files: - logger.debug(f"[FILES] Turn {i+1} has {len(turn.files)} files: {turn.files}") + logger.debug(f"[FILES] Turn {i + 1} has {len(turn.files)} files: {turn.files}") for file_path in turn.files: if file_path not in seen_files: seen_files.add(file_path) @@ -381,7 +381,7 @@ def get_conversation_file_list(context: ThreadContext) -> list[str]: else: logger.debug(f"[FILES] Duplicate file skipped: {file_path}") else: - logger.debug(f"[FILES] Turn {i+1} has no files") + logger.debug(f"[FILES] Turn {i + 1} has no files") logger.debug(f"[FILES] Final unique file list ({len(unique_files)}): {unique_files}") return unique_files