feat: add advisory product comparison tool
This commit is contained in:
@@ -24,6 +24,7 @@ def test_advisor_is_registered_through_the_new_base_factory() -> None:
|
||||
"analyze_portfolio",
|
||||
"generate_asset_allocation",
|
||||
"recommend_products",
|
||||
"compare_products",
|
||||
)
|
||||
assert definition.supported_intents == (
|
||||
"fund_quote",
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.core.product_comparison_contracts import ProductComparisonQuery
|
||||
from app.service.agent.implementations.advisor import AdvisorAgent
|
||||
from app.service.product_comparison_service import ProductComparisonService
|
||||
|
||||
|
||||
def test_comparison_query_requires_two_to_four_six_digit_codes() -> None:
|
||||
assert ProductComparisonQuery(product_codes=["159511", "510500"]).product_codes == (
|
||||
"159511", "510500"
|
||||
)
|
||||
with pytest.raises(ValidationError):
|
||||
ProductComparisonQuery(product_codes=["159511"])
|
||||
with pytest.raises(ValidationError):
|
||||
ProductComparisonQuery(product_codes=["15951x", "510500"])
|
||||
|
||||
|
||||
def test_comparison_differences_only_contains_changed_fields() -> None:
|
||||
rows = [
|
||||
{"product_category": "ETF", "suitability_risk_level": "R2", "fund_type": "股票型",
|
||||
"performance_benchmark": "沪深300", "management_fee_rate_pct": "0.50",
|
||||
"custodian_fee_rate_pct": "0.10"},
|
||||
{"product_category": "LOF", "suitability_risk_level": "R2", "fund_type": "股票型",
|
||||
"performance_benchmark": "沪深300", "management_fee_rate_pct": "0.60",
|
||||
"custodian_fee_rate_pct": "0.10"},
|
||||
]
|
||||
|
||||
result = ProductComparisonService._differences(rows)
|
||||
|
||||
assert set(result) == {"product_category", "management_fee_rate_pct"}
|
||||
|
||||
|
||||
def test_advisor_comparison_description_is_analysis_only() -> None:
|
||||
text = AdvisorAgent._describe_comparison({
|
||||
"status": "ready",
|
||||
"products": [{"product_code": "159511", "product_name": "南方测试ETF"}],
|
||||
"common_industries": ["科技"],
|
||||
})
|
||||
|
||||
assert "159511 南方测试ETF" in text
|
||||
assert "科技" in text
|
||||
assert "不构成交易指令" in text
|
||||
Reference in New Issue
Block a user