feat: complete advisor conversation loop
This commit is contained in:
@@ -4,6 +4,7 @@ from typing import Any
|
||||
|
||||
from app.core.contracts import AgentDefinition, AgentRequest, CoreResult, RequestContext
|
||||
from app.service.agent.implementations.fund_query_demo import FundQueryDemoAgent
|
||||
from app.service.goal_conversation_service import GoalConversationService
|
||||
|
||||
|
||||
class AdvisorAgent(FundQueryDemoAgent):
|
||||
@@ -27,6 +28,7 @@ class AdvisorAgent(FundQueryDemoAgent):
|
||||
"portfolio_analysis",
|
||||
"asset_allocation",
|
||||
"product_recommend",
|
||||
"comparison",
|
||||
),
|
||||
)
|
||||
|
||||
@@ -35,6 +37,12 @@ class AdvisorAgent(FundQueryDemoAgent):
|
||||
self._classified_intent is not None
|
||||
and self._classified_intent.intent == "investment_goal"
|
||||
):
|
||||
if GoalConversationService.should_collect(request.message):
|
||||
goal_result = await GoalConversationService().process(
|
||||
session_id=request.session_id, customer_id=int(context.user_id),
|
||||
trace_id=context.trace_id, message=request.message,
|
||||
)
|
||||
return CoreResult(text=GoalConversationService.customer_prompt(goal_result))
|
||||
output = await self.call_tool(
|
||||
"query_investment_goal", {}, intent="investment_goal", context=context
|
||||
)
|
||||
@@ -65,6 +73,11 @@ class AdvisorAgent(FundQueryDemoAgent):
|
||||
"recommend_products", {"limit": 3}, intent="product_recommend", context=context
|
||||
)
|
||||
return CoreResult(text=self._describe_recommendation(output))
|
||||
if (
|
||||
self._classified_intent is not None
|
||||
and self._classified_intent.intent == "comparison"
|
||||
):
|
||||
return CoreResult(text="对比分析需要明确两个或多个场内基金产品,请提供基金代码或名称。")
|
||||
return await super().handle(request, context)
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user