Commit Graph
9 Commits
Author SHA1 Message Date
itismygoandClaude Sonnet 4.5 eff701c485 fix: 修复 grok-imagine-0.9 同时支持文生图和图生视频
- 恢复 is_video_model: True 以支持视频生成
- 更新模型描述说明支持两种模式
- 保留空列表安全访问修复

根据 xAI 官方文档,grok-imagine-0.9 支持:
1. 文本 → 图片 (text-to-image)
2. 图片 + 文本 → 视频 (image-to-video)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-12 04:14:01 +00:00
itismygo 300b03fdde fix: 修复 grok-imagine-0.9 纯文本生成图片的bug
## 问题描述
当使用 grok-imagine-0.9 模型进行纯文本到图片生成时,会抛出 "list index out of range" 错误。

## 根本原因
1. **模型配置错误**: grok-imagine-0.9 被错误地标记为视频模型 (`is_video_model: True`)
2. **数组访问bug**: 在没有图片附件时,代码尝试访问空列表的第一个元素 `payload.get("fileAttachments", [""])[0]`

## 修复内容

### app/models/grok_models.py
- 将 `is_video_model` 从 `True` 改为 `False`
- 更新 description 为 "Image generation model powered by Grok"

### app/services/grok/client.py
- 修复空列表访问bug,使用安全的访问方式:
  ```python
  file_attachments = payload.get("fileAttachments", [])
  ref_id = post_id or (file_attachments[0] if file_attachments else "")
  ```

## 测试结果
✅ 纯文本生成图片:成功
✅ 文本对话:正常
✅ 其他模型:不受影响

## 相关信息
根据 xAI 官方文档,Grok Imagine 主要是图像生成模型(使用 Aurora 引擎),支持 text-to-image 功能。
2025-12-12 02:26:29 +00:00
Chenyme db73406dae feat: review python code & optimize code structure 2025-11-20 17:15:02 +08:00
Chenyme 9df0ba5e11 fix: corrected parameters of the grok-4.1-thinking model 2025-11-18 10:09:17 +08:00
Chenyme eeb4f7120d feat: support new model grok 4.1 2025-11-18 09:50:07 +08:00
Chenyme 90a11df85d fix: proxy exception repair 2025-10-14 10:07:01 +08:00
Chenyme 93d29d0f8f feat: add grok imagine 0.9 2025-10-14 01:55:16 +08:00
Chenyme 07e9682716 feat: support grok video generation 2025-10-14 01:46:50 +08:00
Chenyme ba617455f0 release: the first version 2025-10-10 16:59:56 +08:00