market_assistant/linguistic_checker.py

36 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from AgentProxy import AgentProxy
class LinguisticChecker:
def __init__(self, api_key, api_secret, assistant_id):
self.agent = AgentProxy(assistant_id, api_key, api_secret)
def check_input(self, crm_field_definition, user_input):
prompt = f"""
任务:
检查给定的用户填写的信息是否符合CRM系统中字段名特别重点检查是否通过随意填写信息来绕过CRM系统的检查。
判断无需根据长度判断,但明显过短的填写信息,需要重点检查。
输入:
用户填写的信息:{user_input}
CRM系统中字段名:{crm_field_definition}
输出:
检查结果:是否通过检查,通过检查则输出"通过检查",否则输出"未通过检查"
置信度对检查结果的置信度取值范围0-100
检测结果分析:给出检测结果的判断依据及分析过程
"""
return self.agent.send_message(prompt)
# 使用示例
if __name__ == "__main__":
api_key = '25bda2c39c0f8ca0'
api_secret = 'e0008b9b9727cb8ceea5a132dbe62495'
assistant_id = "66bb09a84673b57506fe7bbd"
checker = LinguisticChecker(api_key, api_secret, assistant_id)
crm_field_definition = "客户业务场景"
user_input = "数据库XC改造"
result = checker.check_input(crm_field_definition, user_input)
print(result)