更新代码并修改远程仓库地址
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user