更新代码并修改远程仓库地址

This commit is contained in:
史悦
2025-09-02 13:53:24 +08:00
parent 9471480c89
commit 4c6e03a59f
9 changed files with 132 additions and 9 deletions

View File

@@ -266,13 +266,17 @@ class AIAnalyzer:
chunk_data = json.loads(line)
# 检查是否有finish_reason
finish_reason = chunk_data.get("choices", [{}])[0].get("finish_reason")
choices = chunk_data.get("choices", [])
if not choices:
logger.debug("收到空的choices数组跳过")
continue
finish_reason = choices[0].get("finish_reason")
if finish_reason == "stop":
logger.debug("收到finish_reason=stop流结束")
continue
# 获取delta内容
delta = chunk_data.get("choices", [{}])[0].get("delta", {})
delta = choices[0].get("delta", {})
# 检查delta是否为空对象
if not delta or delta == {}:
@@ -350,7 +354,16 @@ class AIAnalyzer:
return
response_data = response.json()
analysis_text = response_data.get("choices", [{}])[0].get("message", {}).get("content", "")
choices = response_data.get("choices", [])
if not choices:
logger.error("API响应中没有choices数据")
yield json.dumps({
"stock_code": stock_code,
"error": "API响应格式错误缺少choices数据",
"status": "error"
})
return
analysis_text = choices[0].get("message", {}).get("content", "")
# 尝试从分析内容中提取投资建议
recommendation = self._extract_recommendation(analysis_text)