diff --git a/app/api/v2/zhipu_controller_v2.py b/app/api/v2/zhipu_controller_v2.py index 3e06f8e..988b0e0 100644 --- a/app/api/v2/zhipu_controller_v2.py +++ b/app/api/v2/zhipu_controller_v2.py @@ -281,7 +281,7 @@ def analysis_stream(): chunk_out = format_chunk(chunk, None, None) yield json.dumps(chunk_out) + '\n' - followup_info = get_analysis_followup_info(message,"1843318172036575232") + followup_info = get_analysis_followup_info(message, accumulated_result,"1843318172036575232") followup_info += "如有新的销售进展,请补充相关信息,我会为您做进一步分析" yield json.dumps(format_chunk("", followup_info, "")) + '\n' logger.info(f'accumulated_result: {accumulated_result}') @@ -290,29 +290,29 @@ def analysis_stream(): return Response(event_stream(), mimetype='text/event-stream', headers=response_headers) -def get_analysis_followup_info(message, knowledge_id): +def get_analysis_followup_info(origin_message, analysis_text , knowledge_id): followup_info = "" # 1. Get business contact info - if '汇理' in message: + if '汇理' in origin_message: # followup_info += "### 联系人信息\n" # followup_info += "- **陈明宇** (技术总监)\n - 📱 186-2155-7823\n" # followup_info += "- **王雪梅** (项目经理)\n - 📱 135-8867-4932\n" - next_action_items = get_detailed_action_items(message, knowledge_id) - followup_info = get_detailed_action_guide(next_action_items, knowledge_id) + next_action_items = get_detailed_action_items(analysis_text, knowledge_id) + followup_info = get_detailed_action_guide(next_action_items, "1858506435089068032") - elif '芝麻地网科' in message: + elif '芝麻地网科' in origin_message: followup_info += "### 联系人信息\n" followup_info += "- **刘建华** (产品总监)\n - 📱 138-9876-5432\n" followup_info += "- **张婷婷** (商务经理)\n - 📱 159-2468-1357\n" - elif '联特科技' in message: + elif '联特科技' in origin_message: followup_info += "### 联系人信息\n" followup_info += "- **郭志强** (研发经理)\n - 📱 177-3344-5566\n" followup_info += "- **林小华** (项目主管)\n - 📱 136-9988-7766\n" - elif '视睿电子' in message: + elif '视睿电子' in origin_message: followup_info += "### 联系人信息\n" followup_info += "- **黄伟东** (技术经理)\n - 📱 158-1122-3344\n" followup_info += "- **赵敏** (销售总监)\n - 📱 139-5544-3322\n" - elif '深圳麦克韦尔' in message: + elif '深圳麦克韦尔' in origin_message: followup_info += "### 联系人信息\n" followup_info += "- **吴晓峰** (部门主管)\n - 📱 182-8899-7766\n" followup_info += "- **孙丽华** (商务代表)\n - 📱 137-6655-4433\n" @@ -335,8 +335,9 @@ def get_detailed_action_items(message, knowledge_id): prompt_detailed_action_items = f""" 以下是销售行动建议及分析报告 {message} -请提取出其中的下一步行动建议,并返回给用户 +请提取上述文本中下一步行动建议的原始文本并返回 """ + logger.info(f'prompt_detailed_action_items: {prompt_detailed_action_items}') detailed_action_items = openai_service.generate_response(prompt_detailed_action_items) logger.info(f'detailed_action_items: {detailed_action_items}') return detailed_action_items diff --git a/app/services/openai_service.py b/app/services/openai_service.py index 493e524..e7c4f88 100644 --- a/app/services/openai_service.py +++ b/app/services/openai_service.py @@ -15,7 +15,7 @@ class OpenaiService(AIServiceInterface): response = self.client.chat.completions.create( model="gpt-4o-mini", messages=[{"role": "system", "content": prompt}], - temperature=0.7, + temperature=0.9 ) return response.choices[0].message.content except Exception as e: