claude-mpm 4.13.2__py3-none-any.whl → 4.18.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- claude_mpm/VERSION +1 -1
- claude_mpm/agents/BASE_ENGINEER.md +286 -0
- claude_mpm/agents/BASE_PM.md +48 -17
- claude_mpm/agents/OUTPUT_STYLE.md +329 -11
- claude_mpm/agents/PM_INSTRUCTIONS.md +227 -8
- claude_mpm/agents/agent_loader.py +17 -5
- claude_mpm/agents/frontmatter_validator.py +284 -253
- claude_mpm/agents/templates/agentic-coder-optimizer.json +9 -2
- claude_mpm/agents/templates/api_qa.json +7 -1
- claude_mpm/agents/templates/clerk-ops.json +8 -1
- claude_mpm/agents/templates/code_analyzer.json +4 -1
- claude_mpm/agents/templates/dart_engineer.json +11 -1
- claude_mpm/agents/templates/data_engineer.json +11 -1
- claude_mpm/agents/templates/documentation.json +6 -1
- claude_mpm/agents/templates/engineer.json +18 -1
- claude_mpm/agents/templates/gcp_ops_agent.json +8 -1
- claude_mpm/agents/templates/golang_engineer.json +11 -1
- claude_mpm/agents/templates/java_engineer.json +12 -2
- claude_mpm/agents/templates/local_ops_agent.json +1217 -6
- claude_mpm/agents/templates/nextjs_engineer.json +11 -1
- claude_mpm/agents/templates/ops.json +8 -1
- claude_mpm/agents/templates/php-engineer.json +11 -1
- claude_mpm/agents/templates/project_organizer.json +10 -3
- claude_mpm/agents/templates/prompt-engineer.json +5 -1
- claude_mpm/agents/templates/python_engineer.json +11 -1
- claude_mpm/agents/templates/qa.json +7 -1
- claude_mpm/agents/templates/react_engineer.json +11 -1
- claude_mpm/agents/templates/refactoring_engineer.json +8 -1
- claude_mpm/agents/templates/research.json +4 -1
- claude_mpm/agents/templates/ruby-engineer.json +11 -1
- claude_mpm/agents/templates/rust_engineer.json +11 -1
- claude_mpm/agents/templates/security.json +6 -1
- claude_mpm/agents/templates/svelte-engineer.json +225 -0
- claude_mpm/agents/templates/ticketing.json +6 -1
- claude_mpm/agents/templates/typescript_engineer.json +11 -1
- claude_mpm/agents/templates/vercel_ops_agent.json +8 -1
- claude_mpm/agents/templates/version_control.json +8 -1
- claude_mpm/agents/templates/web_qa.json +7 -1
- claude_mpm/agents/templates/web_ui.json +11 -1
- claude_mpm/cli/__init__.py +34 -706
- claude_mpm/cli/commands/agent_manager.py +25 -12
- claude_mpm/cli/commands/agent_state_manager.py +186 -0
- claude_mpm/cli/commands/agents.py +204 -148
- claude_mpm/cli/commands/aggregate.py +7 -3
- claude_mpm/cli/commands/analyze.py +9 -4
- claude_mpm/cli/commands/analyze_code.py +7 -2
- claude_mpm/cli/commands/auto_configure.py +7 -9
- claude_mpm/cli/commands/config.py +47 -13
- claude_mpm/cli/commands/configure.py +294 -1788
- claude_mpm/cli/commands/configure_agent_display.py +261 -0
- claude_mpm/cli/commands/configure_behavior_manager.py +204 -0
- claude_mpm/cli/commands/configure_hook_manager.py +225 -0
- claude_mpm/cli/commands/configure_models.py +18 -0
- claude_mpm/cli/commands/configure_navigation.py +167 -0
- claude_mpm/cli/commands/configure_paths.py +104 -0
- claude_mpm/cli/commands/configure_persistence.py +254 -0
- claude_mpm/cli/commands/configure_startup_manager.py +646 -0
- claude_mpm/cli/commands/configure_template_editor.py +497 -0
- claude_mpm/cli/commands/configure_validators.py +73 -0
- claude_mpm/cli/commands/local_deploy.py +537 -0
- claude_mpm/cli/commands/memory.py +54 -20
- claude_mpm/cli/commands/mpm_init.py +39 -25
- claude_mpm/cli/commands/mpm_init_handler.py +8 -3
- claude_mpm/cli/executor.py +202 -0
- claude_mpm/cli/helpers.py +105 -0
- claude_mpm/cli/interactive/__init__.py +3 -0
- claude_mpm/cli/interactive/skills_wizard.py +491 -0
- claude_mpm/cli/parsers/__init__.py +7 -1
- claude_mpm/cli/parsers/base_parser.py +98 -3
- claude_mpm/cli/parsers/local_deploy_parser.py +227 -0
- claude_mpm/cli/shared/output_formatters.py +28 -19
- claude_mpm/cli/startup.py +481 -0
- claude_mpm/cli/utils.py +52 -1
- claude_mpm/commands/mpm-help.md +3 -0
- claude_mpm/commands/mpm-version.md +113 -0
- claude_mpm/commands/mpm.md +1 -0
- claude_mpm/config/agent_config.py +2 -2
- claude_mpm/config/model_config.py +428 -0
- claude_mpm/core/base_service.py +13 -12
- claude_mpm/core/enums.py +452 -0
- claude_mpm/core/factories.py +1 -1
- claude_mpm/core/instruction_reinforcement_hook.py +2 -1
- claude_mpm/core/interactive_session.py +9 -3
- claude_mpm/core/logging_config.py +6 -2
- claude_mpm/core/oneshot_session.py +8 -4
- claude_mpm/core/optimized_agent_loader.py +3 -3
- claude_mpm/core/output_style_manager.py +12 -192
- claude_mpm/core/service_registry.py +5 -1
- claude_mpm/core/types.py +2 -9
- claude_mpm/core/typing_utils.py +7 -6
- claude_mpm/dashboard/static/js/dashboard.js +0 -14
- claude_mpm/dashboard/templates/index.html +3 -41
- claude_mpm/hooks/claude_hooks/response_tracking.py +35 -1
- claude_mpm/hooks/instruction_reinforcement.py +7 -2
- claude_mpm/models/resume_log.py +340 -0
- claude_mpm/services/agents/auto_config_manager.py +10 -11
- claude_mpm/services/agents/deployment/agent_configuration_manager.py +1 -1
- claude_mpm/services/agents/deployment/agent_record_service.py +1 -1
- claude_mpm/services/agents/deployment/agent_validator.py +17 -1
- claude_mpm/services/agents/deployment/async_agent_deployment.py +1 -1
- claude_mpm/services/agents/deployment/interface_adapter.py +3 -2
- claude_mpm/services/agents/deployment/local_template_deployment.py +1 -1
- claude_mpm/services/agents/deployment/pipeline/steps/agent_processing_step.py +7 -6
- claude_mpm/services/agents/deployment/pipeline/steps/base_step.py +7 -16
- claude_mpm/services/agents/deployment/pipeline/steps/configuration_step.py +4 -3
- claude_mpm/services/agents/deployment/pipeline/steps/target_directory_step.py +5 -3
- claude_mpm/services/agents/deployment/pipeline/steps/validation_step.py +6 -5
- claude_mpm/services/agents/deployment/refactored_agent_deployment_service.py +9 -6
- claude_mpm/services/agents/deployment/validation/__init__.py +3 -1
- claude_mpm/services/agents/deployment/validation/validation_result.py +1 -9
- claude_mpm/services/agents/local_template_manager.py +1 -1
- claude_mpm/services/agents/memory/agent_memory_manager.py +5 -2
- claude_mpm/services/agents/registry/modification_tracker.py +5 -2
- claude_mpm/services/command_handler_service.py +11 -5
- claude_mpm/services/core/interfaces/__init__.py +74 -2
- claude_mpm/services/core/interfaces/health.py +172 -0
- claude_mpm/services/core/interfaces/model.py +281 -0
- claude_mpm/services/core/interfaces/process.py +372 -0
- claude_mpm/services/core/interfaces/restart.py +307 -0
- claude_mpm/services/core/interfaces/stability.py +260 -0
- claude_mpm/services/core/models/__init__.py +33 -0
- claude_mpm/services/core/models/agent_config.py +12 -28
- claude_mpm/services/core/models/health.py +162 -0
- claude_mpm/services/core/models/process.py +235 -0
- claude_mpm/services/core/models/restart.py +302 -0
- claude_mpm/services/core/models/stability.py +264 -0
- claude_mpm/services/core/path_resolver.py +23 -7
- claude_mpm/services/diagnostics/__init__.py +2 -2
- claude_mpm/services/diagnostics/checks/agent_check.py +25 -24
- claude_mpm/services/diagnostics/checks/claude_code_check.py +24 -23
- claude_mpm/services/diagnostics/checks/common_issues_check.py +25 -24
- claude_mpm/services/diagnostics/checks/configuration_check.py +24 -23
- claude_mpm/services/diagnostics/checks/filesystem_check.py +18 -17
- claude_mpm/services/diagnostics/checks/installation_check.py +30 -29
- claude_mpm/services/diagnostics/checks/instructions_check.py +20 -19
- claude_mpm/services/diagnostics/checks/mcp_check.py +50 -36
- claude_mpm/services/diagnostics/checks/mcp_services_check.py +36 -31
- claude_mpm/services/diagnostics/checks/monitor_check.py +23 -22
- claude_mpm/services/diagnostics/checks/startup_log_check.py +9 -8
- claude_mpm/services/diagnostics/diagnostic_runner.py +6 -5
- claude_mpm/services/diagnostics/doctor_reporter.py +28 -25
- claude_mpm/services/diagnostics/models.py +19 -24
- claude_mpm/services/infrastructure/monitoring/__init__.py +1 -1
- claude_mpm/services/infrastructure/monitoring/aggregator.py +12 -12
- claude_mpm/services/infrastructure/monitoring/base.py +5 -13
- claude_mpm/services/infrastructure/monitoring/network.py +7 -6
- claude_mpm/services/infrastructure/monitoring/process.py +13 -12
- claude_mpm/services/infrastructure/monitoring/resources.py +7 -6
- claude_mpm/services/infrastructure/monitoring/service.py +16 -15
- claude_mpm/services/infrastructure/resume_log_generator.py +439 -0
- claude_mpm/services/local_ops/__init__.py +163 -0
- claude_mpm/services/local_ops/crash_detector.py +257 -0
- claude_mpm/services/local_ops/health_checks/__init__.py +28 -0
- claude_mpm/services/local_ops/health_checks/http_check.py +224 -0
- claude_mpm/services/local_ops/health_checks/process_check.py +236 -0
- claude_mpm/services/local_ops/health_checks/resource_check.py +255 -0
- claude_mpm/services/local_ops/health_manager.py +430 -0
- claude_mpm/services/local_ops/log_monitor.py +396 -0
- claude_mpm/services/local_ops/memory_leak_detector.py +294 -0
- claude_mpm/services/local_ops/process_manager.py +595 -0
- claude_mpm/services/local_ops/resource_monitor.py +331 -0
- claude_mpm/services/local_ops/restart_manager.py +401 -0
- claude_mpm/services/local_ops/restart_policy.py +387 -0
- claude_mpm/services/local_ops/state_manager.py +372 -0
- claude_mpm/services/local_ops/unified_manager.py +600 -0
- claude_mpm/services/mcp_config_manager.py +9 -4
- claude_mpm/services/mcp_gateway/core/__init__.py +1 -2
- claude_mpm/services/mcp_gateway/core/base.py +18 -31
- claude_mpm/services/mcp_gateway/tools/external_mcp_services.py +71 -24
- claude_mpm/services/mcp_gateway/tools/health_check_tool.py +30 -28
- claude_mpm/services/memory_hook_service.py +4 -1
- claude_mpm/services/model/__init__.py +147 -0
- claude_mpm/services/model/base_provider.py +365 -0
- claude_mpm/services/model/claude_provider.py +412 -0
- claude_mpm/services/model/model_router.py +453 -0
- claude_mpm/services/model/ollama_provider.py +415 -0
- claude_mpm/services/monitor/daemon_manager.py +3 -2
- claude_mpm/services/monitor/handlers/dashboard.py +2 -1
- claude_mpm/services/monitor/handlers/hooks.py +2 -1
- claude_mpm/services/monitor/management/lifecycle.py +3 -2
- claude_mpm/services/monitor/server.py +2 -1
- claude_mpm/services/session_management_service.py +3 -2
- claude_mpm/services/session_manager.py +205 -1
- claude_mpm/services/shared/async_service_base.py +16 -27
- claude_mpm/services/shared/lifecycle_service_base.py +1 -14
- claude_mpm/services/socketio/handlers/__init__.py +5 -2
- claude_mpm/services/socketio/handlers/hook.py +13 -2
- claude_mpm/services/socketio/handlers/registry.py +4 -2
- claude_mpm/services/socketio/server/main.py +10 -8
- claude_mpm/services/subprocess_launcher_service.py +14 -5
- claude_mpm/services/unified/analyzer_strategies/code_analyzer.py +8 -7
- claude_mpm/services/unified/analyzer_strategies/dependency_analyzer.py +6 -5
- claude_mpm/services/unified/analyzer_strategies/performance_analyzer.py +8 -7
- claude_mpm/services/unified/analyzer_strategies/security_analyzer.py +7 -6
- claude_mpm/services/unified/analyzer_strategies/structure_analyzer.py +5 -4
- claude_mpm/services/unified/config_strategies/validation_strategy.py +13 -9
- claude_mpm/services/unified/deployment_strategies/cloud_strategies.py +10 -3
- claude_mpm/services/unified/deployment_strategies/local.py +6 -5
- claude_mpm/services/unified/deployment_strategies/utils.py +6 -5
- claude_mpm/services/unified/deployment_strategies/vercel.py +7 -6
- claude_mpm/services/unified/interfaces.py +3 -1
- claude_mpm/services/unified/unified_analyzer.py +14 -10
- claude_mpm/services/unified/unified_config.py +2 -1
- claude_mpm/services/unified/unified_deployment.py +9 -4
- claude_mpm/services/version_service.py +104 -1
- claude_mpm/skills/__init__.py +21 -0
- claude_mpm/skills/bundled/__init__.py +6 -0
- claude_mpm/skills/bundled/api-documentation.md +393 -0
- claude_mpm/skills/bundled/async-testing.md +571 -0
- claude_mpm/skills/bundled/code-review.md +143 -0
- claude_mpm/skills/bundled/database-migration.md +199 -0
- claude_mpm/skills/bundled/docker-containerization.md +194 -0
- claude_mpm/skills/bundled/express-local-dev.md +1429 -0
- claude_mpm/skills/bundled/fastapi-local-dev.md +1199 -0
- claude_mpm/skills/bundled/git-workflow.md +414 -0
- claude_mpm/skills/bundled/imagemagick.md +204 -0
- claude_mpm/skills/bundled/json-data-handling.md +223 -0
- claude_mpm/skills/bundled/nextjs-local-dev.md +807 -0
- claude_mpm/skills/bundled/pdf.md +141 -0
- claude_mpm/skills/bundled/performance-profiling.md +567 -0
- claude_mpm/skills/bundled/refactoring-patterns.md +180 -0
- claude_mpm/skills/bundled/security-scanning.md +327 -0
- claude_mpm/skills/bundled/systematic-debugging.md +473 -0
- claude_mpm/skills/bundled/test-driven-development.md +378 -0
- claude_mpm/skills/bundled/vite-local-dev.md +1061 -0
- claude_mpm/skills/bundled/web-performance-optimization.md +2305 -0
- claude_mpm/skills/bundled/xlsx.md +157 -0
- claude_mpm/skills/registry.py +286 -0
- claude_mpm/skills/skill_manager.py +310 -0
- claude_mpm/tools/code_tree_analyzer.py +177 -141
- claude_mpm/tools/code_tree_events.py +4 -2
- claude_mpm/utils/agent_dependency_loader.py +2 -2
- {claude_mpm-4.13.2.dist-info → claude_mpm-4.18.2.dist-info}/METADATA +117 -8
- {claude_mpm-4.13.2.dist-info → claude_mpm-4.18.2.dist-info}/RECORD +238 -174
- claude_mpm/dashboard/static/css/code-tree.css +0 -1639
- claude_mpm/dashboard/static/js/components/code-tree/tree-breadcrumb.js +0 -353
- claude_mpm/dashboard/static/js/components/code-tree/tree-constants.js +0 -235
- claude_mpm/dashboard/static/js/components/code-tree/tree-search.js +0 -409
- claude_mpm/dashboard/static/js/components/code-tree/tree-utils.js +0 -435
- claude_mpm/dashboard/static/js/components/code-tree.js +0 -5869
- claude_mpm/dashboard/static/js/components/code-viewer.js +0 -1386
- claude_mpm/hooks/claude_hooks/hook_handler_eventbus.py +0 -425
- claude_mpm/hooks/claude_hooks/hook_handler_original.py +0 -1041
- claude_mpm/hooks/claude_hooks/hook_handler_refactored.py +0 -347
- claude_mpm/services/agents/deployment/agent_lifecycle_manager_refactored.py +0 -575
- claude_mpm/services/project/analyzer_refactored.py +0 -450
- {claude_mpm-4.13.2.dist-info → claude_mpm-4.18.2.dist-info}/WHEEL +0 -0
- {claude_mpm-4.13.2.dist-info → claude_mpm-4.18.2.dist-info}/entry_points.txt +0 -0
- {claude_mpm-4.13.2.dist-info → claude_mpm-4.18.2.dist-info}/licenses/LICENSE +0 -0
- {claude_mpm-4.13.2.dist-info → claude_mpm-4.18.2.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Claude Model Provider Implementation for Claude MPM Framework
|
|
3
|
+
=============================================================
|
|
4
|
+
|
|
5
|
+
WHY: Provides cloud-based content analysis via Claude API as fallback
|
|
6
|
+
when local models are unavailable or for tasks requiring higher quality.
|
|
7
|
+
|
|
8
|
+
DESIGN DECISION: This is a placeholder/wrapper implementation that assumes
|
|
9
|
+
Claude API integration will be added later. For Phase 1, this provides the
|
|
10
|
+
interface contract that the router expects.
|
|
11
|
+
|
|
12
|
+
FUTURE: Will integrate with Anthropic SDK when content agent needs cloud fallback.
|
|
13
|
+
|
|
14
|
+
Note: This implementation returns mock responses for Phase 1. Phase 2 will
|
|
15
|
+
add actual Claude API integration.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from typing import Any, Dict, List, Optional
|
|
19
|
+
|
|
20
|
+
from claude_mpm.services.core.interfaces.model import ModelCapability, ModelResponse
|
|
21
|
+
from claude_mpm.services.model.base_provider import BaseModelProvider
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ClaudeProvider(BaseModelProvider):
|
|
25
|
+
"""
|
|
26
|
+
Claude API model provider (cloud-based).
|
|
27
|
+
|
|
28
|
+
WHY: Provides high-quality cloud-based content analysis with guaranteed
|
|
29
|
+
availability as fallback from local models.
|
|
30
|
+
|
|
31
|
+
Configuration:
|
|
32
|
+
api_key: Anthropic API key (optional, can use env var)
|
|
33
|
+
model: Default model to use (default: claude-3-5-sonnet-20241022)
|
|
34
|
+
max_tokens: Maximum response tokens (default: 4096)
|
|
35
|
+
|
|
36
|
+
Usage:
|
|
37
|
+
provider = ClaudeProvider(config={
|
|
38
|
+
"api_key": "sk-ant-...",
|
|
39
|
+
"model": "claude-3-5-sonnet-20241022"
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
response = await provider.analyze_content(
|
|
43
|
+
content="Your content",
|
|
44
|
+
task=ModelCapability.SEO_ANALYSIS
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
Note: Phase 1 implementation provides interface. Phase 2 will add
|
|
48
|
+
actual Claude API integration.
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
# Available Claude models
|
|
52
|
+
AVAILABLE_MODELS = [
|
|
53
|
+
"claude-3-5-sonnet-20241022",
|
|
54
|
+
"claude-3-5-haiku-20241022",
|
|
55
|
+
"claude-3-opus-20240229",
|
|
56
|
+
"claude-3-sonnet-20240229",
|
|
57
|
+
"claude-3-haiku-20240307",
|
|
58
|
+
]
|
|
59
|
+
|
|
60
|
+
def __init__(self, config: Optional[Dict[str, Any]] = None):
|
|
61
|
+
"""
|
|
62
|
+
Initialize Claude provider.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
config: Configuration dict with:
|
|
66
|
+
- api_key: Anthropic API key
|
|
67
|
+
- model: Default model
|
|
68
|
+
- max_tokens: Maximum response tokens
|
|
69
|
+
"""
|
|
70
|
+
super().__init__(provider_name="claude", config=config or {})
|
|
71
|
+
|
|
72
|
+
self.api_key = self.get_config("api_key", None)
|
|
73
|
+
self.default_model = self.get_config("model", "claude-3-5-sonnet-20241022")
|
|
74
|
+
self.max_tokens = self.get_config("max_tokens", 4096)
|
|
75
|
+
|
|
76
|
+
# TODO Phase 2: Initialize Anthropic SDK client
|
|
77
|
+
self._client = None
|
|
78
|
+
|
|
79
|
+
async def initialize(self) -> bool:
|
|
80
|
+
"""
|
|
81
|
+
Initialize Claude provider.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
True if initialization successful
|
|
85
|
+
"""
|
|
86
|
+
self.log_info("Initializing Claude provider")
|
|
87
|
+
|
|
88
|
+
# TODO Phase 2: Initialize Anthropic SDK
|
|
89
|
+
# if not self.api_key:
|
|
90
|
+
# self.log_warning("No API key provided, checking environment")
|
|
91
|
+
# self.api_key = os.getenv("ANTHROPIC_API_KEY")
|
|
92
|
+
#
|
|
93
|
+
# if not self.api_key:
|
|
94
|
+
# self.log_error("No Claude API key available")
|
|
95
|
+
# return False
|
|
96
|
+
#
|
|
97
|
+
# try:
|
|
98
|
+
# from anthropic import AsyncAnthropic
|
|
99
|
+
# self._client = AsyncAnthropic(api_key=self.api_key)
|
|
100
|
+
# except ImportError:
|
|
101
|
+
# self.log_error("anthropic package not installed")
|
|
102
|
+
# return False
|
|
103
|
+
|
|
104
|
+
# Phase 1: Mock initialization
|
|
105
|
+
self.log_info("Claude provider initialized (Phase 1 mock mode)")
|
|
106
|
+
self._initialized = True
|
|
107
|
+
return True
|
|
108
|
+
|
|
109
|
+
async def shutdown(self) -> None:
|
|
110
|
+
"""Shutdown provider and cleanup resources."""
|
|
111
|
+
self.log_info("Shutting down Claude provider")
|
|
112
|
+
|
|
113
|
+
# TODO Phase 2: Cleanup Anthropic client
|
|
114
|
+
if self._client:
|
|
115
|
+
# await self._client.close()
|
|
116
|
+
pass
|
|
117
|
+
|
|
118
|
+
self._shutdown = True
|
|
119
|
+
|
|
120
|
+
async def is_available(self) -> bool:
|
|
121
|
+
"""
|
|
122
|
+
Check if Claude API is available.
|
|
123
|
+
|
|
124
|
+
WHY: Cloud APIs are generally always available if API key is valid.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
True if API key configured, False otherwise
|
|
128
|
+
"""
|
|
129
|
+
# Phase 1: Return True to enable testing
|
|
130
|
+
# Phase 2: Check API key and test connection
|
|
131
|
+
return True
|
|
132
|
+
|
|
133
|
+
async def get_available_models(self) -> List[str]:
|
|
134
|
+
"""
|
|
135
|
+
List available Claude models.
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
List of model identifiers
|
|
139
|
+
"""
|
|
140
|
+
return self.AVAILABLE_MODELS
|
|
141
|
+
|
|
142
|
+
def get_supported_capabilities(self) -> List[ModelCapability]:
|
|
143
|
+
"""
|
|
144
|
+
Return all supported capabilities.
|
|
145
|
+
|
|
146
|
+
WHY: Claude supports all content analysis capabilities.
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
List of all ModelCapability values
|
|
150
|
+
"""
|
|
151
|
+
return list(ModelCapability)
|
|
152
|
+
|
|
153
|
+
async def analyze_content(
|
|
154
|
+
self,
|
|
155
|
+
content: str,
|
|
156
|
+
task: ModelCapability,
|
|
157
|
+
model: Optional[str] = None,
|
|
158
|
+
**kwargs,
|
|
159
|
+
) -> ModelResponse:
|
|
160
|
+
"""
|
|
161
|
+
Analyze content using Claude API.
|
|
162
|
+
|
|
163
|
+
Args:
|
|
164
|
+
content: Text content to analyze
|
|
165
|
+
task: Type of analysis
|
|
166
|
+
model: Optional specific model
|
|
167
|
+
**kwargs: Additional options:
|
|
168
|
+
- temperature: Sampling temperature
|
|
169
|
+
- max_tokens: Maximum response tokens
|
|
170
|
+
|
|
171
|
+
Returns:
|
|
172
|
+
ModelResponse with analysis results
|
|
173
|
+
"""
|
|
174
|
+
# Validate content
|
|
175
|
+
if not self.validate_content(content, max_length=200000):
|
|
176
|
+
return self.create_response(
|
|
177
|
+
success=False,
|
|
178
|
+
model=model or self.default_model,
|
|
179
|
+
task=task,
|
|
180
|
+
error="Invalid content provided",
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
# Check if initialized
|
|
184
|
+
if not self._initialized:
|
|
185
|
+
await self.initialize()
|
|
186
|
+
|
|
187
|
+
if not self._initialized:
|
|
188
|
+
return self.create_response(
|
|
189
|
+
success=False,
|
|
190
|
+
model=model or self.default_model,
|
|
191
|
+
task=task,
|
|
192
|
+
error="Claude provider not initialized",
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
# Select model
|
|
196
|
+
selected_model = model or self.default_model
|
|
197
|
+
|
|
198
|
+
# Generate prompt
|
|
199
|
+
prompt = self.get_task_prompt(task, content)
|
|
200
|
+
|
|
201
|
+
# Call Claude API with retry logic
|
|
202
|
+
return await self.analyze_with_retry(
|
|
203
|
+
self._call_claude_api,
|
|
204
|
+
prompt,
|
|
205
|
+
task,
|
|
206
|
+
selected_model,
|
|
207
|
+
**kwargs,
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
async def _call_claude_api(
|
|
211
|
+
self,
|
|
212
|
+
prompt: str,
|
|
213
|
+
task: ModelCapability,
|
|
214
|
+
model: str,
|
|
215
|
+
**kwargs,
|
|
216
|
+
) -> ModelResponse:
|
|
217
|
+
"""
|
|
218
|
+
Internal method to call Claude API.
|
|
219
|
+
|
|
220
|
+
Args:
|
|
221
|
+
prompt: Generated prompt
|
|
222
|
+
task: Task capability
|
|
223
|
+
model: Model to use
|
|
224
|
+
**kwargs: Additional options
|
|
225
|
+
|
|
226
|
+
Returns:
|
|
227
|
+
ModelResponse
|
|
228
|
+
"""
|
|
229
|
+
# TODO Phase 2: Implement actual Claude API call
|
|
230
|
+
# try:
|
|
231
|
+
# message = await self._client.messages.create(
|
|
232
|
+
# model=model,
|
|
233
|
+
# max_tokens=kwargs.get("max_tokens", self.max_tokens),
|
|
234
|
+
# temperature=kwargs.get("temperature", 0.7),
|
|
235
|
+
# messages=[{
|
|
236
|
+
# "role": "user",
|
|
237
|
+
# "content": prompt
|
|
238
|
+
# }]
|
|
239
|
+
# )
|
|
240
|
+
#
|
|
241
|
+
# result_text = message.content[0].text
|
|
242
|
+
#
|
|
243
|
+
# metadata = {
|
|
244
|
+
# "model": model,
|
|
245
|
+
# "stop_reason": message.stop_reason,
|
|
246
|
+
# "usage": {
|
|
247
|
+
# "input_tokens": message.usage.input_tokens,
|
|
248
|
+
# "output_tokens": message.usage.output_tokens,
|
|
249
|
+
# }
|
|
250
|
+
# }
|
|
251
|
+
#
|
|
252
|
+
# return self.create_response(
|
|
253
|
+
# success=True,
|
|
254
|
+
# model=model,
|
|
255
|
+
# task=task,
|
|
256
|
+
# result=result_text,
|
|
257
|
+
# metadata=metadata,
|
|
258
|
+
# )
|
|
259
|
+
#
|
|
260
|
+
# except Exception as e:
|
|
261
|
+
# return self.create_response(
|
|
262
|
+
# success=False,
|
|
263
|
+
# model=model,
|
|
264
|
+
# task=task,
|
|
265
|
+
# error=f"Claude API error: {str(e)}",
|
|
266
|
+
# )
|
|
267
|
+
|
|
268
|
+
# Phase 1: Return mock response for testing
|
|
269
|
+
mock_analysis = self._generate_mock_analysis(task)
|
|
270
|
+
|
|
271
|
+
return self.create_response(
|
|
272
|
+
success=True,
|
|
273
|
+
model=model,
|
|
274
|
+
task=task,
|
|
275
|
+
result=mock_analysis,
|
|
276
|
+
metadata={
|
|
277
|
+
"phase": "1",
|
|
278
|
+
"mode": "mock",
|
|
279
|
+
"note": "Phase 2 will implement actual Claude API integration",
|
|
280
|
+
},
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
def _generate_mock_analysis(self, task: ModelCapability) -> str:
|
|
284
|
+
"""
|
|
285
|
+
Generate mock analysis for Phase 1 testing.
|
|
286
|
+
|
|
287
|
+
Args:
|
|
288
|
+
task: Task capability
|
|
289
|
+
|
|
290
|
+
Returns:
|
|
291
|
+
Mock analysis text
|
|
292
|
+
"""
|
|
293
|
+
mock_responses = {
|
|
294
|
+
ModelCapability.SEO_ANALYSIS: """SEO Analysis (Mock):
|
|
295
|
+
1. Primary keywords: content, analysis, optimization
|
|
296
|
+
2. Keyword density: Moderate (2-3%)
|
|
297
|
+
3. Meta description: Well-structured content with clear focus
|
|
298
|
+
4. Title optimization: Consider adding target keywords
|
|
299
|
+
5. Content structure: Good use of headers
|
|
300
|
+
6. SEO Score: 75/100 - Good foundation, room for improvement""",
|
|
301
|
+
ModelCapability.READABILITY: """Readability Analysis (Mock):
|
|
302
|
+
1. Flesch Reading Ease: 65 (Standard)
|
|
303
|
+
2. Average sentence length: 15 words
|
|
304
|
+
3. Complex words: 12% of total
|
|
305
|
+
4. Grade level: 10th grade
|
|
306
|
+
5. Suggestions: Consider simplifying complex sentences
|
|
307
|
+
6. Overall rating: Medium readability""",
|
|
308
|
+
ModelCapability.GRAMMAR: """Grammar Check (Mock):
|
|
309
|
+
1. Grammatical errors: None detected
|
|
310
|
+
2. Spelling: All correct
|
|
311
|
+
3. Punctuation: Appropriate usage
|
|
312
|
+
4. Style: Consistent and clear
|
|
313
|
+
5. Clarity: Well-expressed ideas
|
|
314
|
+
6. Quality score: 95/100 - Excellent""",
|
|
315
|
+
ModelCapability.SUMMARIZATION: """Summary (Mock):
|
|
316
|
+
Main Points:
|
|
317
|
+
- Content provides valuable information
|
|
318
|
+
- Structure is logical and well-organized
|
|
319
|
+
- Key concepts are clearly explained
|
|
320
|
+
|
|
321
|
+
TL;DR: Well-structured content with clear messaging and good organization.""",
|
|
322
|
+
ModelCapability.KEYWORD_EXTRACTION: """Keyword Extraction (Mock):
|
|
323
|
+
Primary Keywords:
|
|
324
|
+
1. content (relevance: 0.95)
|
|
325
|
+
2. analysis (relevance: 0.88)
|
|
326
|
+
3. quality (relevance: 0.82)
|
|
327
|
+
4. structure (relevance: 0.75)
|
|
328
|
+
5. optimization (relevance: 0.70)
|
|
329
|
+
|
|
330
|
+
Long-tail phrases:
|
|
331
|
+
- "content analysis"
|
|
332
|
+
- "quality optimization"
|
|
333
|
+
- "structured content"
|
|
334
|
+
|
|
335
|
+
Suggested additions: performance, effectiveness, improvement""",
|
|
336
|
+
ModelCapability.ACCESSIBILITY: """Accessibility Analysis (Mock):
|
|
337
|
+
1. Language complexity: Moderate (10th grade level)
|
|
338
|
+
2. Inclusivity: Good, neutral language used
|
|
339
|
+
3. Plain language: Some jargon, consider simplification
|
|
340
|
+
4. Potential barriers: Technical terminology may challenge some readers
|
|
341
|
+
5. WCAG compliance: Meets basic guidelines
|
|
342
|
+
6. Accessibility score: 80/100 - Good with room for improvement""",
|
|
343
|
+
ModelCapability.SENTIMENT: """Sentiment Analysis (Mock):
|
|
344
|
+
1. Overall sentiment: Positive
|
|
345
|
+
2. Sentiment score: +0.6 (Moderately positive)
|
|
346
|
+
3. Emotional tone: Professional, informative
|
|
347
|
+
4. Audience perception: Likely to be well-received
|
|
348
|
+
5. Tone consistency: Maintained throughout""",
|
|
349
|
+
ModelCapability.GENERAL: """General Analysis (Mock):
|
|
350
|
+
1. Overview: Well-structured content with clear objectives
|
|
351
|
+
2. Quality: High-quality writing with good organization
|
|
352
|
+
3. Structure: Logical flow with appropriate sections
|
|
353
|
+
4. Improvements: Consider adding more examples
|
|
354
|
+
5. Effectiveness: 80/100 - Strong overall performance""",
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
return mock_responses.get(
|
|
358
|
+
task,
|
|
359
|
+
"Mock analysis completed. Phase 2 will provide detailed results.",
|
|
360
|
+
)
|
|
361
|
+
|
|
362
|
+
async def get_model_info(self, model: str) -> Dict[str, Any]:
|
|
363
|
+
"""
|
|
364
|
+
Get detailed information about a Claude model.
|
|
365
|
+
|
|
366
|
+
Args:
|
|
367
|
+
model: Model identifier
|
|
368
|
+
|
|
369
|
+
Returns:
|
|
370
|
+
Dictionary with model information
|
|
371
|
+
"""
|
|
372
|
+
# Model information based on public documentation
|
|
373
|
+
model_info = {
|
|
374
|
+
"claude-3-5-sonnet-20241022": {
|
|
375
|
+
"name": "Claude 3.5 Sonnet",
|
|
376
|
+
"version": "20241022",
|
|
377
|
+
"context_window": 200000,
|
|
378
|
+
"max_output": 8192,
|
|
379
|
+
"capabilities": ["analysis", "reasoning", "coding", "writing"],
|
|
380
|
+
"speed": "fast",
|
|
381
|
+
"cost": "medium",
|
|
382
|
+
},
|
|
383
|
+
"claude-3-5-haiku-20241022": {
|
|
384
|
+
"name": "Claude 3.5 Haiku",
|
|
385
|
+
"version": "20241022",
|
|
386
|
+
"context_window": 200000,
|
|
387
|
+
"max_output": 8192,
|
|
388
|
+
"capabilities": ["quick_analysis", "summarization"],
|
|
389
|
+
"speed": "fastest",
|
|
390
|
+
"cost": "low",
|
|
391
|
+
},
|
|
392
|
+
"claude-3-opus-20240229": {
|
|
393
|
+
"name": "Claude 3 Opus",
|
|
394
|
+
"version": "20240229",
|
|
395
|
+
"context_window": 200000,
|
|
396
|
+
"max_output": 4096,
|
|
397
|
+
"capabilities": ["complex_reasoning", "detailed_analysis"],
|
|
398
|
+
"speed": "slower",
|
|
399
|
+
"cost": "high",
|
|
400
|
+
},
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
return model_info.get(
|
|
404
|
+
model,
|
|
405
|
+
{
|
|
406
|
+
"name": model,
|
|
407
|
+
"error": "Model information not available",
|
|
408
|
+
},
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
__all__ = ["ClaudeProvider"]
|