market_assistant/analysis_pipeline.py

63 lines
3.4 KiB
Python
Raw 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
# 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资格认定**:这一阶段的目标是确定潜在客户是否具有成为合格销售机会的潜力。这通常涉及对客户的预算、需求、决策过程和时间线等进行评估。
4. **Bidding / Negotiating投标/谈判)**:在这个阶段,销售人员会向客户提交正式的报价或提案,并进行必要的谈判,以达成最终的销售协议。
5. **Contract Review合同审查**:一旦谈判完成,双方将审查合同条款,确保所有细节都得到妥善处理,并准备好签署。
6. **Closed Won成功关闭**:这是销售流程的最终目标,表示交易已经成功完成,客户已经购买了产品或服务。
7. **Cancel取消**:在某些情况下,交易可能会在过程的任何阶段取消。这可能是因为客户改变了主意,或者发现产品或服务不再符合他们的需求。
8. **Closed Lost失败关闭**:如果销售机会没有成功,它将被标记为“失败关闭”。这可能是因为竞争、价格问题或客户需求的改变等原因。'''
# Read the Excel file
df = pd.read_excel('output_top20.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}")
detailed_current_stage = row['Sales stage']
prompt = f"某公司当前销售定义为 {sales_stage_definition}, 当前销售阶段为 {detailed_current_stage}, 销售人员填写的销售动作日志为: {detailed_status} , 请分析当前销售阶段以及销售动作日志,判断其销售动作是否支持将销售阶段转化到当前阶段{detailed_current_stage},给出判断结果及销售阶段分析报告"
analysis_result = agent.send_message(prompt)
print(analysis_result)
df.at[index, '分析结果'] = 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.to_excel('analysis_result.xlsx', index=False)