Fixed priority linting errors to improve code quality: Critical Fixes: - F821 (2 errors): Fixed undefined name 'original_result' in config_enhancer.py - UP035 (2 errors): Removed deprecated typing.Dict and typing.Type imports - F401 (27 errors): Removed unused imports and added noqa for availability checks - E722 (19 errors): Replaced bare 'except:' with 'except Exception:' Code Quality Improvements: - SIM201 (4 errors): Simplified 'not x == y' to 'x != y' - SIM118 (2 errors): Removed unnecessary .keys() in dict iterations - E741 (4 errors): Renamed ambiguous variable 'l' to 'line' - I001 (1 error): Sorted imports in test_bootstrap_skill.py All modified areas tested and passing: - test_scraper_features.py: 42 passed - test_integration.py: 51 passed - test_architecture_scenarios.py: 11 passed - test_real_world_fastmcp.py: 19 passed (1 skipped) Remaining linting errors: 249 (mostly code style suggestions like ARG002, F841, SIM102) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
121 lines
2.8 KiB
Python
121 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Multi-LLM Adaptor Registry
|
|
|
|
Provides factory function to get platform-specific adaptors for skill generation.
|
|
Supports Claude AI, Google Gemini, OpenAI ChatGPT, and generic Markdown export.
|
|
"""
|
|
|
|
from .base import SkillAdaptor, SkillMetadata
|
|
|
|
# Import adaptors (some may not be implemented yet)
|
|
try:
|
|
from .claude import ClaudeAdaptor
|
|
except ImportError:
|
|
ClaudeAdaptor = None
|
|
|
|
try:
|
|
from .gemini import GeminiAdaptor
|
|
except ImportError:
|
|
GeminiAdaptor = None
|
|
|
|
try:
|
|
from .openai import OpenAIAdaptor
|
|
except ImportError:
|
|
OpenAIAdaptor = None
|
|
|
|
try:
|
|
from .markdown import MarkdownAdaptor
|
|
except ImportError:
|
|
MarkdownAdaptor = None
|
|
|
|
|
|
# Registry of available adaptors
|
|
ADAPTORS: dict[str, type[SkillAdaptor]] = {}
|
|
|
|
# Register adaptors that are implemented
|
|
if ClaudeAdaptor:
|
|
ADAPTORS["claude"] = ClaudeAdaptor
|
|
if GeminiAdaptor:
|
|
ADAPTORS["gemini"] = GeminiAdaptor
|
|
if OpenAIAdaptor:
|
|
ADAPTORS["openai"] = OpenAIAdaptor
|
|
if MarkdownAdaptor:
|
|
ADAPTORS["markdown"] = MarkdownAdaptor
|
|
|
|
|
|
def get_adaptor(platform: str, config: dict = None) -> SkillAdaptor:
|
|
"""
|
|
Factory function to get platform-specific adaptor instance.
|
|
|
|
Args:
|
|
platform: Platform identifier ('claude', 'gemini', 'openai', 'markdown')
|
|
config: Optional platform-specific configuration
|
|
|
|
Returns:
|
|
SkillAdaptor instance for the specified platform
|
|
|
|
Raises:
|
|
ValueError: If platform is not supported or not yet implemented
|
|
|
|
Examples:
|
|
>>> adaptor = get_adaptor('claude')
|
|
>>> adaptor = get_adaptor('gemini', {'api_version': 'v1beta'})
|
|
"""
|
|
if platform not in ADAPTORS:
|
|
available = ", ".join(ADAPTORS.keys())
|
|
if not ADAPTORS:
|
|
raise ValueError(
|
|
f"No adaptors are currently implemented. Platform '{platform}' is not available."
|
|
)
|
|
raise ValueError(
|
|
f"Platform '{platform}' is not supported or not yet implemented. Available platforms: {available}"
|
|
)
|
|
|
|
adaptor_class = ADAPTORS[platform]
|
|
return adaptor_class(config)
|
|
|
|
|
|
def list_platforms() -> list[str]:
|
|
"""
|
|
List all supported platforms.
|
|
|
|
Returns:
|
|
List of platform identifiers
|
|
|
|
Examples:
|
|
>>> list_platforms()
|
|
['claude', 'gemini', 'openai', 'markdown']
|
|
"""
|
|
return list(ADAPTORS.keys())
|
|
|
|
|
|
def is_platform_available(platform: str) -> bool:
|
|
"""
|
|
Check if a platform adaptor is available.
|
|
|
|
Args:
|
|
platform: Platform identifier to check
|
|
|
|
Returns:
|
|
True if platform is available
|
|
|
|
Examples:
|
|
>>> is_platform_available('claude')
|
|
True
|
|
>>> is_platform_available('unknown')
|
|
False
|
|
"""
|
|
return platform in ADAPTORS
|
|
|
|
|
|
# Export public interface
|
|
__all__ = [
|
|
"SkillAdaptor",
|
|
"SkillMetadata",
|
|
"get_adaptor",
|
|
"list_platforms",
|
|
"is_platform_available",
|
|
"ADAPTORS",
|
|
]
|