Skip to content

🎬 火宝短剧 - 基于AI的一站式短剧生成平台 《一句话生成完整短剧,从剧本到成片全自动化》 Huobao Drama - An AI-Powered End-to-End Short Drama Generator "One Sentence to Complete Drama: Fully Automated from Script to Final Video"

TypeScript

fix:修改测试连接判断

jiangzjeb0f34a4d171
diff --git a/pkg/ai/openai_client.go b/pkg/ai/openai_client.go
index bd2c543..d9f82e1 100644
--- a/pkg/ai/openai_client.go
+++ b/pkg/ai/openai_client.go
@@ -168,6 +168,7 @@ func (c *OpenAIClient) sendChatRequest(req *ChatCompletionRequest) (*ChatComplet
if len(chatResp.Choices) > 0 {
finishReason := chatResp.Choices[0].FinishReason
content := chatResp.Choices[0].Message.Content
+ usage := chatResp.Usage
fmt.Printf("OpenAI: finish_reason=%s, content_length=%d\n", finishReason, len(content))
@@ -175,7 +176,7 @@ func (c *OpenAIClient) sendChatRequest(req *ChatCompletionRequest) (*ChatComplet
return nil, fmt.Errorf("AI内容被安全过滤器拦截,可能因为:\n1. 请求内容触发了安全策略\n2. 生成的内容包含敏感信息\n3. 建议:调整输入内容或联系API提供商调整过滤策略")
}
- if content == "" && finishReason != "stop" {
+ if usage.TotalTokens == 0 && finishReason != "stop" {
return nil, fmt.Errorf("AI返回内容为空 (finish_reason: %s),可能的原因:\n1. 内容被过滤\n2. Token限制\n3. API异常", finishReason)
}
}