src.ai.providers package#
AI Provider Components.
- class src.ai.providers.BaseLLMProvider[source]#
Bases:
ABCBase class for LLM providers.
Defines the interface that all LLM providers must implement to integrate with Marcus AI system.
- infer_dependencies(tasks)[source]#
Infer logical dependencies between tasks
- Parameters:
- Return type:
Notes
All methods are async to support various LLM APIs. Implementations should handle rate limiting and retries.
Examples
>>> provider = OpenAIProvider(api_key="...") >>> analysis = await provider.analyze_task(task, context) >>> print(f"Task intent: {analysis.task_intent}")
- abstractmethod async analyze_task(task, context)[source]#
Analyze task semantics using LLM.
- Parameters:
- Returns:
Comprehensive semantic analysis of the task
- Return type:
- abstractmethod async infer_dependencies(tasks)[source]#
Infer semantic dependencies between tasks.
- Parameters:
- Returns:
Inferred dependency relationships
- Return type:
Notes
This supplements rule-based dependency detection with semantic understanding of task relationships.
- abstractmethod async generate_enhanced_description(task, context)[source]#
Generate enhanced task description.
- abstractmethod async estimate_effort(task, context)[source]#
Estimate task effort using AI analysis.
- Parameters:
- Returns:
AI-powered effort estimation with confidence
- Return type:
- class src.ai.providers.SemanticAnalysis[source]#
Bases:
objectResult of semantic task analysis.
Contains LLM’s understanding of task meaning and implications.
- __init__(task_intent, semantic_dependencies, risk_factors, suggestions, confidence, reasoning, risk_assessment, fallback_used=False)#
- class src.ai.providers.SemanticDependency[source]#
Bases:
objectSemantic dependency relationship between tasks.
Represents LLM-inferred dependencies based on task meaning.
Examples
>>> dep = SemanticDependency( ... dependent_task_id="deploy-api", ... dependency_task_id="test-api", ... confidence=0.95, ... reasoning="Deployment requires successful tests", ... dependency_type="logical" ... )
- class src.ai.providers.EffortEstimate[source]#
Bases:
objectAI-powered effort estimation.
Provides intelligent time estimates based on task analysis.
Notes
The final estimate should be: estimated_hours * risk_multiplier
- class src.ai.providers.CloudLLMProvider[source]#
Bases:
LocalLLMProviderGeneric cloud LLM provider for OpenAI-compatible hosted APIs.
Inherits all semantic-analysis business logic from
LocalLLMProviderand overrides the transport layer only: the HTTP client is pointed at an explicit remote URL with a required API key. The Ollama native-API fallback present in the parent is intentionally omitted — cloud endpoints do not implement it.- Parameters:
- Raises:
ValueError – If
model,api_key, orurlis empty.
- class src.ai.providers.LLMAbstraction[source]#
Bases:
objectMulti-provider LLM abstraction with intelligent fallback.
Supports multiple LLM providers with automatic fallback when primary fails. Provides a unified interface for all AI operations in Marcus.
- analyze_task_semantics(task, context)[source]#
Analyze task meaning and intent
- Parameters:
- Return type:
- infer_dependencies_semantic(tasks)[source]#
Infer logical dependencies between tasks
- Parameters:
- Return type:
- estimate_effort_intelligently(task, context)[source]#
AI-powered effort estimation
- Parameters:
- Return type:
- analyze_blocker_and_suggest_solutions(task, blocker, severity, agent)[source]#
Analyze blockers and provide solutions
Notes
Providers are initialized lazily to avoid circular imports. Statistics are tracked for intelligent provider selection.
- async analyze_task_semantics(task, context)[source]#
Analyze task semantics using the best available provider.
- Parameters:
- Returns:
Comprehensive semantic analysis including intent and risks
- Return type:
Notes
Automatically falls back to alternative providers on failure. Tagged
analyze_task_semanticsvia_tagged_operation()so the resultingtoken_events.operationrow carries that label instead of the provider’s default.
- async infer_dependencies_semantic(tasks)[source]#
Infer semantic dependencies between tasks.
- Parameters:
- Returns:
Inferred logical relationships between tasks
- Return type:
Notes
Complements rule-based dependency detection with semantic understanding. Tagged
infer_dependenciesvia_tagged_operation().
- async estimate_effort_intelligently(task, context)[source]#
Estimate task effort using AI.
- Parameters:
- Returns:
AI-powered time estimate with confidence and factors
- Return type:
- async analyze_blocker_and_suggest_solutions(task, blocker_description, severity, agent)[source]#
Analyze a blocker and suggest solutions.
- Parameters:
- Returns:
Prioritized list of solution suggestions
- Return type:
Notes
Higher severity blockers receive more detailed analysis.
- async analyze(prompt, context, *, operation=None)[source]#
Analyze content using LLM.
- Parameters:
prompt (
str) – The prompt to analyze.context (
Any) – Analysis context (may carrymax_tokensoverride).operation (
Optional[str]) – Logical operation label to attach to the cost event. When provided, the recorder’s active PlannerContext is shadowed with anoperation_overridefor the duration of the call, sotoken_events.operationrecordsoperationinstead of whatever default the provider stamps. Used for per-call drill-down in the Cato cost dashboard. Seesrc/cost_tracking/operations.pyfor the canonical taxonomy and human-readable descriptions.
- Returns:
Analysis result as string.
- Return type:
Submodules#
- src.ai.providers.anthropic_provider module
- src.ai.providers.base_provider module
- Classes
SemanticAnalysisSemanticAnalysis.task_intentSemanticAnalysis.semantic_dependenciesSemanticAnalysis.risk_factorsSemanticAnalysis.suggestionsSemanticAnalysis.confidenceSemanticAnalysis.reasoningSemanticAnalysis.risk_assessmentSemanticAnalysis.fallback_usedSemanticAnalysis.task_intentSemanticAnalysis.semantic_dependenciesSemanticAnalysis.risk_factorsSemanticAnalysis.suggestionsSemanticAnalysis.confidenceSemanticAnalysis.reasoningSemanticAnalysis.risk_assessmentSemanticAnalysis.fallback_usedSemanticAnalysis.__init__()
SemanticDependencySemanticDependency.dependent_task_idSemanticDependency.dependency_task_idSemanticDependency.confidenceSemanticDependency.reasoningSemanticDependency.dependency_typeSemanticDependency.dependent_task_idSemanticDependency.dependency_task_idSemanticDependency.confidenceSemanticDependency.reasoningSemanticDependency.dependency_typeSemanticDependency.__init__()
EffortEstimateEffortEstimate.estimated_hoursEffortEstimate.confidenceEffortEstimate.factorsEffortEstimate.similar_tasksEffortEstimate.risk_multiplierEffortEstimate.estimated_hoursEffortEstimate.confidenceEffortEstimate.factorsEffortEstimate.similar_tasksEffortEstimate.risk_multiplierEffortEstimate.__init__()
BaseLLMProviderBaseLLMProvider.analyze_task()BaseLLMProvider.infer_dependencies()BaseLLMProvider.generate_enhanced_description()BaseLLMProvider.estimate_effort()BaseLLMProvider.analyze_blocker()BaseLLMProvider.analyze_task()BaseLLMProvider.infer_dependencies()BaseLLMProvider.generate_enhanced_description()BaseLLMProvider.estimate_effort()BaseLLMProvider.analyze_blocker()
- src.ai.providers.llm_abstraction module
- Classes
LLMAbstractionLLMAbstraction.providersLLMAbstraction.current_providerLLMAbstraction.fallback_providersLLMAbstraction.provider_statsLLMAbstraction.analyze_task_semantics()LLMAbstraction.infer_dependencies_semantic()LLMAbstraction.generate_enhanced_description()LLMAbstraction.estimate_effort_intelligently()LLMAbstraction.analyze_blocker_and_suggest_solutions()LLMAbstraction.__init__()LLMAbstraction.analyze_task_semantics()LLMAbstraction.infer_dependencies_semantic()LLMAbstraction.generate_enhanced_description()LLMAbstraction.estimate_effort_intelligently()LLMAbstraction.analyze_blocker_and_suggest_solutions()LLMAbstraction.analyze()LLMAbstraction.switch_provider()LLMAbstraction.get_provider_stats()LLMAbstraction.get_best_provider()LLMAbstraction.health_check()
- src.ai.providers.local_provider module
- Classes
LocalLLMProviderLocalLLMProvider.base_urlLocalLLMProvider.modelLocalLLMProvider.max_tokensLocalLLMProvider.timeoutLocalLLMProvider.clientLocalLLMProvider.__init__()LocalLLMProvider.analyze_task()LocalLLMProvider.infer_dependencies()LocalLLMProvider.generate_enhanced_description()LocalLLMProvider.estimate_effort()LocalLLMProvider.analyze_blocker()LocalLLMProvider.complete()
- src.ai.providers.openai_provider module
- Classes
OpenAIProviderOpenAIProvider.api_keyOpenAIProvider.base_urlOpenAIProvider.modelOpenAIProvider.max_tokensOpenAIProvider.timeoutOpenAIProvider.clientOpenAIProvider.__init__()OpenAIProvider.analyze_task()OpenAIProvider.infer_dependencies()OpenAIProvider.generate_enhanced_description()OpenAIProvider.estimate_effort()OpenAIProvider.analyze_blocker()OpenAIProvider.complete()OpenAIProvider.close()