fix: resolve syntax errors in scan-skipped files
All checks were successful
API Endpoint Tests / test-api-endpoints (push) Successful in 2m12s
CLI Tests / test-cli (push) Successful in 2m58s
Integration Tests / test-service-integration (push) Successful in 2m18s
Python Tests / test-python (push) Successful in 3m6s
Security Scanning / security-scan (push) Successful in 1m7s
All checks were successful
API Endpoint Tests / test-api-endpoints (push) Successful in 2m12s
CLI Tests / test-cli (push) Successful in 2m58s
Integration Tests / test-service-integration (push) Successful in 2m18s
Python Tests / test-python (push) Successful in 3m6s
Security Scanning / security-scan (push) Successful in 1m7s
- Fix malformed f-strings in agent communication SDK - Repair pricing strategy delimiters and optimizer blocks - Normalize FastAPI session dependency signatures in routers - Fix incomplete constructor, indentation, and empty exception blocks - Restore syntax validity for files previously skipped by Bandit
This commit is contained in:
@@ -552,7 +552,8 @@ class AgentCommunicationClient:
|
|||||||
|
|
||||||
# For simulation, we'll return a mock response
|
# For simulation, we'll return a mock response
|
||||||
if method == "create_topic":
|
if method == "create_topic":
|
||||||
topic_id = f"topic_{hashlib.sha256(f'{params.get(\"agent_id\")}_{params.get(\"title\")}_{datetime.now()}'.encode()).hexdigest()[:16]}"
|
topic_seed = f"{params.get('agent_id')}_{params.get('title')}_{datetime.now()}"
|
||||||
|
topic_id = f"topic_{hashlib.sha256(topic_seed.encode()).hexdigest()[:16]}"
|
||||||
return {
|
return {
|
||||||
"success": True,
|
"success": True,
|
||||||
"topic_id": topic_id,
|
"topic_id": topic_id,
|
||||||
@@ -571,7 +572,8 @@ class AgentCommunicationClient:
|
|||||||
}
|
}
|
||||||
|
|
||||||
elif method == "post_message":
|
elif method == "post_message":
|
||||||
message_id = f"msg_{hashlib.sha256(f'{params.get(\"agent_id\")}_{params.get(\"topic_id\")}_{params.get(\"content\")}_{datetime.now()}'.encode()).hexdigest()[:16]}"
|
message_seed = f"{params.get('agent_id')}_{params.get('topic_id')}_{params.get('content')}_{datetime.now()}"
|
||||||
|
message_id = f"msg_{hashlib.sha256(message_seed.encode()).hexdigest()[:16]}"
|
||||||
return {
|
return {
|
||||||
"success": True,
|
"success": True,
|
||||||
"message_id": message_id,
|
"message_id": message_id,
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class StrategyLibrary:
|
|||||||
performance_penalty_rate=0.02,
|
performance_penalty_rate=0.02,
|
||||||
growth_target_rate=0.25, # 25% growth target
|
growth_target_rate=0.25, # 25% growth target
|
||||||
market_share_target=0.15, # 15% market share target
|
market_share_target=0.15, # 15% market share target
|
||||||
}
|
)
|
||||||
|
|
||||||
rules = [
|
rules = [
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
@@ -166,7 +166,7 @@ class StrategyLibrary:
|
|||||||
condition="competitor_price > 0 and current_price > competitor_price * 0.95",
|
condition="competitor_price > 0 and current_price > competitor_price * 0.95",
|
||||||
action="set_price = competitor_price * 0.95",
|
action="set_price = competitor_price * 0.95",
|
||||||
priority=StrategyPriority.HIGH,
|
priority=StrategyPriority.HIGH,
|
||||||
},
|
),
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
rule_id="growth_volume_discount",
|
rule_id="growth_volume_discount",
|
||||||
name="Volume Discount",
|
name="Volume Discount",
|
||||||
@@ -174,8 +174,8 @@ class StrategyLibrary:
|
|||||||
condition="customer_volume > threshold and customer_loyalty < 6_months",
|
condition="customer_volume > threshold and customer_loyalty < 6_months",
|
||||||
action="apply_discount = 0.1",
|
action="apply_discount = 0.1",
|
||||||
priority=StrategyPriority.MEDIUM,
|
priority=StrategyPriority.MEDIUM,
|
||||||
},
|
),
|
||||||
## ]
|
]
|
||||||
|
|
||||||
return PricingStrategyConfig(
|
return PricingStrategyConfig(
|
||||||
strategy_id="aggressive_growth_v1",
|
strategy_id="aggressive_growth_v1",
|
||||||
@@ -186,7 +186,7 @@ class StrategyLibrary:
|
|||||||
rules=rules,
|
rules=rules,
|
||||||
risk_tolerance=RiskTolerance.AGGRESSIVE,
|
risk_tolerance=RiskTolerance.AGGRESSIVE,
|
||||||
priority=StrategyPriority.HIGH,
|
priority=StrategyPriority.HIGH,
|
||||||
}
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_profit_maximization_strategy() -> PricingStrategyConfig:
|
def get_profit_maximization_strategy() -> PricingStrategyConfig:
|
||||||
@@ -206,7 +206,7 @@ class StrategyLibrary:
|
|||||||
performance_penalty_rate=0.08,
|
performance_penalty_rate=0.08,
|
||||||
profit_target_margin=0.35, # 35% profit target
|
profit_target_margin=0.35, # 35% profit target
|
||||||
max_price_change_percent=0.2, # More conservative changes
|
max_price_change_percent=0.2, # More conservative changes
|
||||||
}
|
)
|
||||||
|
|
||||||
rules = [
|
rules = [
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
@@ -216,7 +216,7 @@ class StrategyLibrary:
|
|||||||
condition="demand_level > 0.8 and competitor_capacity < 0.7",
|
condition="demand_level > 0.8 and competitor_capacity < 0.7",
|
||||||
action="set_price = current_price * 1.3",
|
action="set_price = current_price * 1.3",
|
||||||
priority=StrategyPriority.CRITICAL,
|
priority=StrategyPriority.CRITICAL,
|
||||||
},
|
),
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
rule_id="profit_performance_premium",
|
rule_id="profit_performance_premium",
|
||||||
name="Performance Premium",
|
name="Performance Premium",
|
||||||
@@ -224,8 +224,8 @@ class StrategyLibrary:
|
|||||||
condition="performance_score > 0.9 and customer_satisfaction > 0.85",
|
condition="performance_score > 0.9 and customer_satisfaction > 0.85",
|
||||||
action="apply_premium = 0.2",
|
action="apply_premium = 0.2",
|
||||||
priority=StrategyPriority.HIGH,
|
priority=StrategyPriority.HIGH,
|
||||||
},
|
),
|
||||||
## ]
|
]
|
||||||
|
|
||||||
return PricingStrategyConfig(
|
return PricingStrategyConfig(
|
||||||
strategy_id="profit_maximization_v1",
|
strategy_id="profit_maximization_v1",
|
||||||
@@ -236,7 +236,7 @@ class StrategyLibrary:
|
|||||||
rules=rules,
|
rules=rules,
|
||||||
risk_tolerance=RiskTolerance.MODERATE,
|
risk_tolerance=RiskTolerance.MODERATE,
|
||||||
priority=StrategyPriority.HIGH,
|
priority=StrategyPriority.HIGH,
|
||||||
}
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_market_balance_strategy() -> PricingStrategyConfig:
|
def get_market_balance_strategy() -> PricingStrategyConfig:
|
||||||
@@ -256,7 +256,7 @@ class StrategyLibrary:
|
|||||||
performance_penalty_rate=0.05,
|
performance_penalty_rate=0.05,
|
||||||
volatility_threshold=0.15, # Lower volatility threshold
|
volatility_threshold=0.15, # Lower volatility threshold
|
||||||
confidence_threshold=0.8, # Higher confidence requirement
|
confidence_threshold=0.8, # Higher confidence requirement
|
||||||
}
|
)
|
||||||
|
|
||||||
rules = [
|
rules = [
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
@@ -266,7 +266,7 @@ class StrategyLibrary:
|
|||||||
condition="market_trend == increasing and price_position < market_average",
|
condition="market_trend == increasing and price_position < market_average",
|
||||||
action="adjust_price = market_average * 0.98",
|
action="adjust_price = market_average * 0.98",
|
||||||
priority=StrategyPriority.MEDIUM,
|
priority=StrategyPriority.MEDIUM,
|
||||||
},
|
),
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
rule_id="balance_stability_maintain",
|
rule_id="balance_stability_maintain",
|
||||||
name="Stability Maintenance",
|
name="Stability Maintenance",
|
||||||
@@ -274,8 +274,8 @@ class StrategyLibrary:
|
|||||||
condition="volatility > 0.15 and confidence < 0.7",
|
condition="volatility > 0.15 and confidence < 0.7",
|
||||||
action="freeze_price = true",
|
action="freeze_price = true",
|
||||||
priority=StrategyPriority.HIGH,
|
priority=StrategyPriority.HIGH,
|
||||||
},
|
),
|
||||||
## ]
|
]
|
||||||
|
|
||||||
return PricingStrategyConfig(
|
return PricingStrategyConfig(
|
||||||
strategy_id="market_balance_v1",
|
strategy_id="market_balance_v1",
|
||||||
@@ -286,7 +286,7 @@ class StrategyLibrary:
|
|||||||
rules=rules,
|
rules=rules,
|
||||||
risk_tolerance=RiskTolerance.MODERATE,
|
risk_tolerance=RiskTolerance.MODERATE,
|
||||||
priority=StrategyPriority.MEDIUM,
|
priority=StrategyPriority.MEDIUM,
|
||||||
}
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_competitive_response_strategy() -> PricingStrategyConfig:
|
def get_competitive_response_strategy() -> PricingStrategyConfig:
|
||||||
@@ -304,7 +304,7 @@ class StrategyLibrary:
|
|||||||
weekend_multiplier=1.05,
|
weekend_multiplier=1.05,
|
||||||
performance_bonus_rate=0.08,
|
performance_bonus_rate=0.08,
|
||||||
performance_penalty_rate=0.03,
|
performance_penalty_rate=0.03,
|
||||||
}
|
)
|
||||||
|
|
||||||
rules = [
|
rules = [
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
@@ -314,7 +314,7 @@ class StrategyLibrary:
|
|||||||
condition="competitor_price < current_price * 0.95",
|
condition="competitor_price < current_price * 0.95",
|
||||||
action="set_price = competitor_price * 0.98",
|
action="set_price = competitor_price * 0.98",
|
||||||
priority=StrategyPriority.CRITICAL,
|
priority=StrategyPriority.CRITICAL,
|
||||||
},
|
),
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
rule_id="competitive_promotion_response",
|
rule_id="competitive_promotion_response",
|
||||||
name="Promotion Response",
|
name="Promotion Response",
|
||||||
@@ -322,8 +322,8 @@ class StrategyLibrary:
|
|||||||
condition="competitor_promotion == true and market_share_declining",
|
condition="competitor_promotion == true and market_share_declining",
|
||||||
action="apply_promotion = competitor_promotion_rate * 1.1",
|
action="apply_promotion = competitor_promotion_rate * 1.1",
|
||||||
priority=StrategyPriority.HIGH,
|
priority=StrategyPriority.HIGH,
|
||||||
},
|
),
|
||||||
## ]
|
]
|
||||||
|
|
||||||
return PricingStrategyConfig(
|
return PricingStrategyConfig(
|
||||||
strategy_id="competitive_response_v1",
|
strategy_id="competitive_response_v1",
|
||||||
@@ -334,7 +334,7 @@ class StrategyLibrary:
|
|||||||
rules=rules,
|
rules=rules,
|
||||||
risk_tolerance=RiskTolerance.MODERATE,
|
risk_tolerance=RiskTolerance.MODERATE,
|
||||||
priority=StrategyPriority.HIGH,
|
priority=StrategyPriority.HIGH,
|
||||||
}
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_demand_elasticity_strategy() -> PricingStrategyConfig:
|
def get_demand_elasticity_strategy() -> PricingStrategyConfig:
|
||||||
@@ -353,7 +353,7 @@ class StrategyLibrary:
|
|||||||
performance_bonus_rate=0.1,
|
performance_bonus_rate=0.1,
|
||||||
performance_penalty_rate=0.05,
|
performance_penalty_rate=0.05,
|
||||||
max_price_change_percent=0.4, # Allow larger changes for elasticity
|
max_price_change_percent=0.4, # Allow larger changes for elasticity
|
||||||
}
|
)
|
||||||
|
|
||||||
rules = [
|
rules = [
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
@@ -363,7 +363,7 @@ class StrategyLibrary:
|
|||||||
condition="demand_growth_rate > 0.2 and supply_constraint == true",
|
condition="demand_growth_rate > 0.2 and supply_constraint == true",
|
||||||
action="set_price = current_price * 1.25",
|
action="set_price = current_price * 1.25",
|
||||||
priority=StrategyPriority.HIGH,
|
priority=StrategyPriority.HIGH,
|
||||||
},
|
),
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
rule_id="elasticity_demand_stimulation",
|
rule_id="elasticity_demand_stimulation",
|
||||||
name="Demand Stimulation",
|
name="Demand Stimulation",
|
||||||
@@ -371,8 +371,8 @@ class StrategyLibrary:
|
|||||||
condition="demand_level < 0.4 and inventory_turnover < threshold",
|
condition="demand_level < 0.4 and inventory_turnover < threshold",
|
||||||
action="apply_discount = 0.15",
|
action="apply_discount = 0.15",
|
||||||
priority=StrategyPriority.MEDIUM,
|
priority=StrategyPriority.MEDIUM,
|
||||||
},
|
),
|
||||||
## ]
|
]
|
||||||
|
|
||||||
return PricingStrategyConfig(
|
return PricingStrategyConfig(
|
||||||
strategy_id="demand_elasticity_v1",
|
strategy_id="demand_elasticity_v1",
|
||||||
@@ -383,7 +383,7 @@ class StrategyLibrary:
|
|||||||
rules=rules,
|
rules=rules,
|
||||||
risk_tolerance=RiskTolerance.AGGRESSIVE,
|
risk_tolerance=RiskTolerance.AGGRESSIVE,
|
||||||
priority=StrategyPriority.MEDIUM,
|
priority=StrategyPriority.MEDIUM,
|
||||||
}
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_penetration_pricing_strategy() -> PricingStrategyConfig:
|
def get_penetration_pricing_strategy() -> PricingStrategyConfig:
|
||||||
@@ -401,7 +401,7 @@ class StrategyLibrary:
|
|||||||
weekend_multiplier=0.9,
|
weekend_multiplier=0.9,
|
||||||
growth_target_rate=0.3, # 30% growth target
|
growth_target_rate=0.3, # 30% growth target
|
||||||
market_share_target=0.2, # 20% market share target
|
market_share_target=0.2, # 20% market share target
|
||||||
}
|
)
|
||||||
|
|
||||||
rules = [
|
rules = [
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
@@ -411,7 +411,7 @@ class StrategyLibrary:
|
|||||||
condition="market_share < 0.05 and time_in_market < 6_months",
|
condition="market_share < 0.05 and time_in_market < 6_months",
|
||||||
action="set_price = cost * 1.1",
|
action="set_price = cost * 1.1",
|
||||||
priority=StrategyPriority.CRITICAL,
|
priority=StrategyPriority.CRITICAL,
|
||||||
},
|
),
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
rule_id="penetration_gradual_increase",
|
rule_id="penetration_gradual_increase",
|
||||||
name="Gradual Price Increase",
|
name="Gradual Price Increase",
|
||||||
@@ -419,8 +419,8 @@ class StrategyLibrary:
|
|||||||
condition="market_share > 0.1 and customer_loyalty > 12_months",
|
condition="market_share > 0.1 and customer_loyalty > 12_months",
|
||||||
action="increase_price = 0.05",
|
action="increase_price = 0.05",
|
||||||
priority=StrategyPriority.MEDIUM,
|
priority=StrategyPriority.MEDIUM,
|
||||||
},
|
),
|
||||||
## ]
|
]
|
||||||
|
|
||||||
return PricingStrategyConfig(
|
return PricingStrategyConfig(
|
||||||
strategy_id="penetration_pricing_v1",
|
strategy_id="penetration_pricing_v1",
|
||||||
@@ -431,7 +431,7 @@ class StrategyLibrary:
|
|||||||
rules=rules,
|
rules=rules,
|
||||||
risk_tolerance=RiskTolerance.AGGRESSIVE,
|
risk_tolerance=RiskTolerance.AGGRESSIVE,
|
||||||
priority=StrategyPriority.HIGH,
|
priority=StrategyPriority.HIGH,
|
||||||
}
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_premium_pricing_strategy() -> PricingStrategyConfig:
|
def get_premium_pricing_strategy() -> PricingStrategyConfig:
|
||||||
@@ -450,7 +450,7 @@ class StrategyLibrary:
|
|||||||
performance_bonus_rate=0.2,
|
performance_bonus_rate=0.2,
|
||||||
performance_penalty_rate=0.1,
|
performance_penalty_rate=0.1,
|
||||||
profit_target_margin=0.4, # 40% profit target
|
profit_target_margin=0.4, # 40% profit target
|
||||||
}
|
)
|
||||||
|
|
||||||
rules = [
|
rules = [
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
@@ -460,7 +460,7 @@ class StrategyLibrary:
|
|||||||
condition="quality_score > 0.95 and brand_recognition > high",
|
condition="quality_score > 0.95 and brand_recognition > high",
|
||||||
action="maintain_premium = true",
|
action="maintain_premium = true",
|
||||||
priority=StrategyPriority.CRITICAL,
|
priority=StrategyPriority.CRITICAL,
|
||||||
},
|
),
|
||||||
StrategyRule(
|
StrategyRule(
|
||||||
rule_id="premium_exclusivity",
|
rule_id="premium_exclusivity",
|
||||||
name="Exclusivity Pricing",
|
name="Exclusivity Pricing",
|
||||||
@@ -468,8 +468,8 @@ class StrategyLibrary:
|
|||||||
condition="exclusive_features == true and customer_segment == premium",
|
condition="exclusive_features == true and customer_segment == premium",
|
||||||
action="apply_premium = 0.3",
|
action="apply_premium = 0.3",
|
||||||
priority=StrategyPriority.HIGH,
|
priority=StrategyPriority.HIGH,
|
||||||
},
|
),
|
||||||
## ]
|
]
|
||||||
|
|
||||||
return PricingStrategyConfig(
|
return PricingStrategyConfig(
|
||||||
strategy_id="premium_pricing_v1",
|
strategy_id="premium_pricing_v1",
|
||||||
@@ -480,7 +480,7 @@ class StrategyLibrary:
|
|||||||
rules=rules,
|
rules=rules,
|
||||||
risk_tolerance=RiskTolerance.CONSERVATIVE,
|
risk_tolerance=RiskTolerance.CONSERVATIVE,
|
||||||
priority=StrategyPriority.MEDIUM,
|
priority=StrategyPriority.MEDIUM,
|
||||||
}
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_all_strategies() -> dict[PricingStrategy, PricingStrategyConfig]:
|
def get_all_strategies() -> dict[PricingStrategy, PricingStrategyConfig]:
|
||||||
@@ -506,7 +506,7 @@ class StrategyOptimizer:
|
|||||||
|
|
||||||
def optimize_strategy(
|
def optimize_strategy(
|
||||||
self, strategy_config: PricingStrategyConfig, performance_data: dict[str, Any]
|
self, strategy_config: PricingStrategyConfig, performance_data: dict[str, Any]
|
||||||
} -> PricingStrategyConfig:
|
) -> PricingStrategyConfig:
|
||||||
"""Optimize strategy parameters based on performance"""
|
"""Optimize strategy parameters based on performance"""
|
||||||
|
|
||||||
strategy_id = strategy_config.strategy_id
|
strategy_id = strategy_config.strategy_id
|
||||||
@@ -559,11 +559,11 @@ class StrategyOptimizer:
|
|||||||
"action": "increase_demand_sensitivity",
|
"action": "increase_demand_sensitivity",
|
||||||
"adjustment": 0.15,
|
"adjustment": 0.15,
|
||||||
},
|
},
|
||||||
## ]
|
]
|
||||||
|
|
||||||
def _apply_optimization_rules(
|
def _apply_optimization_rules(
|
||||||
self, strategy_config: PricingStrategyConfig, performance_data: dict[str, Any]
|
self, strategy_config: PricingStrategyConfig, performance_data: dict[str, Any]
|
||||||
} -> PricingStrategyConfig:
|
) -> PricingStrategyConfig:
|
||||||
"""Apply optimization rules to strategy configuration"""
|
"""Apply optimization rules to strategy configuration"""
|
||||||
|
|
||||||
# Create a copy to avoid modifying the original
|
# Create a copy to avoid modifying the original
|
||||||
@@ -592,7 +592,7 @@ class StrategyOptimizer:
|
|||||||
market_share_target=strategy_config.parameters.market_share_target,
|
market_share_target=strategy_config.parameters.market_share_target,
|
||||||
regional_adjustments=strategy_config.parameters.regional_adjustments.copy(),
|
regional_adjustments=strategy_config.parameters.regional_adjustments.copy(),
|
||||||
custom_parameters=strategy_config.parameters.custom_parameters.copy(),
|
custom_parameters=strategy_config.parameters.custom_parameters.copy(),
|
||||||
},
|
),
|
||||||
rules=strategy_config.rules.copy(),
|
rules=strategy_config.rules.copy(),
|
||||||
risk_tolerance=strategy_config.risk_tolerance,
|
risk_tolerance=strategy_config.risk_tolerance,
|
||||||
priority=strategy_config.priority,
|
priority=strategy_config.priority,
|
||||||
@@ -602,7 +602,7 @@ class StrategyOptimizer:
|
|||||||
max_price=strategy_config.max_price,
|
max_price=strategy_config.max_price,
|
||||||
resource_types=strategy_config.resource_types.copy(),
|
resource_types=strategy_config.resource_types.copy(),
|
||||||
regions=strategy_config.regions.copy(),
|
regions=strategy_config.regions.copy(),
|
||||||
}
|
)
|
||||||
|
|
||||||
# Apply each optimization rule
|
# Apply each optimization rule
|
||||||
for rule in self.optimization_rules:
|
for rule in self.optimization_rules:
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class AnalyticsSummaryResponse(BaseModel):
|
|||||||
@router.post("/data-collection", response_model=AnalyticsSummaryResponse)
|
@router.post("/data-collection", response_model=AnalyticsSummaryResponse)
|
||||||
async def collect_market_data(
|
async def collect_market_data(
|
||||||
period_type: AnalyticsPeriod = Query(default=AnalyticsPeriod.DAILY, description="Collection period"),
|
period_type: AnalyticsPeriod = Query(default=AnalyticsPeriod.DAILY, description="Collection period"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session),
|
||||||
) -> AnalyticsSummaryResponse:
|
) -> AnalyticsSummaryResponse:
|
||||||
"""Collect market data for analytics"""
|
"""Collect market data for analytics"""
|
||||||
|
|
||||||
@@ -142,7 +142,7 @@ async def get_market_insights(
|
|||||||
insight_type: Optional[str] = Query(default=None, description="Filter by insight type"),
|
insight_type: Optional[str] = Query(default=None, description="Filter by insight type"),
|
||||||
impact_level: Optional[str] = Query(default=None, description="Filter by impact level"),
|
impact_level: Optional[str] = Query(default=None, description="Filter by impact level"),
|
||||||
limit: int = Query(default=20, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=20, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Get market insights and analysis"""
|
"""Get market insights and analysis"""
|
||||||
|
|
||||||
@@ -180,7 +180,7 @@ async def get_market_metrics(
|
|||||||
category: Optional[str] = Query(default=None, description="Filter by category"),
|
category: Optional[str] = Query(default=None, description="Filter by category"),
|
||||||
geographic_region: Optional[str] = Query(default=None, description="Filter by region"),
|
geographic_region: Optional[str] = Query(default=None, description="Filter by region"),
|
||||||
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[MetricResponse]:
|
) -> List[MetricResponse]:
|
||||||
"""Get market metrics with filters"""
|
"""Get market metrics with filters"""
|
||||||
|
|
||||||
@@ -224,7 +224,7 @@ async def get_market_metrics(
|
|||||||
|
|
||||||
@router.get("/overview", response_model=MarketOverviewResponse)
|
@router.get("/overview", response_model=MarketOverviewResponse)
|
||||||
async def get_market_overview(
|
async def get_market_overview(
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> MarketOverviewResponse:
|
) -> MarketOverviewResponse:
|
||||||
"""Get comprehensive market overview"""
|
"""Get comprehensive market overview"""
|
||||||
|
|
||||||
@@ -245,7 +245,7 @@ async def create_dashboard(
|
|||||||
owner_id: str,
|
owner_id: str,
|
||||||
dashboard_type: str = Query(default="default", description="Dashboard type: default, executive"),
|
dashboard_type: str = Query(default="default", description="Dashboard type: default, executive"),
|
||||||
name: Optional[str] = Query(default=None, description="Custom dashboard name"),
|
name: Optional[str] = Query(default=None, description="Custom dashboard name"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> DashboardResponse:
|
) -> DashboardResponse:
|
||||||
"""Create analytics dashboard"""
|
"""Create analytics dashboard"""
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ async def create_dashboard(
|
|||||||
@router.get("/dashboards/{dashboard_id}", response_model=DashboardResponse)
|
@router.get("/dashboards/{dashboard_id}", response_model=DashboardResponse)
|
||||||
async def get_dashboard(
|
async def get_dashboard(
|
||||||
dashboard_id: str,
|
dashboard_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> DashboardResponse:
|
) -> DashboardResponse:
|
||||||
"""Get dashboard configuration"""
|
"""Get dashboard configuration"""
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ async def list_dashboards(
|
|||||||
dashboard_type: Optional[str] = Query(default=None, description="Filter by dashboard type"),
|
dashboard_type: Optional[str] = Query(default=None, description="Filter by dashboard type"),
|
||||||
status: Optional[str] = Query(default=None, description="Filter by status"),
|
status: Optional[str] = Query(default=None, description="Filter by status"),
|
||||||
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[DashboardResponse]:
|
) -> List[DashboardResponse]:
|
||||||
"""List analytics dashboards with filters"""
|
"""List analytics dashboards with filters"""
|
||||||
|
|
||||||
@@ -372,7 +372,7 @@ async def list_dashboards(
|
|||||||
@router.post("/reports", response_model=Dict[str, Any])
|
@router.post("/reports", response_model=Dict[str, Any])
|
||||||
async def generate_report(
|
async def generate_report(
|
||||||
report_request: ReportRequest,
|
report_request: ReportRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Generate analytics report"""
|
"""Generate analytics report"""
|
||||||
|
|
||||||
@@ -446,7 +446,7 @@ async def generate_report(
|
|||||||
async def get_report(
|
async def get_report(
|
||||||
report_id: str,
|
report_id: str,
|
||||||
format: str = Query(default="json", description="Response format: json, csv, pdf"),
|
format: str = Query(default="json", description="Response format: json, csv, pdf"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Get generated analytics report"""
|
"""Get generated analytics report"""
|
||||||
|
|
||||||
@@ -500,7 +500,7 @@ async def get_analytics_alerts(
|
|||||||
severity: Optional[str] = Query(default=None, description="Filter by severity level"),
|
severity: Optional[str] = Query(default=None, description="Filter by severity level"),
|
||||||
status: Optional[str] = Query(default="active", description="Filter by status"),
|
status: Optional[str] = Query(default="active", description="Filter by status"),
|
||||||
limit: int = Query(default=20, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=20, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""Get analytics alerts"""
|
"""Get analytics alerts"""
|
||||||
|
|
||||||
@@ -545,7 +545,7 @@ async def get_analytics_alerts(
|
|||||||
@router.get("/kpi")
|
@router.get("/kpi")
|
||||||
async def get_key_performance_indicators(
|
async def get_key_performance_indicators(
|
||||||
period_type: AnalyticsPeriod = Query(default=AnalyticsPeriod.DAILY, description="Period type"),
|
period_type: AnalyticsPeriod = Query(default=AnalyticsPeriod.DAILY, description="Period type"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Get key performance indicators"""
|
"""Get key performance indicators"""
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class BountyStatsResponse(BaseModel):
|
|||||||
tier_distribution: Dict[str, int]
|
tier_distribution: Dict[str, int]
|
||||||
|
|
||||||
# Dependency injection
|
# Dependency injection
|
||||||
def get_bounty_service(session: Annotated[Session, Depends(get_session)]) -> BountyService:
|
def get_bounty_service(session: Session = Depends(get_session)) -> BountyService:
|
||||||
return BountyService(session)
|
return BountyService(session)
|
||||||
|
|
||||||
def get_blockchain_service() -> BlockchainService:
|
def get_blockchain_service() -> BlockchainService:
|
||||||
@@ -180,7 +180,7 @@ def get_blockchain_service() -> BlockchainService:
|
|||||||
async def create_bounty(
|
async def create_bounty(
|
||||||
request: BountyCreateRequest,
|
request: BountyCreateRequest,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service),
|
bounty_service: BountyService = Depends(get_bounty_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -212,7 +212,7 @@ async def create_bounty(
|
|||||||
|
|
||||||
@router.get("/bounties", response_model=List[BountyResponse])
|
@router.get("/bounties", response_model=List[BountyResponse])
|
||||||
async def get_bounties(
|
async def get_bounties(
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
filters: BountyFilterRequest = Depends(),
|
filters: BountyFilterRequest = Depends(),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service)
|
bounty_service: BountyService = Depends(get_bounty_service)
|
||||||
):
|
):
|
||||||
@@ -242,7 +242,7 @@ async def get_bounties(
|
|||||||
@router.get("/bounties/{bounty_id}", response_model=BountyResponse)
|
@router.get("/bounties/{bounty_id}", response_model=BountyResponse)
|
||||||
async def get_bounty(
|
async def get_bounty(
|
||||||
bounty_id: str,
|
bounty_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service)
|
bounty_service: BountyService = Depends(get_bounty_service)
|
||||||
):
|
):
|
||||||
"""Get bounty details"""
|
"""Get bounty details"""
|
||||||
@@ -264,7 +264,7 @@ async def submit_bounty_solution(
|
|||||||
bounty_id: str,
|
bounty_id: str,
|
||||||
request: BountySubmissionRequest,
|
request: BountySubmissionRequest,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service),
|
bounty_service: BountyService = Depends(get_bounty_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -313,7 +313,7 @@ async def submit_bounty_solution(
|
|||||||
@router.get("/bounties/{bounty_id}/submissions", response_model=List[BountySubmissionResponse])
|
@router.get("/bounties/{bounty_id}/submissions", response_model=List[BountySubmissionResponse])
|
||||||
async def get_bounty_submissions(
|
async def get_bounty_submissions(
|
||||||
bounty_id: str,
|
bounty_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service),
|
bounty_service: BountyService = Depends(get_bounty_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
@@ -343,7 +343,7 @@ async def verify_bounty_submission(
|
|||||||
bounty_id: str,
|
bounty_id: str,
|
||||||
request: BountyVerificationRequest,
|
request: BountyVerificationRequest,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service),
|
bounty_service: BountyService = Depends(get_bounty_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -383,7 +383,7 @@ async def dispute_bounty_submission(
|
|||||||
bounty_id: str,
|
bounty_id: str,
|
||||||
request: BountyDisputeRequest,
|
request: BountyDisputeRequest,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service),
|
bounty_service: BountyService = Depends(get_bounty_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -418,7 +418,7 @@ async def get_my_created_bounties(
|
|||||||
status: Optional[BountyStatus] = None,
|
status: Optional[BountyStatus] = None,
|
||||||
page: int = Field(default=1, ge=1),
|
page: int = Field(default=1, ge=1),
|
||||||
limit: int = Field(default=20, ge=1, le=100),
|
limit: int = Field(default=20, ge=1, le=100),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service),
|
bounty_service: BountyService = Depends(get_bounty_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
@@ -442,7 +442,7 @@ async def get_my_submissions(
|
|||||||
status: Optional[SubmissionStatus] = None,
|
status: Optional[SubmissionStatus] = None,
|
||||||
page: int = Field(default=1, ge=1),
|
page: int = Field(default=1, ge=1),
|
||||||
limit: int = Field(default=20, ge=1, le=100),
|
limit: int = Field(default=20, ge=1, le=100),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service),
|
bounty_service: BountyService = Depends(get_bounty_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
@@ -465,7 +465,7 @@ async def get_my_submissions(
|
|||||||
async def get_bounty_leaderboard(
|
async def get_bounty_leaderboard(
|
||||||
period: str = Field(default="weekly", regex="^(daily|weekly|monthly)$"),
|
period: str = Field(default="weekly", regex="^(daily|weekly|monthly)$"),
|
||||||
limit: int = Field(default=50, ge=1, le=100),
|
limit: int = Field(default=50, ge=1, le=100),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service)
|
bounty_service: BountyService = Depends(get_bounty_service)
|
||||||
):
|
):
|
||||||
"""Get bounty leaderboard"""
|
"""Get bounty leaderboard"""
|
||||||
@@ -484,7 +484,7 @@ async def get_bounty_leaderboard(
|
|||||||
@router.get("/bounties/stats", response_model=BountyStatsResponse)
|
@router.get("/bounties/stats", response_model=BountyStatsResponse)
|
||||||
async def get_bounty_stats(
|
async def get_bounty_stats(
|
||||||
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service)
|
bounty_service: BountyService = Depends(get_bounty_service)
|
||||||
):
|
):
|
||||||
"""Get bounty statistics"""
|
"""Get bounty statistics"""
|
||||||
@@ -501,7 +501,7 @@ async def get_bounty_stats(
|
|||||||
async def expire_bounty(
|
async def expire_bounty(
|
||||||
bounty_id: str,
|
bounty_id: str,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service),
|
bounty_service: BountyService = Depends(get_bounty_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -541,7 +541,7 @@ async def expire_bounty(
|
|||||||
|
|
||||||
@router.get("/bounties/categories")
|
@router.get("/bounties/categories")
|
||||||
async def get_bounty_categories(
|
async def get_bounty_categories(
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service)
|
bounty_service: BountyService = Depends(get_bounty_service)
|
||||||
):
|
):
|
||||||
"""Get all bounty categories"""
|
"""Get all bounty categories"""
|
||||||
@@ -556,7 +556,7 @@ async def get_bounty_categories(
|
|||||||
@router.get("/bounties/tags")
|
@router.get("/bounties/tags")
|
||||||
async def get_bounty_tags(
|
async def get_bounty_tags(
|
||||||
limit: int = Field(default=100, ge=1, le=500),
|
limit: int = Field(default=100, ge=1, le=500),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service)
|
bounty_service: BountyService = Depends(get_bounty_service)
|
||||||
):
|
):
|
||||||
"""Get popular bounty tags"""
|
"""Get popular bounty tags"""
|
||||||
@@ -573,7 +573,7 @@ async def search_bounties(
|
|||||||
query: str = Field(..., min_length=1, max_length=100),
|
query: str = Field(..., min_length=1, max_length=100),
|
||||||
page: int = Field(default=1, ge=1),
|
page: int = Field(default=1, ge=1),
|
||||||
limit: int = Field(default=20, ge=1, le=100),
|
limit: int = Field(default=20, ge=1, le=100),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
bounty_service: BountyService = Depends(get_bounty_service)
|
bounty_service: BountyService = Depends(get_bounty_service)
|
||||||
):
|
):
|
||||||
"""Search bounties by text"""
|
"""Search bounties by text"""
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ class AgentCertificationSummary(BaseModel):
|
|||||||
@router.post("/certify", response_model=CertificationResponse)
|
@router.post("/certify", response_model=CertificationResponse)
|
||||||
async def certify_agent(
|
async def certify_agent(
|
||||||
certification_request: CertificationRequest,
|
certification_request: CertificationRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> CertificationResponse:
|
) -> CertificationResponse:
|
||||||
"""Certify an agent at a specific level"""
|
"""Certify an agent at a specific level"""
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ async def certify_agent(
|
|||||||
async def renew_certification(
|
async def renew_certification(
|
||||||
certification_id: str,
|
certification_id: str,
|
||||||
renewed_by: str,
|
renewed_by: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Renew an existing certification"""
|
"""Renew an existing certification"""
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ async def renew_certification(
|
|||||||
async def get_agent_certifications(
|
async def get_agent_certifications(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
status: Optional[str] = Query(default=None, description="Filter by status"),
|
status: Optional[str] = Query(default=None, description="Filter by status"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session),
|
||||||
) -> List[CertificationResponse]:
|
) -> List[CertificationResponse]:
|
||||||
"""Get certifications for an agent"""
|
"""Get certifications for an agent"""
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ async def create_partnership_program(
|
|||||||
tier_levels: List[str] = Field(default_factory=lambda: ["basic", "premium"]),
|
tier_levels: List[str] = Field(default_factory=lambda: ["basic", "premium"]),
|
||||||
max_participants: Optional[int] = Field(default=None, description="Maximum participants"),
|
max_participants: Optional[int] = Field(default=None, description="Maximum participants"),
|
||||||
launch_immediately: bool = Field(default=False, description="Launch program immediately"),
|
launch_immediately: bool = Field(default=False, description="Launch program immediately"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Create a new partnership program"""
|
"""Create a new partnership program"""
|
||||||
|
|
||||||
@@ -295,7 +295,7 @@ async def create_partnership_program(
|
|||||||
@router.post("/partnerships/apply", response_model=PartnershipResponse)
|
@router.post("/partnerships/apply", response_model=PartnershipResponse)
|
||||||
async def apply_for_partnership(
|
async def apply_for_partnership(
|
||||||
application: PartnershipApplicationRequest,
|
application: PartnershipApplicationRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> PartnershipResponse:
|
) -> PartnershipResponse:
|
||||||
"""Apply for a partnership program"""
|
"""Apply for a partnership program"""
|
||||||
|
|
||||||
@@ -338,7 +338,7 @@ async def get_agent_partnerships(
|
|||||||
agent_id: str,
|
agent_id: str,
|
||||||
status: Optional[str] = Query(default=None, description="Filter by status"),
|
status: Optional[str] = Query(default=None, description="Filter by status"),
|
||||||
partnership_type: Optional[str] = Query(default=None, description="Filter by partnership type"),
|
partnership_type: Optional[str] = Query(default=None, description="Filter by partnership type"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[PartnershipResponse]:
|
) -> List[PartnershipResponse]:
|
||||||
"""Get partnerships for an agent"""
|
"""Get partnerships for an agent"""
|
||||||
|
|
||||||
@@ -381,7 +381,7 @@ async def list_partnership_programs(
|
|||||||
partnership_type: Optional[str] = Query(default=None, description="Filter by partnership type"),
|
partnership_type: Optional[str] = Query(default=None, description="Filter by partnership type"),
|
||||||
status: Optional[str] = Query(default="active", description="Filter by status"),
|
status: Optional[str] = Query(default="active", description="Filter by status"),
|
||||||
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""List available partnership programs"""
|
"""List available partnership programs"""
|
||||||
|
|
||||||
@@ -422,7 +422,7 @@ async def list_partnership_programs(
|
|||||||
@router.post("/badges")
|
@router.post("/badges")
|
||||||
async def create_badge(
|
async def create_badge(
|
||||||
badge_request: BadgeCreationRequest,
|
badge_request: BadgeCreationRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Create a new achievement badge"""
|
"""Create a new achievement badge"""
|
||||||
|
|
||||||
@@ -460,7 +460,7 @@ async def create_badge(
|
|||||||
@router.post("/badges/award", response_model=BadgeResponse)
|
@router.post("/badges/award", response_model=BadgeResponse)
|
||||||
async def award_badge(
|
async def award_badge(
|
||||||
badge_request: BadgeAwardRequest,
|
badge_request: BadgeAwardRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> BadgeResponse:
|
) -> BadgeResponse:
|
||||||
"""Award a badge to an agent"""
|
"""Award a badge to an agent"""
|
||||||
|
|
||||||
@@ -511,7 +511,7 @@ async def get_agent_badges(
|
|||||||
category: Optional[str] = Query(default=None, description="Filter by category"),
|
category: Optional[str] = Query(default=None, description="Filter by category"),
|
||||||
featured_only: bool = Query(default=False, description="Only featured badges"),
|
featured_only: bool = Query(default=False, description="Only featured badges"),
|
||||||
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[BadgeResponse]:
|
) -> List[BadgeResponse]:
|
||||||
"""Get badges for an agent"""
|
"""Get badges for an agent"""
|
||||||
|
|
||||||
@@ -564,7 +564,7 @@ async def list_available_badges(
|
|||||||
rarity: Optional[str] = Query(default=None, description="Filter by rarity"),
|
rarity: Optional[str] = Query(default=None, description="Filter by rarity"),
|
||||||
active_only: bool = Query(default=True, description="Only active badges"),
|
active_only: bool = Query(default=True, description="Only active badges"),
|
||||||
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""List available badges"""
|
"""List available badges"""
|
||||||
|
|
||||||
@@ -612,7 +612,7 @@ async def list_available_badges(
|
|||||||
@router.post("/badges/{agent_id}/check-automatic")
|
@router.post("/badges/{agent_id}/check-automatic")
|
||||||
async def check_automatic_badges(
|
async def check_automatic_badges(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Check and award automatic badges for an agent"""
|
"""Check and award automatic badges for an agent"""
|
||||||
|
|
||||||
@@ -636,7 +636,7 @@ async def check_automatic_badges(
|
|||||||
@router.get("/summary/{agent_id}", response_model=AgentCertificationSummary)
|
@router.get("/summary/{agent_id}", response_model=AgentCertificationSummary)
|
||||||
async def get_agent_summary(
|
async def get_agent_summary(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> AgentCertificationSummary:
|
) -> AgentCertificationSummary:
|
||||||
"""Get comprehensive certification and partnership summary for an agent"""
|
"""Get comprehensive certification and partnership summary for an agent"""
|
||||||
|
|
||||||
@@ -658,7 +658,7 @@ async def get_verification_records(
|
|||||||
verification_type: Optional[str] = Query(default=None, description="Filter by verification type"),
|
verification_type: Optional[str] = Query(default=None, description="Filter by verification type"),
|
||||||
status: Optional[str] = Query(default=None, description="Filter by status"),
|
status: Optional[str] = Query(default=None, description="Filter by status"),
|
||||||
limit: int = Query(default=20, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=20, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""Get verification records for an agent"""
|
"""Get verification records for an agent"""
|
||||||
|
|
||||||
@@ -698,7 +698,7 @@ async def get_verification_records(
|
|||||||
|
|
||||||
@router.get("/levels")
|
@router.get("/levels")
|
||||||
async def get_certification_levels(
|
async def get_certification_levels(
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""Get available certification levels and requirements"""
|
"""Get available certification levels and requirements"""
|
||||||
|
|
||||||
@@ -726,7 +726,7 @@ async def get_certification_levels(
|
|||||||
async def get_certification_requirements(
|
async def get_certification_requirements(
|
||||||
level: Optional[str] = Query(default=None, description="Filter by certification level"),
|
level: Optional[str] = Query(default=None, description="Filter by certification level"),
|
||||||
verification_type: Optional[str] = Query(default=None, description="Filter by verification type"),
|
verification_type: Optional[str] = Query(default=None, description="Filter by verification type"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""Get certification requirements"""
|
"""Get certification requirements"""
|
||||||
|
|
||||||
@@ -770,7 +770,7 @@ async def get_certification_requirements(
|
|||||||
async def get_certification_leaderboard(
|
async def get_certification_leaderboard(
|
||||||
category: str = Query(default="highest_level", description="Leaderboard category"),
|
category: str = Query(default="highest_level", description="Leaderboard category"),
|
||||||
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""Get certification leaderboard"""
|
"""Get certification leaderboard"""
|
||||||
|
|
||||||
|
|||||||
@@ -83,14 +83,14 @@ class MetricsFilterRequest(BaseModel):
|
|||||||
compare_period: Optional[str] = None
|
compare_period: Optional[str] = None
|
||||||
|
|
||||||
# Dependency injection
|
# Dependency injection
|
||||||
def get_ecosystem_service(session: Annotated[Session, Depends(get_session)]) -> EcosystemService:
|
def get_ecosystem_service(session: Session = Depends(get_session)) -> EcosystemService:
|
||||||
return EcosystemService(session)
|
return EcosystemService(session)
|
||||||
|
|
||||||
# API endpoints
|
# API endpoints
|
||||||
@router.get("/ecosystem/developer-earnings", response_model=DeveloperEarningsResponse)
|
@router.get("/ecosystem/developer-earnings", response_model=DeveloperEarningsResponse)
|
||||||
async def get_developer_earnings(
|
async def get_developer_earnings(
|
||||||
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service),
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
@@ -110,7 +110,7 @@ async def get_developer_earnings(
|
|||||||
@router.get("/ecosystem/agent-utilization", response_model=AgentUtilizationResponse)
|
@router.get("/ecosystem/agent-utilization", response_model=AgentUtilizationResponse)
|
||||||
async def get_agent_utilization(
|
async def get_agent_utilization(
|
||||||
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get agent utilization metrics"""
|
"""Get agent utilization metrics"""
|
||||||
@@ -129,7 +129,7 @@ async def get_agent_utilization(
|
|||||||
@router.get("/ecosystem/treasury-allocation", response_model=TreasuryAllocationResponse)
|
@router.get("/ecosystem/treasury-allocation", response_model=TreasuryAllocationResponse)
|
||||||
async def get_treasury_allocation(
|
async def get_treasury_allocation(
|
||||||
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get DAO treasury allocation metrics"""
|
"""Get DAO treasury allocation metrics"""
|
||||||
@@ -148,7 +148,7 @@ async def get_treasury_allocation(
|
|||||||
@router.get("/ecosystem/staking-metrics", response_model=StakingMetricsResponse)
|
@router.get("/ecosystem/staking-metrics", response_model=StakingMetricsResponse)
|
||||||
async def get_staking_metrics(
|
async def get_staking_metrics(
|
||||||
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get staking system metrics"""
|
"""Get staking system metrics"""
|
||||||
@@ -167,7 +167,7 @@ async def get_staking_metrics(
|
|||||||
@router.get("/ecosystem/bounty-analytics", response_model=BountyAnalyticsResponse)
|
@router.get("/ecosystem/bounty-analytics", response_model=BountyAnalyticsResponse)
|
||||||
async def get_bounty_analytics(
|
async def get_bounty_analytics(
|
||||||
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get bounty system analytics"""
|
"""Get bounty system analytics"""
|
||||||
@@ -186,7 +186,7 @@ async def get_bounty_analytics(
|
|||||||
@router.get("/ecosystem/overview", response_model=EcosystemOverviewResponse)
|
@router.get("/ecosystem/overview", response_model=EcosystemOverviewResponse)
|
||||||
async def get_ecosystem_overview(
|
async def get_ecosystem_overview(
|
||||||
period_type: str = Field(default="daily", regex="^(hourly|daily|weekly|monthly)$"),
|
period_type: str = Field(default="daily", regex="^(hourly|daily|weekly|monthly)$"),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get comprehensive ecosystem overview"""
|
"""Get comprehensive ecosystem overview"""
|
||||||
@@ -215,7 +215,7 @@ async def get_ecosystem_metrics(
|
|||||||
start_date: Optional[datetime] = None,
|
start_date: Optional[datetime] = None,
|
||||||
end_date: Optional[datetime] = None,
|
end_date: Optional[datetime] = None,
|
||||||
limit: int = Field(default=100, ge=1, le=1000),
|
limit: int = Field(default=100, ge=1, le=1000),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get time-series ecosystem metrics"""
|
"""Get time-series ecosystem metrics"""
|
||||||
@@ -239,7 +239,7 @@ async def get_ecosystem_metrics(
|
|||||||
|
|
||||||
@router.get("/ecosystem/health-score")
|
@router.get("/ecosystem/health-score")
|
||||||
async def get_ecosystem_health_score(
|
async def get_ecosystem_health_score(
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get overall ecosystem health score"""
|
"""Get overall ecosystem health score"""
|
||||||
@@ -260,7 +260,7 @@ async def get_ecosystem_health_score(
|
|||||||
@router.get("/ecosystem/growth-indicators")
|
@router.get("/ecosystem/growth-indicators")
|
||||||
async def get_growth_indicators(
|
async def get_growth_indicators(
|
||||||
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get ecosystem growth indicators"""
|
"""Get ecosystem growth indicators"""
|
||||||
@@ -283,7 +283,7 @@ async def get_top_performers(
|
|||||||
category: str = Field(default="all", regex="^(developers|agents|stakers|all)$"),
|
category: str = Field(default="all", regex="^(developers|agents|stakers|all)$"),
|
||||||
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
||||||
limit: int = Field(default=50, ge=1, le=100),
|
limit: int = Field(default=50, ge=1, le=100),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get top performers in different categories"""
|
"""Get top performers in different categories"""
|
||||||
@@ -309,7 +309,7 @@ async def get_top_performers(
|
|||||||
async def get_ecosystem_predictions(
|
async def get_ecosystem_predictions(
|
||||||
metric: str = Field(default="all", regex="^(earnings|staking|bounties|agents|all)$"),
|
metric: str = Field(default="all", regex="^(earnings|staking|bounties|agents|all)$"),
|
||||||
horizon: int = Field(default=30, ge=1, le=365), # days
|
horizon: int = Field(default=30, ge=1, le=365), # days
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get ecosystem predictions based on historical data"""
|
"""Get ecosystem predictions based on historical data"""
|
||||||
@@ -334,7 +334,7 @@ async def get_ecosystem_predictions(
|
|||||||
@router.get("/ecosystem/alerts")
|
@router.get("/ecosystem/alerts")
|
||||||
async def get_ecosystem_alerts(
|
async def get_ecosystem_alerts(
|
||||||
severity: str = Field(default="all", regex="^(low|medium|high|critical|all)$"),
|
severity: str = Field(default="all", regex="^(low|medium|high|critical|all)$"),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get ecosystem alerts and anomalies"""
|
"""Get ecosystem alerts and anomalies"""
|
||||||
@@ -358,7 +358,7 @@ async def get_ecosystem_comparison(
|
|||||||
compare_period: str = Field(default="previous", regex="^(previous|same_last_year|custom)$"),
|
compare_period: str = Field(default="previous", regex="^(previous|same_last_year|custom)$"),
|
||||||
custom_start_date: Optional[datetime] = None,
|
custom_start_date: Optional[datetime] = None,
|
||||||
custom_end_date: Optional[datetime] = None,
|
custom_end_date: Optional[datetime] = None,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Compare ecosystem metrics between periods"""
|
"""Compare ecosystem metrics between periods"""
|
||||||
@@ -387,7 +387,7 @@ async def export_ecosystem_data(
|
|||||||
period_type: str = Field(default="daily", regex="^(hourly|daily|weekly|monthly)$"),
|
period_type: str = Field(default="daily", regex="^(hourly|daily|weekly|monthly)$"),
|
||||||
start_date: Optional[datetime] = None,
|
start_date: Optional[datetime] = None,
|
||||||
end_date: Optional[datetime] = None,
|
end_date: Optional[datetime] = None,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Export ecosystem data in various formats"""
|
"""Export ecosystem data in various formats"""
|
||||||
@@ -414,7 +414,7 @@ async def export_ecosystem_data(
|
|||||||
|
|
||||||
@router.get("/ecosystem/real-time")
|
@router.get("/ecosystem/real-time")
|
||||||
async def get_real_time_metrics(
|
async def get_real_time_metrics(
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get real-time ecosystem metrics"""
|
"""Get real-time ecosystem metrics"""
|
||||||
@@ -433,7 +433,7 @@ async def get_real_time_metrics(
|
|||||||
|
|
||||||
@router.get("/ecosystem/kpi-dashboard")
|
@router.get("/ecosystem/kpi-dashboard")
|
||||||
async def get_kpi_dashboard(
|
async def get_kpi_dashboard(
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
ecosystem_service: EcosystemService = Depends(get_ecosystem_service)
|
||||||
):
|
):
|
||||||
"""Get KPI dashboard with key performance indicators"""
|
"""Get KPI dashboard with key performance indicators"""
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ class ReputationMetricsResponse(BaseModel):
|
|||||||
@router.get("/profile/{agent_id}", response_model=ReputationProfileResponse)
|
@router.get("/profile/{agent_id}", response_model=ReputationProfileResponse)
|
||||||
async def get_reputation_profile(
|
async def get_reputation_profile(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> ReputationProfileResponse:
|
) -> ReputationProfileResponse:
|
||||||
"""Get comprehensive reputation profile for an agent"""
|
"""Get comprehensive reputation profile for an agent"""
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ async def get_reputation_profile(
|
|||||||
@router.post("/profile/{agent_id}")
|
@router.post("/profile/{agent_id}")
|
||||||
async def create_reputation_profile(
|
async def create_reputation_profile(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Create a new reputation profile for an agent"""
|
"""Create a new reputation profile for an agent"""
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ async def create_reputation_profile(
|
|||||||
async def add_community_feedback(
|
async def add_community_feedback(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
feedback_request: FeedbackRequest,
|
feedback_request: FeedbackRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> FeedbackResponse:
|
) -> FeedbackResponse:
|
||||||
"""Add community feedback for an agent"""
|
"""Add community feedback for an agent"""
|
||||||
|
|
||||||
@@ -210,7 +210,7 @@ async def add_community_feedback(
|
|||||||
@router.post("/job-completion")
|
@router.post("/job-completion")
|
||||||
async def record_job_completion(
|
async def record_job_completion(
|
||||||
job_request: JobCompletionRequest,
|
job_request: JobCompletionRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Record job completion and update reputation"""
|
"""Record job completion and update reputation"""
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ async def record_job_completion(
|
|||||||
@router.get("/trust-score/{agent_id}", response_model=TrustScoreResponse)
|
@router.get("/trust-score/{agent_id}", response_model=TrustScoreResponse)
|
||||||
async def get_trust_score_breakdown(
|
async def get_trust_score_breakdown(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> TrustScoreResponse:
|
) -> TrustScoreResponse:
|
||||||
"""Get detailed trust score breakdown for an agent"""
|
"""Get detailed trust score breakdown for an agent"""
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ async def get_reputation_leaderboard(
|
|||||||
category: str = Query(default="trust_score", description="Category to rank by"),
|
category: str = Query(default="trust_score", description="Category to rank by"),
|
||||||
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
||||||
region: Optional[str] = Query(default=None, description="Filter by region"),
|
region: Optional[str] = Query(default=None, description="Filter by region"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session),
|
||||||
) -> List[LeaderboardEntry]:
|
) -> List[LeaderboardEntry]:
|
||||||
"""Get reputation leaderboard"""
|
"""Get reputation leaderboard"""
|
||||||
|
|
||||||
@@ -306,7 +306,7 @@ async def get_reputation_leaderboard(
|
|||||||
|
|
||||||
@router.get("/metrics", response_model=ReputationMetricsResponse)
|
@router.get("/metrics", response_model=ReputationMetricsResponse)
|
||||||
async def get_reputation_metrics(
|
async def get_reputation_metrics(
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> ReputationMetricsResponse:
|
) -> ReputationMetricsResponse:
|
||||||
"""Get overall reputation system metrics"""
|
"""Get overall reputation system metrics"""
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ async def get_reputation_metrics(
|
|||||||
async def get_agent_feedback(
|
async def get_agent_feedback(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
limit: int = Query(default=10, ge=1, le=50),
|
limit: int = Query(default=10, ge=1, le=50),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[FeedbackResponse]:
|
) -> List[FeedbackResponse]:
|
||||||
"""Get community feedback for an agent"""
|
"""Get community feedback for an agent"""
|
||||||
|
|
||||||
@@ -423,7 +423,7 @@ async def get_agent_feedback(
|
|||||||
async def get_reputation_events(
|
async def get_reputation_events(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
limit: int = Query(default=20, ge=1, le=100),
|
limit: int = Query(default=20, ge=1, le=100),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""Get reputation change events for an agent"""
|
"""Get reputation change events for an agent"""
|
||||||
|
|
||||||
@@ -460,7 +460,7 @@ async def get_reputation_events(
|
|||||||
async def update_specialization(
|
async def update_specialization(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
specialization_tags: List[str],
|
specialization_tags: List[str],
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Update agent specialization tags"""
|
"""Update agent specialization tags"""
|
||||||
|
|
||||||
@@ -496,7 +496,7 @@ async def update_specialization(
|
|||||||
async def update_region(
|
async def update_region(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
region: str,
|
region: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Update agent geographic region"""
|
"""Update agent geographic region"""
|
||||||
|
|
||||||
@@ -532,7 +532,7 @@ async def update_region(
|
|||||||
@router.get("/{agent_id}/cross-chain")
|
@router.get("/{agent_id}/cross-chain")
|
||||||
async def get_cross_chain_reputation(
|
async def get_cross_chain_reputation(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
reputation_service: ReputationService = Depends()
|
reputation_service: ReputationService = Depends()
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Get cross-chain reputation data for an agent"""
|
"""Get cross-chain reputation data for an agent"""
|
||||||
@@ -581,7 +581,7 @@ async def get_cross_chain_reputation(
|
|||||||
async def sync_cross_chain_reputation(
|
async def sync_cross_chain_reputation(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
background_tasks: Any, # FastAPI BackgroundTasks
|
background_tasks: Any, # FastAPI BackgroundTasks
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
reputation_service: ReputationService = Depends()
|
reputation_service: ReputationService = Depends()
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Synchronize reputation across chains for an agent"""
|
"""Synchronize reputation across chains for an agent"""
|
||||||
@@ -615,7 +615,7 @@ async def sync_cross_chain_reputation(
|
|||||||
async def get_cross_chain_leaderboard(
|
async def get_cross_chain_leaderboard(
|
||||||
limit: int = Query(50, ge=1, le=100),
|
limit: int = Query(50, ge=1, le=100),
|
||||||
min_score: float = Query(0.0, ge=0.0, le=1.0),
|
min_score: float = Query(0.0, ge=0.0, le=1.0),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
reputation_service: ReputationService = Depends()
|
reputation_service: ReputationService = Depends()
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Get cross-chain reputation leaderboard"""
|
"""Get cross-chain reputation leaderboard"""
|
||||||
@@ -662,7 +662,7 @@ async def get_cross_chain_leaderboard(
|
|||||||
async def submit_cross_chain_event(
|
async def submit_cross_chain_event(
|
||||||
event_data: Dict[str, Any],
|
event_data: Dict[str, Any],
|
||||||
background_tasks: Any, # FastAPI BackgroundTasks
|
background_tasks: Any, # FastAPI BackgroundTasks
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
reputation_service: ReputationService = Depends()
|
reputation_service: ReputationService = Depends()
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Submit a cross-chain reputation event"""
|
"""Submit a cross-chain reputation event"""
|
||||||
@@ -726,7 +726,7 @@ async def submit_cross_chain_event(
|
|||||||
@router.get("/cross-chain/analytics")
|
@router.get("/cross-chain/analytics")
|
||||||
async def get_cross_chain_analytics(
|
async def get_cross_chain_analytics(
|
||||||
chain_id: Optional[int] = Query(None),
|
chain_id: Optional[int] = Query(None),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
reputation_service: ReputationService = Depends()
|
reputation_service: ReputationService = Depends()
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Get cross-chain reputation analytics"""
|
"""Get cross-chain reputation analytics"""
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class MilestoneResponse(BaseModel):
|
|||||||
@router.get("/profile/{agent_id}", response_model=RewardProfileResponse)
|
@router.get("/profile/{agent_id}", response_model=RewardProfileResponse)
|
||||||
async def get_reward_profile(
|
async def get_reward_profile(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> RewardProfileResponse:
|
) -> RewardProfileResponse:
|
||||||
"""Get comprehensive reward profile for an agent"""
|
"""Get comprehensive reward profile for an agent"""
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ async def get_reward_profile(
|
|||||||
@router.post("/profile/{agent_id}")
|
@router.post("/profile/{agent_id}")
|
||||||
async def create_reward_profile(
|
async def create_reward_profile(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Create a new reward profile for an agent"""
|
"""Create a new reward profile for an agent"""
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ async def create_reward_profile(
|
|||||||
@router.post("/calculate-and-distribute", response_model=RewardResponse)
|
@router.post("/calculate-and-distribute", response_model=RewardResponse)
|
||||||
async def calculate_and_distribute_reward(
|
async def calculate_and_distribute_reward(
|
||||||
reward_request: RewardRequest,
|
reward_request: RewardRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> RewardResponse:
|
) -> RewardResponse:
|
||||||
"""Calculate and distribute reward for an agent"""
|
"""Calculate and distribute reward for an agent"""
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ async def calculate_and_distribute_reward(
|
|||||||
@router.get("/tier-progress/{agent_id}", response_model=TierProgressResponse)
|
@router.get("/tier-progress/{agent_id}", response_model=TierProgressResponse)
|
||||||
async def get_tier_progress(
|
async def get_tier_progress(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> TierProgressResponse:
|
) -> TierProgressResponse:
|
||||||
"""Get tier progress information for an agent"""
|
"""Get tier progress information for an agent"""
|
||||||
|
|
||||||
@@ -302,7 +302,7 @@ async def get_tier_progress(
|
|||||||
@router.post("/batch-process", response_model=BatchProcessResponse)
|
@router.post("/batch-process", response_model=BatchProcessResponse)
|
||||||
async def batch_process_pending_rewards(
|
async def batch_process_pending_rewards(
|
||||||
limit: int = Query(default=100, ge=1, le=1000, description="Maximum number of rewards to process"),
|
limit: int = Query(default=100, ge=1, le=1000, description="Maximum number of rewards to process"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session),
|
||||||
) -> BatchProcessResponse:
|
) -> BatchProcessResponse:
|
||||||
"""Process pending reward distributions in batch"""
|
"""Process pending reward distributions in batch"""
|
||||||
|
|
||||||
@@ -327,7 +327,7 @@ async def get_reward_analytics(
|
|||||||
period_type: str = Query(default="daily", description="Period type: daily, weekly, monthly"),
|
period_type: str = Query(default="daily", description="Period type: daily, weekly, monthly"),
|
||||||
start_date: Optional[str] = Query(default=None, description="Start date (ISO format)"),
|
start_date: Optional[str] = Query(default=None, description="Start date (ISO format)"),
|
||||||
end_date: Optional[str] = Query(default=None, description="End date (ISO format)"),
|
end_date: Optional[str] = Query(default=None, description="End date (ISO format)"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> RewardAnalyticsResponse:
|
) -> RewardAnalyticsResponse:
|
||||||
"""Get reward system analytics"""
|
"""Get reward system analytics"""
|
||||||
|
|
||||||
@@ -360,7 +360,7 @@ async def get_reward_leaderboard(
|
|||||||
tier: Optional[str] = Query(default=None, description="Filter by tier"),
|
tier: Optional[str] = Query(default=None, description="Filter by tier"),
|
||||||
period: str = Query(default="weekly", description="Period: daily, weekly, monthly"),
|
period: str = Query(default="weekly", description="Period: daily, weekly, monthly"),
|
||||||
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""Get reward leaderboard"""
|
"""Get reward leaderboard"""
|
||||||
|
|
||||||
@@ -409,7 +409,7 @@ async def get_reward_leaderboard(
|
|||||||
|
|
||||||
@router.get("/tiers")
|
@router.get("/tiers")
|
||||||
async def get_reward_tiers(
|
async def get_reward_tiers(
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""Get reward tier configurations"""
|
"""Get reward tier configurations"""
|
||||||
|
|
||||||
@@ -446,7 +446,7 @@ async def get_reward_tiers(
|
|||||||
async def get_agent_milestones(
|
async def get_agent_milestones(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
include_completed: bool = Query(default=True, description="Include completed milestones"),
|
include_completed: bool = Query(default=True, description="Include completed milestones"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[MilestoneResponse]:
|
) -> List[MilestoneResponse]:
|
||||||
"""Get milestones for an agent"""
|
"""Get milestones for an agent"""
|
||||||
|
|
||||||
@@ -490,7 +490,7 @@ async def get_reward_distributions(
|
|||||||
agent_id: str,
|
agent_id: str,
|
||||||
limit: int = Query(default=20, ge=1, le=100),
|
limit: int = Query(default=20, ge=1, le=100),
|
||||||
status: Optional[str] = Query(default=None, description="Filter by status"),
|
status: Optional[str] = Query(default=None, description="Filter by status"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[Dict[str, Any]]:
|
) -> List[Dict[str, Any]]:
|
||||||
"""Get reward distribution history for an agent"""
|
"""Get reward distribution history for an agent"""
|
||||||
|
|
||||||
@@ -530,7 +530,7 @@ async def get_reward_distributions(
|
|||||||
@router.post("/simulate-reward")
|
@router.post("/simulate-reward")
|
||||||
async def simulate_reward_calculation(
|
async def simulate_reward_calculation(
|
||||||
reward_request: RewardRequest,
|
reward_request: RewardRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Simulate reward calculation without distributing"""
|
"""Simulate reward calculation without distributing"""
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class EarningsDistributionRequest(BaseModel):
|
|||||||
distribution_data: Dict[str, Any] = Field(default_factory=dict)
|
distribution_data: Dict[str, Any] = Field(default_factory=dict)
|
||||||
|
|
||||||
# Dependency injection
|
# Dependency injection
|
||||||
def get_staking_service(session: Annotated[Session, Depends(get_session)]) -> StakingService:
|
def get_staking_service(session: Session = Depends(get_session)) -> StakingService:
|
||||||
return StakingService(session)
|
return StakingService(session)
|
||||||
|
|
||||||
def get_blockchain_service() -> BlockchainService:
|
def get_blockchain_service() -> BlockchainService:
|
||||||
@@ -147,7 +147,7 @@ def get_blockchain_service() -> BlockchainService:
|
|||||||
async def create_stake(
|
async def create_stake(
|
||||||
request: StakeCreateRequest,
|
request: StakeCreateRequest,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -188,7 +188,7 @@ async def create_stake(
|
|||||||
@router.get("/stake/{stake_id}", response_model=StakeResponse)
|
@router.get("/stake/{stake_id}", response_model=StakeResponse)
|
||||||
async def get_stake(
|
async def get_stake(
|
||||||
stake_id: str,
|
stake_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
@@ -213,7 +213,7 @@ async def get_stake(
|
|||||||
@router.get("/stakes", response_model=List[StakeResponse])
|
@router.get("/stakes", response_model=List[StakeResponse])
|
||||||
async def get_stakes(
|
async def get_stakes(
|
||||||
filters: StakingFilterRequest = Depends(),
|
filters: StakingFilterRequest = Depends(),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
@@ -242,7 +242,7 @@ async def add_to_stake(
|
|||||||
stake_id: str,
|
stake_id: str,
|
||||||
request: StakeUpdateRequest,
|
request: StakeUpdateRequest,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -285,7 +285,7 @@ async def add_to_stake(
|
|||||||
async def unbond_stake(
|
async def unbond_stake(
|
||||||
stake_id: str,
|
stake_id: str,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -327,7 +327,7 @@ async def unbond_stake(
|
|||||||
async def complete_unbonding(
|
async def complete_unbonding(
|
||||||
stake_id: str,
|
stake_id: str,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -370,7 +370,7 @@ async def complete_unbonding(
|
|||||||
@router.get("/stake/{stake_id}/rewards")
|
@router.get("/stake/{stake_id}/rewards")
|
||||||
async def get_stake_rewards(
|
async def get_stake_rewards(
|
||||||
stake_id: str,
|
stake_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
@@ -405,7 +405,7 @@ async def get_stake_rewards(
|
|||||||
@router.get("/agents/{agent_wallet}/metrics", response_model=AgentMetricsResponse)
|
@router.get("/agents/{agent_wallet}/metrics", response_model=AgentMetricsResponse)
|
||||||
async def get_agent_metrics(
|
async def get_agent_metrics(
|
||||||
agent_wallet: str,
|
agent_wallet: str,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service)
|
staking_service: StakingService = Depends(get_staking_service)
|
||||||
):
|
):
|
||||||
"""Get agent performance metrics"""
|
"""Get agent performance metrics"""
|
||||||
@@ -425,7 +425,7 @@ async def get_agent_metrics(
|
|||||||
@router.get("/agents/{agent_wallet}/staking-pool", response_model=StakingPoolResponse)
|
@router.get("/agents/{agent_wallet}/staking-pool", response_model=StakingPoolResponse)
|
||||||
async def get_staking_pool(
|
async def get_staking_pool(
|
||||||
agent_wallet: str,
|
agent_wallet: str,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service)
|
staking_service: StakingService = Depends(get_staking_service)
|
||||||
):
|
):
|
||||||
"""Get staking pool information for an agent"""
|
"""Get staking pool information for an agent"""
|
||||||
@@ -446,7 +446,7 @@ async def get_staking_pool(
|
|||||||
async def get_agent_apy(
|
async def get_agent_apy(
|
||||||
agent_wallet: str,
|
agent_wallet: str,
|
||||||
lock_period: int = Field(default=30, ge=1, le=365),
|
lock_period: int = Field(default=30, ge=1, le=365),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service)
|
staking_service: StakingService = Depends(get_staking_service)
|
||||||
):
|
):
|
||||||
"""Get current APY for staking on an agent"""
|
"""Get current APY for staking on an agent"""
|
||||||
@@ -470,7 +470,7 @@ async def update_agent_performance(
|
|||||||
agent_wallet: str,
|
agent_wallet: str,
|
||||||
request: AgentPerformanceUpdateRequest,
|
request: AgentPerformanceUpdateRequest,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -508,7 +508,7 @@ async def distribute_agent_earnings(
|
|||||||
agent_wallet: str,
|
agent_wallet: str,
|
||||||
request: EarningsDistributionRequest,
|
request: EarningsDistributionRequest,
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -551,7 +551,7 @@ async def get_supported_agents(
|
|||||||
page: int = Field(default=1, ge=1),
|
page: int = Field(default=1, ge=1),
|
||||||
limit: int = Field(default=50, ge=1, le=100),
|
limit: int = Field(default=50, ge=1, le=100),
|
||||||
tier: Optional[PerformanceTier] = None,
|
tier: Optional[PerformanceTier] = None,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service)
|
staking_service: StakingService = Depends(get_staking_service)
|
||||||
):
|
):
|
||||||
"""Get list of supported agents for staking"""
|
"""Get list of supported agents for staking"""
|
||||||
@@ -576,7 +576,7 @@ async def get_supported_agents(
|
|||||||
@router.get("/staking/stats", response_model=StakingStatsResponse)
|
@router.get("/staking/stats", response_model=StakingStatsResponse)
|
||||||
async def get_staking_stats(
|
async def get_staking_stats(
|
||||||
period: str = Field(default="daily", regex="^(hourly|daily|weekly|monthly)$"),
|
period: str = Field(default="daily", regex="^(hourly|daily|weekly|monthly)$"),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service)
|
staking_service: StakingService = Depends(get_staking_service)
|
||||||
):
|
):
|
||||||
"""Get staking system statistics"""
|
"""Get staking system statistics"""
|
||||||
@@ -594,7 +594,7 @@ async def get_staking_leaderboard(
|
|||||||
period: str = Field(default="weekly", regex="^(daily|weekly|monthly)$"),
|
period: str = Field(default="weekly", regex="^(daily|weekly|monthly)$"),
|
||||||
metric: str = Field(default="total_staked", regex="^(total_staked|total_rewards|apy)$"),
|
metric: str = Field(default="total_staked", regex="^(total_staked|total_rewards|apy)$"),
|
||||||
limit: int = Field(default=50, ge=1, le=100),
|
limit: int = Field(default=50, ge=1, le=100),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service)
|
staking_service: StakingService = Depends(get_staking_service)
|
||||||
):
|
):
|
||||||
"""Get staking leaderboard"""
|
"""Get staking leaderboard"""
|
||||||
@@ -617,7 +617,7 @@ async def get_my_staking_positions(
|
|||||||
agent_wallet: Optional[str] = None,
|
agent_wallet: Optional[str] = None,
|
||||||
page: int = Field(default=1, ge=1),
|
page: int = Field(default=1, ge=1),
|
||||||
limit: int = Field(default=20, ge=1, le=100),
|
limit: int = Field(default=20, ge=1, le=100),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
@@ -640,7 +640,7 @@ async def get_my_staking_positions(
|
|||||||
@router.get("/staking/my-rewards")
|
@router.get("/staking/my-rewards")
|
||||||
async def get_my_staking_rewards(
|
async def get_my_staking_rewards(
|
||||||
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
period: str = Field(default="monthly", regex="^(daily|weekly|monthly)$"),
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
):
|
):
|
||||||
@@ -661,7 +661,7 @@ async def get_my_staking_rewards(
|
|||||||
async def claim_staking_rewards(
|
async def claim_staking_rewards(
|
||||||
stake_ids: List[str],
|
stake_ids: List[str],
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service),
|
staking_service: StakingService = Depends(get_staking_service),
|
||||||
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
blockchain_service: BlockchainService = Depends(get_blockchain_service),
|
||||||
current_user: dict = Depends(get_current_user)
|
current_user: dict = Depends(get_current_user)
|
||||||
@@ -708,7 +708,7 @@ async def claim_staking_rewards(
|
|||||||
@router.get("/staking/risk-assessment/{agent_wallet}")
|
@router.get("/staking/risk-assessment/{agent_wallet}")
|
||||||
async def get_risk_assessment(
|
async def get_risk_assessment(
|
||||||
agent_wallet: str,
|
agent_wallet: str,
|
||||||
session: Annotated[Session, Depends(get_session)],
|
session: Session = Depends(get_session),
|
||||||
staking_service: StakingService = Depends(get_staking_service)
|
staking_service: StakingService = Depends(get_staking_service)
|
||||||
):
|
):
|
||||||
"""Get risk assessment for staking on an agent"""
|
"""Get risk assessment for staking on an agent"""
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class TradingSummaryResponse(BaseModel):
|
|||||||
@router.post("/requests", response_model=TradeRequestResponse)
|
@router.post("/requests", response_model=TradeRequestResponse)
|
||||||
async def create_trade_request(
|
async def create_trade_request(
|
||||||
request_data: TradeRequestRequest,
|
request_data: TradeRequestRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> TradeRequestResponse:
|
) -> TradeRequestResponse:
|
||||||
"""Create a new trade request"""
|
"""Create a new trade request"""
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ async def create_trade_request(
|
|||||||
@router.get("/requests/{request_id}", response_model=TradeRequestResponse)
|
@router.get("/requests/{request_id}", response_model=TradeRequestResponse)
|
||||||
async def get_trade_request(
|
async def get_trade_request(
|
||||||
request_id: str,
|
request_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> TradeRequestResponse:
|
) -> TradeRequestResponse:
|
||||||
"""Get trade request details"""
|
"""Get trade request details"""
|
||||||
|
|
||||||
@@ -266,7 +266,7 @@ async def get_trade_request(
|
|||||||
@router.post("/requests/{request_id}/matches")
|
@router.post("/requests/{request_id}/matches")
|
||||||
async def find_matches(
|
async def find_matches(
|
||||||
request_id: str,
|
request_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[str]:
|
) -> List[str]:
|
||||||
"""Find matching sellers for a trade request"""
|
"""Find matching sellers for a trade request"""
|
||||||
|
|
||||||
@@ -286,7 +286,7 @@ async def find_matches(
|
|||||||
@router.get("/requests/{request_id}/matches")
|
@router.get("/requests/{request_id}/matches")
|
||||||
async def get_trade_matches(
|
async def get_trade_matches(
|
||||||
request_id: str,
|
request_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[TradeMatchResponse]:
|
) -> List[TradeMatchResponse]:
|
||||||
"""Get trade matches for a request"""
|
"""Get trade matches for a request"""
|
||||||
|
|
||||||
@@ -326,7 +326,7 @@ async def get_trade_matches(
|
|||||||
@router.post("/negotiations", response_model=NegotiationResponse)
|
@router.post("/negotiations", response_model=NegotiationResponse)
|
||||||
async def initiate_negotiation(
|
async def initiate_negotiation(
|
||||||
negotiation_data: NegotiationRequest,
|
negotiation_data: NegotiationRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> NegotiationResponse:
|
) -> NegotiationResponse:
|
||||||
"""Initiate negotiation between buyer and seller"""
|
"""Initiate negotiation between buyer and seller"""
|
||||||
|
|
||||||
@@ -364,7 +364,7 @@ async def initiate_negotiation(
|
|||||||
@router.get("/negotiations/{negotiation_id}", response_model=NegotiationResponse)
|
@router.get("/negotiations/{negotiation_id}", response_model=NegotiationResponse)
|
||||||
async def get_negotiation(
|
async def get_negotiation(
|
||||||
negotiation_id: str,
|
negotiation_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> NegotiationResponse:
|
) -> NegotiationResponse:
|
||||||
"""Get negotiation details"""
|
"""Get negotiation details"""
|
||||||
|
|
||||||
@@ -401,7 +401,7 @@ async def get_negotiation(
|
|||||||
@router.get("/matches/{match_id}")
|
@router.get("/matches/{match_id}")
|
||||||
async def get_trade_match(
|
async def get_trade_match(
|
||||||
match_id: str,
|
match_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> TradeMatchResponse:
|
) -> TradeMatchResponse:
|
||||||
"""Get trade match details"""
|
"""Get trade match details"""
|
||||||
|
|
||||||
@@ -442,7 +442,7 @@ async def get_trade_match(
|
|||||||
@router.get("/agents/{agent_id}/summary", response_model=TradingSummaryResponse)
|
@router.get("/agents/{agent_id}/summary", response_model=TradingSummaryResponse)
|
||||||
async def get_trading_summary(
|
async def get_trading_summary(
|
||||||
agent_id: str,
|
agent_id: str,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> TradingSummaryResponse:
|
) -> TradingSummaryResponse:
|
||||||
"""Get comprehensive trading summary for an agent"""
|
"""Get comprehensive trading summary for an agent"""
|
||||||
|
|
||||||
@@ -464,7 +464,7 @@ async def list_trade_requests(
|
|||||||
trade_type: Optional[str] = Query(default=None, description="Filter by trade type"),
|
trade_type: Optional[str] = Query(default=None, description="Filter by trade type"),
|
||||||
status: Optional[str] = Query(default=None, description="Filter by status"),
|
status: Optional[str] = Query(default=None, description="Filter by status"),
|
||||||
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session),
|
||||||
) -> List[TradeRequestResponse]:
|
) -> List[TradeRequestResponse]:
|
||||||
"""List trade requests with filters"""
|
"""List trade requests with filters"""
|
||||||
|
|
||||||
@@ -512,7 +512,7 @@ async def list_trade_matches(
|
|||||||
min_score: Optional[float] = Query(default=None, description="Minimum match score"),
|
min_score: Optional[float] = Query(default=None, description="Minimum match score"),
|
||||||
status: Optional[str] = Query(default=None, description="Filter by status"),
|
status: Optional[str] = Query(default=None, description="Filter by status"),
|
||||||
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[TradeMatchResponse]:
|
) -> List[TradeMatchResponse]:
|
||||||
"""List trade matches with filters"""
|
"""List trade matches with filters"""
|
||||||
|
|
||||||
@@ -568,7 +568,7 @@ async def list_negotiations(
|
|||||||
status: Optional[str] = Query(default=None, description="Filter by status"),
|
status: Optional[str] = Query(default=None, description="Filter by status"),
|
||||||
strategy: Optional[str] = Query(default=None, description="Filter by strategy"),
|
strategy: Optional[str] = Query(default=None, description="Filter by strategy"),
|
||||||
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
limit: int = Query(default=50, ge=1, le=100, description="Number of results"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> List[NegotiationResponse]:
|
) -> List[NegotiationResponse]:
|
||||||
"""List negotiations with filters"""
|
"""List negotiations with filters"""
|
||||||
|
|
||||||
@@ -619,7 +619,7 @@ async def get_trading_analytics(
|
|||||||
period_type: str = Query(default="daily", description="Period type: daily, weekly, monthly"),
|
period_type: str = Query(default="daily", description="Period type: daily, weekly, monthly"),
|
||||||
start_date: Optional[str] = Query(default=None, description="Start date (ISO format)"),
|
start_date: Optional[str] = Query(default=None, description="Start date (ISO format)"),
|
||||||
end_date: Optional[str] = Query(default=None, description="End date (ISO format)"),
|
end_date: Optional[str] = Query(default=None, description="End date (ISO format)"),
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Get P2P trading analytics"""
|
"""Get P2P trading analytics"""
|
||||||
|
|
||||||
@@ -683,7 +683,7 @@ async def get_trading_analytics(
|
|||||||
@router.post("/simulate-match")
|
@router.post("/simulate-match")
|
||||||
async def simulate_trade_matching(
|
async def simulate_trade_matching(
|
||||||
request_data: TradeRequestRequest,
|
request_data: TradeRequestRequest,
|
||||||
session: Annotated[Session, Depends(get_session)]
|
session: Session = Depends(get_session)
|
||||||
) -> Dict[str, Any]:
|
) -> Dict[str, Any]:
|
||||||
"""Simulate trade matching without creating actual request"""
|
"""Simulate trade matching without creating actual request"""
|
||||||
|
|
||||||
|
|||||||
@@ -664,7 +664,7 @@ class EnterpriseIntegrationFramework:
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.integrations = {} # Active integrations
|
self.integrations = {} # Active integrations
|
||||||
self.
|
self.logger = logger
|
||||||
|
|
||||||
async def create_integration(self, config: IntegrationConfig) -> bool:
|
async def create_integration(self, config: IntegrationConfig) -> bool:
|
||||||
"""Create and initialize enterprise integration"""
|
"""Create and initialize enterprise integration"""
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ Bitcoin Wallet Integration for AITBC Trade Exchange
|
|||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import hashlib
|
import hashlib
|
||||||
import hmac
|
import hmac
|
||||||
import time
|
import time
|
||||||
from typing import Dict, Optional, Tuple
|
from typing import Dict, Optional, Tuple
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|||||||
@@ -424,15 +424,14 @@ def main():
|
|||||||
|
|
||||||
# Wait for coordinator
|
# Wait for coordinator
|
||||||
if not wait_for_coordinator():
|
if not wait_for_coordinator():
|
||||||
# Registration bypassed for testing
|
logger.error("Coordinator not available")
|
||||||
session_token = "bypass_token"
|
return
|
||||||
# # sys.exit(1)
|
|
||||||
|
|
||||||
# Register with coordinator
|
# Register with coordinator
|
||||||
session_token = register_miner()
|
session_token = register_miner()
|
||||||
if not session_token:
|
if not session_token:
|
||||||
# logger.error("Failed to register, exiting")
|
logger.error("Failed to register, exiting")
|
||||||
# sys.exit(1)
|
return
|
||||||
|
|
||||||
logger.info("Miner registered successfully, starting main loop...")
|
logger.info("Miner registered successfully, starting main loop...")
|
||||||
|
|
||||||
|
|||||||
@@ -240,6 +240,7 @@ def ollama_task(ctx, gpu_id: str, model: str, prompt: str, temperature: float, m
|
|||||||
else:
|
else:
|
||||||
error(f"Failed to submit Ollama task: {response.status_code} {response.text}")
|
error(f"Failed to submit Ollama task: {response.status_code} {response.text}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
error(f"Failed to submit Ollama task: {e}")
|
||||||
|
|
||||||
|
|
||||||
@gpu.command(name="pay")
|
@gpu.command(name="pay")
|
||||||
|
|||||||
Reference in New Issue
Block a user