同步完整源码 - 2026-05-25

This commit is contained in:
xiaoxue
2026-05-25 01:45:00 +08:00
commit 2417bb427c
3151 changed files with 149175 additions and 0 deletions
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/29 10:19
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/29 10:41
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/29 10:42
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/30 19:31
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,96 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/12/16 14:07
# @Author : jijiawei
# @Email : jijiawei.jjw@antgroup.com
# @FileName: choose_product_agent.py
from agentuniverse.agent.input_object import InputObject
from agentuniverse.agent.template.agent_template import AgentTemplate
from agentuniverse.base.config.component_configer.configers.agent_configer import AgentConfiger
from agentuniverse.prompt.chat_prompt import ChatPrompt
from agentuniverse.prompt.prompt import Prompt
from agentuniverse.prompt.prompt_manager import PromptManager
from agentuniverse.prompt.prompt_model import AgentPromptModel
from langchain_core.utils.json import parse_json_markdown
class ChooseProductAgent(AgentTemplate):
def input_keys(self) -> list[str]:
"""Return the input keys of the Agent."""
return ['input']
def output_keys(self) -> list[str]:
"""Return the output keys of the Agent."""
return ['product_list']
def parse_input(self, input_object: InputObject, agent_input: dict) -> dict:
"""Agent parameter parsing.
Args:
input_object (InputObject): input parameters passed by the user.
agent_input (dict): agent input preparsed by the agent.
Returns:
dict: agent input parsed from `input_object` by the user.
"""
i_object = input_object.to_dict()
for key, value in i_object.items():
agent_input[key] = value
return agent_input
def parse_result(self, agent_result: dict) -> dict:
"""Agent result parser.
Args:
agent_result(dict): Agent result
Returns:
dict: Agent result object.
"""
final_result = dict()
output = agent_result.get('output')
output = parse_json_markdown(output)
final_result['product_list'] = output.get('product_list')
final_result['reason'] = output.get('reason')
final_result['company'] = output.get('company')
return final_result
def process_prompt(self, agent_input: dict, **kwargs) -> ChatPrompt:
expert_framework = agent_input.pop('expert_framework', '') or ''
profile: dict = self.agent_model.profile
profile_instruction = profile.get('instruction')
profile_instruction = expert_framework + profile_instruction if profile_instruction else profile_instruction
profile_prompt_model: AgentPromptModel = AgentPromptModel(introduction=profile.get('introduction'),
target=profile.get('target'),
instruction=profile_instruction)
# get the prompt by the prompt version
input = agent_input.get('input')
if "医疗险" in input:
version_prompt: Prompt = PromptManager().get_instance_obj('choose_product_agent_v2.cn')
else:
version_prompt: Prompt = PromptManager().get_instance_obj(self.prompt_version)
if version_prompt is None and not profile_prompt_model:
raise Exception("Either the `prompt_version` or `introduction & target & instruction`"
" in agent profile configuration should be provided.")
if version_prompt:
version_prompt_model: AgentPromptModel = AgentPromptModel(
introduction=getattr(version_prompt, 'introduction', ''),
target=getattr(version_prompt, 'target', ''),
instruction=expert_framework + getattr(version_prompt, 'instruction', ''))
profile_prompt_model = profile_prompt_model + version_prompt_model
chat_prompt = ChatPrompt().build_prompt(profile_prompt_model, ['introduction', 'target', 'instruction'])
image_urls: list = agent_input.pop('image_urls', []) or []
if image_urls:
chat_prompt.generate_image_prompt(image_urls)
return chat_prompt
def initialize_by_component_configer(self, component_configer: AgentConfiger) -> 'ChooseProductAgent':
super().initialize_by_component_configer(component_configer)
self.prompt_version = self.agent_model.profile.get('prompt_version')
return self
@@ -0,0 +1,12 @@
info:
name: 'choose_product_agent'
description: 'choose product agent'
profile:
prompt_version: 'choose_product_agent.cn'
llm_model:
name: 'qwen_llm'
temperature: 0.1
metadata:
type: 'AGENT'
module: 'basic_sop_app.intelligence.agentic.agent.agent_instance.choose_product_agent'
class: 'ChooseProductAgent'
@@ -0,0 +1,51 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/11/12 10:36
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: choose_product_info_agent.py
from agentuniverse.agent.input_object import InputObject
from agentuniverse.agent.template.agent_template import AgentTemplate
from agentuniverse.base.config.component_configer.configers.agent_configer import AgentConfiger
from langchain_core.utils.json import parse_json_markdown
class ChooseProductInfoAgent(AgentTemplate):
def input_keys(self) -> list[str]:
"""Return the input keys of the Agent."""
return ['input']
def output_keys(self) -> list[str]:
"""Return the output keys of the Agent."""
return ['item_list']
def parse_input(self, input_object: InputObject, agent_input: dict) -> dict:
"""Agent parameter parsing.
Args:
input_object (InputObject): input parameters passed by the user.
agent_input (dict): agent input preparsed by the agent.
Returns:
dict: agent input parsed from `input_object` by the user.
"""
i_object = input_object.to_dict()
for key, value in i_object.items():
agent_input[key] = value
return agent_input
def parse_result(self, agent_result: dict) -> dict:
"""Agent result parser.
Args:
agent_result(dict): Agent result
Returns:
dict: Agent result object.
"""
final_result = dict()
output = agent_result.get('output')
output = parse_json_markdown(output)
final_result['item_list'] = output.get('item_list')
return final_result
@@ -0,0 +1,12 @@
info:
name: 'choose_product_info_agent'
description: 'choose product info agent'
profile:
prompt_version: 'product_info_agent.cn'
llm_model:
name: 'qwen_llm'
temperature: 0.1
metadata:
type: 'AGENT'
module: 'basic_sop_app.intelligence.agentic.agent.agent_instance.choose_product_info_agent'
class: 'ChooseProductInfoAgent'
@@ -0,0 +1,116 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/12/16 14:08
# @Author : jijiawei
# @Email : jijiawei.jjw@antgroup.com
# @FileName: recommend_sop_agent.py
from langchain_core.output_parsers import StrOutputParser
from agentuniverse.base.util.prompt_util import process_llm_token
from agentuniverse.agent.action.tool.tool_manager import ToolManager
from agentuniverse.agent.agent import Agent
from agentuniverse.agent.agent_manager import AgentManager
from agentuniverse.agent.input_object import InputObject
from agentuniverse.agent.memory.memory import Memory
from agentuniverse.agent.output_object import OutputObject
from agentuniverse.agent.template.agent_template import AgentTemplate
from agentuniverse.base.util.logging.logging_util import LOGGER
from agentuniverse.llm.llm import LLM
from agentuniverse.prompt.prompt import Prompt
from basic_sop_app.intelligence.utils.constant import product_info
class RecommendSopAgent(AgentTemplate):
def input_keys(self) -> list[str]:
"""Return the input keys of the Agent."""
return ['input']
def output_keys(self) -> list[str]:
"""Return the output keys of the Agent."""
return ['output']
def parse_input(self, input_object: InputObject, agent_input: dict) -> dict:
"""Agent parameter parsing.
Args:
input_object (InputObject): input parameters passed by the user.
agent_input (dict): agent input preparsed by the agent.
Returns:
dict: agent input parsed from `input_object` by the user.
"""
for key, value in input_object.to_dict().items():
agent_input[key] = value
LOGGER.info(f"agent, agent input: {agent_input}, input_object: {input_object.to_dict()}")
return agent_input
def parse_result(self, agent_result: dict) -> dict:
"""Agent result parser.
Args:
agent_result(dict): Agent result
Returns:
dict: Agent result object.
"""
return {**agent_result}
def execute(self, input_object: InputObject, agent_input: dict, **kwargs) -> dict:
memory: Memory = self.process_memory(agent_input, **kwargs)
llm: LLM = self.process_llm(**kwargs)
return self.customized_execute(input_object, agent_input, memory, llm, **kwargs)
def customized_execute(self, input_object: InputObject, agent_input: dict, memory: Memory,
llm: LLM, **kwargs) -> dict:
# invoke choose_product_info_agent to target required items
choose_product_info_agent: Agent = AgentManager().get_instance_obj('choose_product_info_agent')
choose_product_info_agent_res: OutputObject = choose_product_info_agent.run(**input_object.to_dict())
LOGGER.info(f"choose_product_info_agent_res: {choose_product_info_agent_res.to_dict()}")
product_info_item_list = choose_product_info_agent_res.get_data('item_list')
# invoke product_info_tool to get product info under items
product_description_dict: dict = ToolManager().get_instance_obj('product_info_tool').run(
input=product_info_item_list)
input_object.add_data('product_b_description', product_description_dict['B'])
input_object.add_data('product_c_description', product_description_dict['C'])
# invoke choose_product_agent
choose_product_agent: Agent = AgentManager().get_instance_obj('choose_product_agent')
if not choose_product_agent:
raise ValueError('No choose_product_agent found')
choose_product_agent_res: OutputObject = choose_product_agent.run(**input_object.to_dict())
LOGGER.info(f"choose_product_agent_res: {choose_product_agent_res.to_dict()}")
product_list = choose_product_agent_res.get_data('product_list')
choose_product_reason = choose_product_agent_res.get_data('reason')
# bottom line logic for product choice
if not product_list:
product_list = ["B"]
choose_product_reason += "\n根据您的要求未能找到合适的产品,建议看看下面的产品"
# construct inputs for llm
agent_input['reason'] = choose_product_reason
product_names = ""
product_description_list = ""
product_recommendation = ""
for product in product_list:
product_names += product_info.PRODUCT_NAME_MAP.get(product) + "\n"
product_description_list += product_info.PRODUCT_NAME_MAP.get(product) + "\n"
product_description_list += product_description_dict.get(product) + "\n"
product_recommendation += product_info.PRODUCT_RECOMMENDATION_MAP.get(product) + "\n"
agent_input['product_description_list'] = product_description_list
agent_input['product_names'] = product_names
agent_input['product_recommendation'] = product_recommendation
# process prompt and token
prompt: Prompt = self.process_prompt(agent_input, **kwargs)
process_llm_token(llm, prompt.as_langchain(), self.agent_model.profile, agent_input)
# invoke llm
chain = prompt.as_langchain() | llm.as_langchain_runnable(
self.agent_model.llm_params()) | StrOutputParser()
res = self.invoke_chain(chain, agent_input, input_object, **kwargs)
LOGGER.info(f"product recommend sop agent res: {res}")
return {'output': res}
@@ -0,0 +1,12 @@
info:
name: 'recommend_sop_agent'
description: 'Standard sop for product recommend agent.'
profile:
prompt_version: 'recommend_sop_agent.cn'
llm_model:
name: 'qwen_llm'
temperature: 0.1
metadata:
type: 'AGENT'
module: 'basic_sop_app.intelligence.agentic.agent.agent_instance.recommend_sop_agent'
class: 'RecommendSopAgent'
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/29 10:43
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/8/14 15:58
# @Author : fanen.lhy
# @Email : fanen.lhy@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
name: 'query_keyword_extractor'
description: 'extract keywords from query'
top_k: 6
metadata:
type: 'DOC_PROCESSOR'
module: 'agentuniverse.agent.action.knowledge.doc_processor.jieba_keyword_extractor'
class: 'JiebaKeywordExtractor'
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/8/14 15:59
# @Author : fanen.lhy
# @Email : fanen.lhy@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
name: 'custom_query_keyword_extractor'
description: 'extract keywords from query origin str'
keyword_extractor: 'query_keyword_extractor'
metadata:
type: 'QUERY_PARAPHRASER'
module: 'agentuniverse.agent.action.knowledge.query_paraphraser.query_keyword_extractor'
class: 'QueryKeywordExtractor'
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/8/13 17:07
# @Author : fanen.lhy
# @Email : fanen.lhy@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,10 @@
name: 'nlu_rag_router'
description: 'base rag router map query to all store'
store_amount: 2
llm:
name: qwen_llm
model_name: qwen-max
metadata:
type: 'RAG_ROUTER'
module: 'agentuniverse.agent.action.knowledge.rag_router.nlu_rag_router'
class: 'NluRagRouter'
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/8/6 14:55
# @Author : fanen.lhy
# @Email : fanen.lhy@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/4/2 17:35
# @Author : jerry.zzw
# @Email : jerry.zzw@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,9 @@
name: 'qwen_llm'
description: 'demo qwen llm with spi'
model_name: 'qwen2-72b-instruct'
max_tokens: 2500
api_key: '${DASHSCOPE_API_KEY}'
metadata:
type: 'LLM'
module: 'agentuniverse.llm.default.qwen_openai_style_llm'
class: 'QWenOpenAIStyleLLM'
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/29 10:43
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/29 10:55
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/11 16:49
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/5/7 20:04
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,61 @@
introduction: |
# 身份设定
从现在开始,你的角色是一名选品专家,你精通各产品的合同条款和产品特点。
target: |
# 目标
根据用户提出的问题,从售卖的产品中选出一款或多款符合用户条件的产品。
instruction: |
# few shot
产品信息如下:
产品B:
产品名称:责任险B
对应险种:简称责任险
产品C:
产品名称:大病医疗C
对应险种:简称医疗险
示例1:
用户问题:你好,我之前买过一个保险,现在想换一个?
选品思路:由于用户没有提及具体的险种或产品名称,每个险种各选一款产品,选择B、C,覆盖大病医疗、责任险两款险种。
# 产品条款类目
目前主要售卖2款保险产品,产品信息如下:
产品B:
产品名称:责任险B
对应险种:责任险
责任险产品信息:
{product_b_description}
产品C:
产品名称:大病医疗C
对应险种:医疗险
大病医疗产品信息:
{product_c_description}
# 回答问题的要求和限制:
1. 根据用户问题匹配各产品条款信息,选出的产品必须满足用户对于条款的所有要求。
2. 如果用户问题中明确提及某一险种,如提及责任险选择产品责任险B;提及医疗险选择产品大病医疗C。
# 输出格式
输出必须是按照以下格式化的Json代码片段,product_list字段代表你挑选出来的产品名称列表,例如["C", "B"] 或 ["C"] 或 [];
reason字段代表根据用户提出的问题,选出一款或多款符合用户条件的产品的理由;
如果用户的问题中提及了保险公司的全称或简称,则company字段设置为true。
```json
{{
"product_list": list[string],
"reason": string,
"company": bool
}}
```
开始!
用户的问题是: {input}
你需要回答的答案是:
metadata:
type: 'PROMPT'
version: 'choose_product_agent.cn'
@@ -0,0 +1,61 @@
introduction: |
# 身份设定
从现在开始,你的角色是一名选品专家,你精通各产品的合同条款和产品特点。
target: |
# 目标
根据用户提出的问题,从售卖的产品中选出一款或多款符合用户条件的产品。
instruction: |
# few shot
产品信息如下:
产品B:
产品名称:责任险B
对应险种:责任险
产品C:
产品名称:大病医疗C
对应险种:医疗险
示例1:
用户问题:医疗险是哪个
选品思路:如果用户想要医疗险,则选择产品C(大病医疗C); 并向用户说明: "现在可以优先选择该产品,大病医疗C相比于其他品类在多个方面进行了升级,可以给您提供更全面的保障和服务。"。
回答:你好,现在可以优先选择大病医疗C,大病医疗C相比于其他品类在多个方面进行了升级,可以给您提供更全面的保障和服务。
# 产品条款类目
目前主要售卖2款保险产品,产品信息如下:
产品B:
产品名称:责任险B
对应险种:责任险
责任险产品信息:
{product_b_description}
产品C:
产品名称:大病医疗C
对应险种:医疗险
大病医疗产品信息:
{product_c_description}
# 回答问题的要求和限制:
1. 根据用户问题匹配各产品条款信息,选出的产品必须满足用户对于条款的所有要求。
2. 如果用户未指定具体需求,每个险种各选一款产品,选择产品C(大病医疗C)、产品B(责任险B),覆盖医疗险、责任险两款险种。
# 输出格式
输出必须是按照以下格式化的Json代码片段,product_list字段代表你挑选出来的产品名称列表,例如["C", "B"] 或 ["C"] 或 [];
reason字段代表根据用户提出的问题,选出一款或多款符合用户条件的产品的理由;
如果用户的问题中非常明确提及了保险公司,则company字段设置为true。
```json
{{
"product_list": list[string],
"reason": string,
"company": bool
}}
```
开始!
用户的问题是: {query}
你需要回答的答案是:
metadata:
type: 'PROMPT'
version: 'choose_product_agent_v2.cn'
@@ -0,0 +1,40 @@
introduction: |
# 身份设定
从现在开始,你的角色是一名选品专家,你精通各产品的合同条款和产品特点。
target: |
# 目标
根据用户提出的问题,决定在给定的合同条款项目中,选择哪几项作为参考内容,用来帮助获取到用户想要的答案。
instruction: |
# 产品条款类目
几款保险产品,条款包含以下类目:
A. 投/被保险人:涉及合同的主体,即谁在合同中承担义务和享有权利,这里包含投保和被保险人所需满足的条件和限制等信息。
B. 投保份数:指投保人购买保险的份数,被投保保险份数限制等信息。
C. 保险期限:指保险合同的有效时间期限,保险生效时间等相关信息。
D. 保障责任:指被保险宠物发生事故、疾病等各种情况下,产品保障的范围、保障额度、免赔额、等待期规则、报销比例、赔付比例、保障详情等信息。
E. 缴费方式及金额:指投保人支付保险费的方式(如年缴、月缴等)和具体金额等信息。
F. 产品犹豫期:指投保人在购买保险后,有一段时间可以无理由解除保险合同并全额退还已支付的保险费的期限。
# 回答问题的要求和限制:
1. 如果用户问题意图比较清晰时,选出一个或多个可以帮助回答用户问题的产品条款类目。
2. 如果用户问题意图比较模糊时,多角度猜测用户真正意图,选择多个可以帮助回答用户问题的产品条款类目,例如用户问题:一年200那种险是哪种,不清楚200是指什么,选择C、E,对应保险期限和缴费方式及金额。
# 输出格式
输出必须是按照以下格式化的Json代码片段,item_list字段代表你挑选出来的合同条款类目序列号
例如: 选出几个合同条款类目序列号的情况 {{"item_list": ["A", "C", "E", "G"]}};选不出任何合同条款类目序列号的情况 {{"item_list": []}}
```json
{{
"item_list": list[string]
}}
```
开始!
用户的问题是: {input}
你需要回答的答案是:
metadata:
type: 'PROMPT'
version: 'product_info_agent.cn'
@@ -0,0 +1,43 @@
introduction: |
# 身份设定
从现在开始,你的角色是一名保险产品顾问,你熟悉各产品的合同条款和产品特点,精通向用户推荐产品。
target: |
# 目标
根据用户提出的问题,结合保险选品专家给出的保险产品和选品理由,向用户推荐一款或多款保险产品,并给出推荐理由。
instruction: |
目前主要售卖2款保险产品
分别是:
产品名称:责任险B
对应险种:责任险
产品名称:大病医疗C
对应险种:医疗险
# 结合用户问题,选品专家选出的产品是:
{product_names}
# 选出的这几款产品的具体信息是:
{product_description_list}
# 专家的选品理由是:
{reason}
# 这几款产品的具体推荐理由是:
{product_recommendation}
# 回答问题的要求和限制:
1. 选品专家选出的产品,不做二次选品筛选。
2. 不向用户透露产品编号,如产品B、产品C
3. 回答内容精炼,不要有重复信息,也不要重复回答!
4. 你给出的答案是直接展示给用户的,回答用户问题时不要出现如【用户的问题与保险无关】等无法给用户展示的思考语句
5. 回答保险产品中金额内容要严格按照条款中的描述,尤其注意对不同版本的保费金额、累计限额、单次赔付限额的列举要清晰且保证准确性。
开始!
回答问题简要精炼,突出重点,不要有重复信息,也不要重复回答!
用户的问题是: {input}
metadata:
type: 'PROMPT'
version: 'recommend_sop_agent.cn'
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/4/2 17:36
# @Author : jerry.zzw
# @Email : jerry.zzw@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,29 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/11/12 11:59
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: product_info_tool.py
from agentuniverse.agent.action.tool.tool import Tool, ToolInput
from basic_sop_app.intelligence.utils.constant import product_b_info, product_c_info
class SearchProductInfoTool(Tool):
def execute(self, input: list):
product_info_item_list = input
product_b_description = product_b_info.BASE_PRODUCT_DESCRIPTION
product_c_description = product_c_info.BASE_PRODUCT_DESCRIPTION
for item in product_info_item_list:
if item == 'G':
continue
if item == 'K':
product_b_description += product_b_info.PRODUCT_DESCRIPTION_MAP.get('L')
product_c_description += product_c_info.PRODUCT_DESCRIPTION_MAP.get('L')
else:
product_b_description += product_b_info.PRODUCT_DESCRIPTION_MAP.get(item)
product_c_description += product_c_info.PRODUCT_DESCRIPTION_MAP.get(item)
return {'B': product_b_description, 'C': product_c_description}
@@ -0,0 +1,23 @@
name: 'product_info_tool'
description: |
根据保险产品条款类目获取产品具体信息
工具输入:条款类目列表item_list
工具输出:产品编号和该产品详情的键值对,产品只有两种,分别是 B-责任险,C-大病医疗,格式如下
{"B": "B产品详情条目", "C": "C产品详情条目"}
工具输入输出示例:
#工具输入:
["B", "E"]
#工具输出:
{"B": "【责任险】保险产品名称:责任险 产品分为三个版本:基础版、升级版、尊享版"
"C": "【大病医疗】保险产品名称:大病医疗产品分为两个版本:升级版、尊享版"}
tool_type: 'api'
input_keys: [ 'input' ]
metadata:
type: 'TOOL'
module: 'basic_sop_app.intelligence.agentic.tool.product_info_tool'
class: 'SearchProductInfoTool'
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/29 10:44
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/29 10:29
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/4/2 18:52
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,5 @@
name: 'recommend_sop_service'
description: 'demo service of consult agent'
agent: 'recommend_sop_agent'
metadata:
type: 'SERVICE'
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/29 10:30
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/4/2 17:32
# @Author : jerry.zzw
# @Email : jerry.zzw@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,20 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/11/28 17:17
# @Author : jijiawei
# @Email : jijiawei.jjw@antgroup.com
# @FileName: recommend_sop_agent_test.py
from agentuniverse.base.agentuniverse import AgentUniverse
from agentuniverse.agent.agent import Agent
from agentuniverse.agent.agent_manager import AgentManager
AgentUniverse().start(config_path='../../config/config.toml', core_mode=True)
def chat(question: str):
instance: Agent = AgentManager().get_instance_obj('recommend_sop_agent')
return instance.run(input=question)
if __name__ == '__main__':
print(chat("为我想要买医疗类保险").get_data('output'))
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/29 10:36
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,6 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/11/28 17:20
# @Author : jijiawei
# @Email : jijiawei.jjw@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,102 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/11/22 15:13
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: product_b_info.py
BASE_PRODUCT_DESCRIPTION = """
【责任险】
1、保险产品名称:
责任险
产品分为三个版本:基础版、升级版、尊享版
2、保险险种名称:
一级分类名称:保险
二级分类名称:责任险
"""
A = """
3、投/被保险人:
在中华人民共和国境内(不包括港、澳、台地区),且具有完全民事行为能力的自然人,可作为本保险合同的投保人和被保险人。
"""
B = """
略
"""
C = """
5、投保份数:
本产品同一时间段多投无效。同一投保人累计限购3份。
"""
D = """
6、保险期限:
本产品保险期限为一年,保单生效时间为投保并成功缴纳保费的第三日零时。
"""
E = """
7、保障责任:
a.保险期限:本产品保险期限为一年,保单生效时间为投保并成功缴纳保费的第三日零时。
b.保障详情:
【基础版方案】
1. 三者责任
保障详情:
略
【升级版方案】
1. 三者责任,保障详情同基础版
略
【尊享版方案】
1. 三者责任,保障详情同基础版。
略
"""
F = """
8、缴费方式及金额:
本产品可支持趸交一次性付清和月缴分为12期交付两种方式:保费分期缴付周期为每月,未缴付首期保费,保险合同不成立。
"""
G = """
9、产品犹豫期:
本产品无犹豫期。
"""
H = """
10、产品合同解除(退保)规则:
(1)保单未生效:
保单未生效申请退保并递交齐全退保资料的,将全额退还已缴纳的保险费;
(2)保单已生效:
A、年缴保单:
在保单生效后申请退保的,将退还未满期净保险费,计算公式为:未满期净保险费=保险费x(1-保险单已经过天数/保险期间天数)。
B、月缴保单:
在保单生效后申请退保的,将退还未满期净保险费,计算公式为:退还未满期净保险费=本合同当期月度保险费*(1-当月实际经过天数/当月实际天数)。
对于月缴保单用户,缴费宽限期为15天,若超过缴费宽限期仍未能完成保费缴纳,保单及增值服务均自动失效,保单终止日期为上一缴费期最后一天。
"""
I = """
11、续保规则:
保险续保服务由用户选择投保的保险公司提供。续保功能目前仅支持部分险种,用户可以在明确标识可续保的保险产品页面或保单详情页面开通续保功能。
"""
J = """
12、增值服务:
无
"""
K = """
略
"""
L = """
略
"""
M = """
7、保障责任:
等待期:本产品保单生效后无等待期。
【略
"""
PRODUCT_DESCRIPTION_MAP = {"A": A, "B": B, "C": C, "D": D, "E": E, "F": F, "G": G, "H": H, "I": I, "J": J, "K": K,
"L": L, "M": M}
@@ -0,0 +1,98 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/11/22 16:30
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: product_c_info.py
BASE_PRODUCT_DESCRIPTION = """
【大病医疗】
1、保险产品名称:
大病医疗C
产品分为两个版本:升级版、尊享版
2、保险险种名称:
一级分类名称:保险
二级分类名称:医疗险
"""
A = """
3、投/被保险人:
(1)投保人:需为16周岁及以上且具有完全民事行为能力的自然人
(2)被保险人:与投保人为同一人
"""
B = """
略
"""
C = """
5、投保份数:
本产品仅限本人购买,多投无效。
"""
D = """
6、保险期限:
保险期限为1年,自核保通过后次日零时起保,具体以保单载明时间为准
"""
E = """
7、保障责任:
升级版总保额50500元(医疗保险金50000元,死亡保险金500元); 尊享版总保额100800元(医疗保险金100000元,死亡保险金800元)。
略
"""
F = """
8、缴费方式及金额:
保险方案分为年缴及月缴两种缴费方式,您可以根据需求自行选择。
"""
G = """
9、产品犹豫期:
本产品无犹豫期。
"""
H = """
10、产品合同解除(退保)规则:
本产品可在线申请退保,投保人要求解除合同,自保险人接到保险合同解除申请书之日次日零时起,本合同效力终止。保单未生效,申请退保并递交齐全退保资料的,将全额退还保险费。若投保人在保单生效后申请退保的,将退还未满期净保险费。
对于年缴保单用户:
保单未生效,申请退保并递交齐全退保资料的,将全额退还已缴纳的保险费。
在保单生效后申请退保的,将退还未满期净保险费,计算公式为:未满期净保险费=保险费×[1-(保险单已经过天数/保险期间天数)]。对于已使用服务的,需在保4个月以上方可申请退保。
对于月缴保单用户:
保单未生效,申请退保并递交齐全退保资料的,将全额退还已缴纳的保险费。
在保单生效后申请退保的,根据以下约定进行处理:
(1)若未使用服务,退还当月保费的未满期净保险费,计算公式为:退还未满期净保险费=本合同当期月度保险费*[1-(当月实际经过天数/当月实际天数)]。
(2)若已使用服务,对于缴费完成期数不少于4期的,退还当月保费的未满期净保险费,计算公式为:退还未满期净保险费=本合同当期月度保险费*[1-(当月实际经过天数/当月实际天数)];对于缴费完成期数少于4期的,无法退保。
对于月缴保单用户,缴费宽限期为15天,若超过缴费宽限期仍未能完成保费缴纳,保单及赠送的增值服务均自动失效,保单中止日期为上一缴费期最后一天。
"""
I = """
11、续保规则:
本产品为不保证续保保险产品。
您在本年度投保时选择了开通下一年延续保障(以下简称“续保”)服务并同意相关服务协议,或在该保单到期前30天或到期后15天内为同一被保险人及其宠物重新申请投保的,经保险人审核同意后缴纳保费,重新获得新的保险合同。
"""
J = """
1略
"""
K = """
略
"""
L = """
略
"""
M = """
7、保障责任:
升级版总保额50500元(医疗保险金50000元,死亡保险金500元); 尊享版总保额100800元(医疗保险金100000元,死亡保险金800元)。
略
等待期:普通疾病为20天,指定重大疾病为60天,如为意外事故导致的,等待期均为20天;
连续投保不重复计算等待期,非连续投保重新计算等待期;
"""
PRODUCT_DESCRIPTION_MAP = {"A": A, "B": B, "C": C, "D": D, "E": E, "F": F, "G": G, "H": H, "I": I, "J": J, "K": K, "L": L, "M": M}
@@ -0,0 +1,40 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/11/23 13:43
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: product_info.py
PRODUCT_ITEM_MAP = {"A": "投/被保险人", "B": "略", "C": "投保份数", "D": "保险期限", "E": "保障责任",
"F": "缴费方式及金额", "G": "产品犹豫期",
"H": "产品合同解除(退保)规则", "I": "续保规则", "J": "增值服务", "K": "责任免除"}
PRODUCT_B = """
产品名称:责任险B
对应险种:责任险
"""
PRODUCT_B_RECOMMENDATION = """
责任险
- 总评:该产品不仅保障自己及家人,并且包含xx责任条款
- 优势点:性价比高,同等保障价格更低;保障对象更广,投保者、家人均可赔。
"""
PRODUCT_C = """
产品名称:大病医疗C
对应险种:医疗险
"""
PRODUCT_C_RECOMMENDATION = """
大病医疗C
- 总评:本产品可报销XX疾病(包括小病门诊及大病手术)与意外(骨折、烧伤烫伤等)医疗费用,重疾单次最多可赔2万,性价比高。
- 优势点:性价比高,保额高,定点医院覆盖广;科技赋能,投保理赔更便捷;理赔时仅需在线提交资料,支持3日快赔;健康要求宽松。
"""
PRODUCT_NAME_MAP = {"B": PRODUCT_B, "C": PRODUCT_C}
PRODUCT_RECOMMENDATION_MAP = {"B": PRODUCT_B_RECOMMENDATION,
"C": PRODUCT_C_RECOMMENDATION}
@@ -0,0 +1,7 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/10/29 10:39
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: __init__.py
@@ -0,0 +1,32 @@
# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# @Time : 2024/11/15 11:42
# @Author : wangchongshi
# @Email : wangchongshi.wcs@antgroup.com
# @FileName: prompt_util.py
from agentuniverse.prompt.chat_prompt import ChatPrompt
def convert_prompt_to_message(agent_input: dict, prompt: ChatPrompt) -> list:
messages = prompt.messages
prompt_list = []
for message in messages:
if message.type == 'system':
prompt_list.append({'role': 'system', 'content': message.content})
if message.type == 'human' or message.type == 'user':
formatted_content = message.content.format(**agent_input)
prompt_list.append({'role': 'user', 'content': formatted_content})
return prompt_list
def get_prompt_str(agent_input: dict, prompt: ChatPrompt) -> str:
messages = prompt.messages
prompt_str = ''
for message in messages:
if message.type == 'system':
prompt_str += f"System prompt: {message.content}\n\n"
if message.type == 'human' or message.type == 'user':
formatted_content = message.content.format(**agent_input)
prompt_str += f"User prompt: {formatted_content}\n\n"
return prompt_str