袁聪的第一次提交,包含nl2sql,行情数据,场外申购
This commit is contained in:
@@ -2,7 +2,10 @@ from functools import lru_cache
|
||||
from typing import Any, cast
|
||||
|
||||
from app.core.fund_contracts import FundQuoteQuery
|
||||
from app.core.nl2sql_contracts import FinancialNL2SQLInput
|
||||
from app.service.agent.factory import AgentFactory
|
||||
from app.service.agent.offsite_fund_agent import OffsiteFundAgent
|
||||
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.model_gateway import (
|
||||
@@ -34,11 +37,24 @@ def get_agent_factory() -> AgentFactory:
|
||||
allowed_roles=("customer", "advisor", "operator", "risk_operator", "admin"),
|
||||
timeout_seconds=5,
|
||||
))
|
||||
registry.register(ToolDefinition(
|
||||
name="query_financial_data",
|
||||
input_model=FinancialNL2SQLInput,
|
||||
handler=cast(Any, query_financial_data_tool),
|
||||
required_permission="financial:nl2sql:read",
|
||||
allowed_roles=("advisor", "operator", "admin", "super_admin"),
|
||||
timeout_seconds=10,
|
||||
))
|
||||
model_service = ModelGenerationService(ModelDispatchService(DatabaseModelGateway()))
|
||||
endpoint_resolver = DatabaseModelEndpointResolver()
|
||||
return AgentFactory(
|
||||
factory = AgentFactory(
|
||||
model_service=model_service,
|
||||
tool_executor=ToolExecutor(registry),
|
||||
intent_classifier=IntentClassifier(model_service),
|
||||
intent_endpoint_resolver=endpoint_resolver,
|
||||
)
|
||||
factory.register(
|
||||
OffsiteFundAgent.definition,
|
||||
lambda _context: OffsiteFundAgent(OffsiteFundAgent.definition),
|
||||
)
|
||||
return factory
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
"""场外基金运营 Agent。"""
|
||||
|
||||
from app.core.contracts import AgentDefinition, AgentRequest, CoreResult, RequestContext
|
||||
from app.service.agent.base import BaseAgent
|
||||
|
||||
|
||||
class OffsiteFundAgent(BaseAgent):
|
||||
definition = AgentDefinition(
|
||||
agent_type="offsite_fund",
|
||||
version="1.0.0",
|
||||
allowed_roles=("operator", "risk_operator", "admin"),
|
||||
allowed_portals=("api",),
|
||||
supported_intents=("offsite_status", "offsite_reconcile", "general"),
|
||||
)
|
||||
|
||||
async def handle(self, request: AgentRequest, context: RequestContext) -> CoreResult:
|
||||
del context
|
||||
text = (
|
||||
"场外申购赎回后端流程已接入。请通过场外业务接口写入已识别邮件和附件,"
|
||||
"系统会生成邮件编号、附件编号、执行计划、确定性规则结果和待人工确认状态。"
|
||||
f"本次请求摘要:{request.message[:120]}"
|
||||
)
|
||||
return CoreResult(text=text)
|
||||
|
||||
Reference in New Issue
Block a user