market_assistant/analysis_pipeline.py

84 lines
5.6 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.

import pandas as pd
from AgentProxy import AgentProxy
from datetime import datetime # Add this import
# Here you need to replace the API Key and API Secret with yourI provide a test key and secret here
api_key = '25bda2c39c0f8ca0'
api_secret = 'e0008b9b9727cb8ceea5a132dbe62495'
assistant_id = "66bb09a84673b57506fe7bbd"
agent = AgentProxy(assistant_id, api_key, api_secret)
# Prospecting
# Evaluation
# Qualification
# Bidding / Negotiating
# Contract Review
# Closed Won
# Cancel
# Closed Lost
sales_stages = ["Prospecting", "Evaluation", "Qualification", "Bidding / Negotiating", "Contract Review", "Closed Won", "Cancel", "Closed Lost"]
prompt = "某公司销售阶段分为如下几个定义,你能告诉我什么信息 "+ str(sales_stages)
print(prompt)
# print(agent.send_message(prompt))
sales_stage_definition = '''
1. **Prospecting潜在客户开发**:这一阶段涉及识别和开发潜在客户。销售人员通过各种渠道(如电话、电子邮件、社交媒体等)寻找潜在买家。-阶段转化标准:①客户有需求 ②有明确的项目联系人;
2. **Evaluation评估**:在评估阶段,销售团队会评估潜在客户的需求,确定他们是否与公司的产品或服务相匹配。同时,潜在客户也在评估不同的供应商。-阶段转化标准:①客户有预算 ②有明确的项目时间 ③有预期的产品和数量
3. **Qualification资格认定**:这一阶段的目标是确定潜在客户是否具有成为合格销售机会的潜力。这通常涉及对客户的预算、需求、决策过程和时间线等进行评估。-阶段转化标准:①项目预算批准、项目已立项 ②有确定产品和数量;或③完成场景应用/技术适用性验证客户确定平凯入围完成poc
4. **Bidding / Negotiating投标/谈判)**:在这个阶段,销售人员会向客户提交正式的报价或提案,并进行必要的谈判,以达成最终的销售协议。-阶段转化标准①完成可交付评审②报价单通过审批③投标结果确认赢标或完成商务谈判确定价格和SOW客户启动合同流程
5. **Contract Review合同审查**:一旦谈判完成,双方将审查合同条款,确保所有细节都得到妥善处理,并准备好签署。-阶段转化标准:完成飞书合同协商审批,确认合同条款(包括付款条件、服务开通时间等)
6. **Closed Won成功关闭**:这是销售流程的最终目标,表示交易已经成功完成,客户已经购买了产品或服务。-阶段转化标准:完成合同签署,合同归档
7. **Cancel取消**:在某些情况下,交易可能会在过程的任何阶段取消。这可能是因为客户改变了主意,或者发现产品或服务不再符合他们的需求。-阶段标准:①客户明确回复项目取消 ②客户明确表示没有预算 ③内部立项未通过
8. **Closed Lost失败关闭**:如果销售机会没有成功,它将被标记为“失败关闭”。这可能是因为竞争、价格问题或客户需求的改变等原因。-阶段转化标准:①投标确认结果未赢标 ②客户明确表示选择友商 ③poc结果客户确认平凯未入围/未通过 ④商务谈判失败 ⑤其他如商务关系没有竞争机会
上述每个阶段的阶段转化标准是准出标准,只有在满足该准出标准,才可以进入到下一个阶段
'''
# Read the Excel file
df = pd.read_excel('output_top200.xlsx')
# Iterate over each row in the DataFrame
for index, row in df.iterrows():
# Extract the information from the column "当前详细状态及Close节奏"
try:
detailed_status = row['当前详细状态及Close节奏']
print(f"Processing row {index} at current time: {datetime.now()}")
detailed_current_stage = row['Sales stage']
prompt = (f"某公司当前销售定义为 {sales_stage_definition}, "
f"当前销售阶段为 {detailed_current_stage}, "
f"销售人员填写的销售动作日志为: {detailed_status} , "
f"请分析当前销售阶段以及销售动作日志,判断其销售动作是否完成了前一阶段的准出标准,以及是否支持将销售阶段转化到当前阶段{detailed_current_stage},按照如下要点给出分析:"
f"1. **销售阶段分析**"
f"2. **销售动作日志分析**"
f"3. **销售动作与销售阶段的关系**"
f"4. **判断结果**"
f"5. **销售阶段分析报告**")
analysis_result = agent.send_message(prompt)
print(analysis_result)
df.at[index, '分析结果'] = analysis_result # Directly update the DataFrame
prompt_sales_action_analysis = (f"某公司当前销售定义为 {sales_stage_definition}, "
f"当前销售阶段为 {detailed_current_stage}, "
f"销售人员填写的销售动作日志为: {detailed_status} , "
f"请分析当前销售阶段以及销售动作日志,分析、总结、提炼出销售动作,给出一个概括的销售动作列表,比如拜访客户,需求讨论这种形式的动作描述")
sales_action_analysis_result = agent.send_message(prompt_sales_action_analysis)
print(sales_action_analysis_result)
df.at[index, '销售动作分析'] = sales_action_analysis_result # Directly update the DataFrame
except Exception as e:
print(f"Error processing row {index}: {e}")
df.at[index, '分析结果'] = f"Error: {e}" # Log the error in the DataFrame
df.at[index, '销售动作分析'] = f"Error: {e}" # Log the error in the DataFrame
df.to_excel('analysis_result_top200.xlsx', index=False)