feat: add Nailong Fund advisor capabilities

This commit is contained in:
Windows
2026-09-11 09:47:40 +08:00
parent 5907fcd6d2
commit a4499defee
143 changed files with 12255 additions and 89 deletions
+61
View File
@@ -1,19 +1,31 @@
from functools import lru_cache
from typing import Any, cast
from app.core.advisor_allocation_contracts import AssetAllocationQuery, CustomerProfileQuery
from app.core.fund_contracts import FundQuoteQuery
from app.core.investment_goal_contracts import InvestmentGoalQuery
from app.core.nl2sql_contracts import FinancialNL2SQLInput
from app.core.portfolio_analysis_contracts import PortfolioAnalysisQuery
from app.core.portfolio_rebalance_contracts import PortfolioRebalanceQuery
from app.core.product_recommendation_contracts import ProductRecommendationQuery
from app.service.agent.advisor_agent import AdvisorAgent
from app.service.agent.factory import AgentFactory
from app.service.agent.offsite_fund_agent import OffsiteFundAgent
from app.service.asset_allocation_service import asset_allocation_tool
from app.service.customer_profile_service import customer_profile_query_tool
from app.service.financial_nl2sql_service import query_financial_data_tool
from app.service.fund_quote_service import query_fund_quote_tool
from app.service.intent_classifier import IntentClassifier
from app.service.investment_goal_service import investment_goal_query_tool
from app.service.model_gateway import (
DatabaseModelEndpointResolver,
DatabaseModelGateway,
ModelDispatchService,
ModelGenerationService,
)
from app.service.portfolio_analysis_service import portfolio_analysis_tool
from app.service.portfolio_rebalance_service import portfolio_rebalance_tool
from app.service.product_recommendation_service import product_recommendation_tool
from app.service.suitability_service import SuitabilityToolInput, suitability_tool_handler
from app.service.tool_executor import ToolDefinition, ToolExecutor, ToolRegistry
@@ -45,6 +57,51 @@ def get_agent_factory() -> AgentFactory:
allowed_roles=("advisor", "operator", "admin", "super_admin"),
timeout_seconds=10,
))
registry.register(ToolDefinition(
name="query_investment_goal",
input_model=InvestmentGoalQuery,
handler=cast(Any, investment_goal_query_tool),
required_permission="investment-goal:read:self",
allowed_roles=("customer", "advisor", "operator", "admin"),
))
registry.register(ToolDefinition(
name="query_customer_profile",
input_model=CustomerProfileQuery,
handler=cast(Any, customer_profile_query_tool),
required_permission="customer-profile:read:self",
allowed_roles=("customer",),
))
registry.register(ToolDefinition(
name="generate_asset_allocation",
input_model=AssetAllocationQuery,
handler=cast(Any, asset_allocation_tool),
required_permission="asset-allocation:generate:self",
allowed_roles=("customer",),
))
registry.register(ToolDefinition(
name="recommend_products",
input_model=ProductRecommendationQuery,
handler=cast(Any, product_recommendation_tool),
required_permission="product-recommendation:read:self",
allowed_roles=("customer",),
timeout_seconds=10,
))
registry.register(ToolDefinition(
name="analyze_portfolio",
input_model=PortfolioAnalysisQuery,
handler=cast(Any, portfolio_analysis_tool),
required_permission="portfolio-analysis:read:self",
allowed_roles=("customer",),
timeout_seconds=10,
))
registry.register(ToolDefinition(
name="simulate_portfolio_rebalance",
input_model=PortfolioRebalanceQuery,
handler=cast(Any, portfolio_rebalance_tool),
required_permission="portfolio-analysis:read:self",
allowed_roles=("customer",),
timeout_seconds=10,
))
model_service = ModelGenerationService(ModelDispatchService(DatabaseModelGateway()))
endpoint_resolver = DatabaseModelEndpointResolver()
factory = AgentFactory(
@@ -57,4 +114,8 @@ def get_agent_factory() -> AgentFactory:
OffsiteFundAgent.definition,
lambda _context: OffsiteFundAgent(OffsiteFundAgent.definition),
)
factory.register(
AdvisorAgent.definition,
lambda _context: AdvisorAgent(AdvisorAgent.definition),
)
return factory