-
-
Notifications
You must be signed in to change notification settings - Fork 968
修复配置图片转述供应商后自动调用图片转述的Bug #3295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
修复配置图片转述供应商后自动调用图片转述的Bug #3295
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
你好 - 我已审阅了你的更改,它们看起来很棒!
AI 代理的提示
请处理此代码审查中的评论:
## 单独评论
### 评论 1
<location> `packages/astrbot/process_llm_request.py:159` </location>
<code_context>
# image caption
+ # 只有当前 provider 不支持图像时才使用图像转述
if img_cap_prov_id and req.image_urls:
- await self._ensure_img_caption(req, cfg, img_cap_prov_id)
+ current_provider = self.ctx.get_using_provider(
</code_context>
<issue_to_address>
**问题 (复杂性):** 考虑将提供者图像支持检查重构为一个辅助方法,以简化主逻辑流程。
```markdown
考虑将所有这些嵌套、配置查找和日志记录提取到一个小型辅助方法中,例如 `_provider_supports_image()`。这样你的主流程就只是一个 `if`/`await`,并且可以移除大量的样板代码。
示例:
```python
def _provider_supports_image(self, event) -> bool:
provider = self.ctx.get_using_provider(umo=event.unified_msg_origin)
if not provider:
logger.debug("[IMG Caption] no provider → will caption")
return False
try:
pid = provider.meta().id
cfg = self.ctx.get_config(umo=event.unified_msg_origin)
for p in cfg.get("provider", []):
if p.get("id") == pid and "image" in p.get("modalities", []):
logger.debug(f"[IMG Caption] {pid} supports image → skip caption")
return True
logger.debug(f"[IMG Caption] {pid} does not support image")
except Exception as e:
logger.warning(f"[IMG Caption] failed to check provider support: {e}")
return False
```
然后将大块代码替换为:
```python
if img_cap_prov_id and req.image_urls:
if not self._provider_supports_image(event):
await self._ensure_img_caption(req, cfg, img_cap_prov_id)
```
这保持了完全相同的逻辑和日志记录,但将所有分支合并到一个集中的辅助方法中。
</issue_to_address>帮助我更有用!请在每条评论上点击 👍 或 👎,我将利用反馈来改进你的评论。
Original comment in English
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `packages/astrbot/process_llm_request.py:159` </location>
<code_context>
# image caption
+ # 只有当前 provider 不支持图像时才使用图像转述
if img_cap_prov_id and req.image_urls:
- await self._ensure_img_caption(req, cfg, img_cap_prov_id)
+ current_provider = self.ctx.get_using_provider(
</code_context>
<issue_to_address>
**issue (complexity):** Consider refactoring the provider image support check into a helper method to simplify the main logic flow.
```markdown
Consider pulling all of that nesting, config‐lookup and logging into one small helper, e.g. `_provider_supports_image()`. Then your main flow is just one `if`/`await` and you remove a ton of boilerplate.
Example:
```python
def _provider_supports_image(self, event) -> bool:
provider = self.ctx.get_using_provider(umo=event.unified_msg_origin)
if not provider:
logger.debug("[IMG Caption] no provider → will caption")
return False
try:
pid = provider.meta().id
cfg = self.ctx.get_config(umo=event.unified_msg_origin)
for p in cfg.get("provider", []):
if p.get("id") == pid and "image" in p.get("modalities", []):
logger.debug(f"[IMG Caption] {pid} supports image → skip caption")
return True
logger.debug(f"[IMG Caption] {pid} does not support image")
except Exception as e:
logger.warning(f"[IMG Caption] failed to check provider support: {e}")
return False
```
Then replace the big block with:
```python
if img_cap_prov_id and req.image_urls:
if not self._provider_supports_image(event):
await self._ensure_img_caption(req, cfg, img_cap_prov_id)
```
This keeps exactly the same logic and logging but collapses all branching into one focused helper.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
|
||
| # image caption | ||
| # 只有当前 provider 不支持图像时才使用图像转述 | ||
| if img_cap_prov_id and req.image_urls: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
问题 (复杂性): 考虑将提供者图像支持检查重构为一个辅助方法,以简化主逻辑流程。
考虑将所有这些嵌套、配置查找和日志记录提取到一个小型辅助方法中,例如 `_provider_supports_image()`。这样你的主流程就只是一个 `if`/`await`,并且可以移除大量的样板代码。
示例:
```python
def _provider_supports_image(self, event) -> bool:
provider = self.ctx.get_using_provider(umo=event.unified_msg_origin)
if not provider:
logger.debug("[IMG Caption] no provider → will caption")
return False
try:
pid = provider.meta().id
cfg = self.ctx.get_config(umo=event.unified_msg_origin)
for p in cfg.get("provider", []):
if p.get("id") == pid and "image" in p.get("modalities", []):
logger.debug(f"[IMG Caption] {pid} supports image → skip caption")
return True
logger.debug(f"[IMG Caption] {pid} does not support image")
except Exception as e:
logger.warning(f"[IMG Caption] failed to check provider support: {e}")
return False然后将大块代码替换为:
if img_cap_prov_id and req.image_urls:
if not self._provider_supports_image(event):
await self._ensure_img_caption(req, cfg, img_cap_prov_id)这保持了完全相同的逻辑和日志记录,但将所有分支合并到一个集中的辅助方法中。
Original comment in English
issue (complexity): Consider refactoring the provider image support check into a helper method to simplify the main logic flow.
Consider pulling all of that nesting, config‐lookup and logging into one small helper, e.g. `_provider_supports_image()`. Then your main flow is just one `if`/`await` and you remove a ton of boilerplate.
Example:
```python
def _provider_supports_image(self, event) -> bool:
provider = self.ctx.get_using_provider(umo=event.unified_msg_origin)
if not provider:
logger.debug("[IMG Caption] no provider → will caption")
return False
try:
pid = provider.meta().id
cfg = self.ctx.get_config(umo=event.unified_msg_origin)
for p in cfg.get("provider", []):
if p.get("id") == pid and "image" in p.get("modalities", []):
logger.debug(f"[IMG Caption] {pid} supports image → skip caption")
return True
logger.debug(f"[IMG Caption] {pid} does not support image")
except Exception as e:
logger.warning(f"[IMG Caption] failed to check provider support: {e}")
return FalseThen replace the big block with:
if img_cap_prov_id and req.image_urls:
if not self._provider_supports_image(event):
await self._ensure_img_caption(req, cfg, img_cap_prov_id)This keeps exactly the same logic and logging but collapses all branching into one focused helper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the image caption functionality by making it conditional on the provider's image support capabilities. Instead of unconditionally using image captioning when configured, the code now checks whether the current provider supports images natively before falling back to image captioning.
Key changes:
- Added logic to check if the current provider supports image modality by inspecting its configuration
- Image captioning is now only used when the provider doesn't support images natively
- Added extensive debug logging to trace the provider capability detection process
| # 从配置中查找当前 provider 的配置 | ||
| full_cfg = self.ctx.get_config(umo=event.unified_msg_origin) | ||
| providers_list = full_cfg.get("provider", []) | ||
| logger.debug( | ||
| f"[IMG Caption] 配置中的 provider 数量: {len(providers_list)}" | ||
| ) | ||
| logger.debug( | ||
| f"[IMG Caption] 所有 provider IDs: {[p.get('id') for p in providers_list]}" | ||
| ) | ||
|
|
||
| for provider_cfg in providers_list: | ||
| if provider_cfg.get("id") == provider_id: | ||
| modalities = provider_cfg.get("modalities", []) | ||
| logger.debug( | ||
| f"[IMG Caption] 找到 provider 配置,modalities: {modalities}" | ||
| ) | ||
| if "image" in modalities: | ||
| provider_supports_image = True | ||
| logger.debug( | ||
| "[IMG Caption] Provider 支持图像能力,跳过图像转述" | ||
| ) | ||
| break | ||
| else: | ||
| logger.debug( | ||
| f"[IMG Caption] 未找到 provider_id={provider_id} 的配置" |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This duplicates existing provider modality checking logic. The same functionality exists in astrbot/core/pipeline/process_stage/method/llm_request.py lines 510-516 where provider.provider_config.get('modalities', ['image']) is used. Consider using current_provider.provider_config.get('modalities', []) directly instead of searching through the config list, which would simplify this code significantly.
| # 从配置中查找当前 provider 的配置 | |
| full_cfg = self.ctx.get_config(umo=event.unified_msg_origin) | |
| providers_list = full_cfg.get("provider", []) | |
| logger.debug( | |
| f"[IMG Caption] 配置中的 provider 数量: {len(providers_list)}" | |
| ) | |
| logger.debug( | |
| f"[IMG Caption] 所有 provider IDs: {[p.get('id') for p in providers_list]}" | |
| ) | |
| for provider_cfg in providers_list: | |
| if provider_cfg.get("id") == provider_id: | |
| modalities = provider_cfg.get("modalities", []) | |
| logger.debug( | |
| f"[IMG Caption] 找到 provider 配置,modalities: {modalities}" | |
| ) | |
| if "image" in modalities: | |
| provider_supports_image = True | |
| logger.debug( | |
| "[IMG Caption] Provider 支持图像能力,跳过图像转述" | |
| ) | |
| break | |
| else: | |
| logger.debug( | |
| f"[IMG Caption] 未找到 provider_id={provider_id} 的配置" | |
| # 直接从当前 provider 的配置获取 modalities | |
| modalities = current_provider.provider_config.get("modalities", []) | |
| logger.debug( | |
| f"[IMG Caption] 当前 provider 配置 modalities: {modalities}" | |
| ) | |
| if "image" in modalities: | |
| provider_supports_image = True | |
| logger.debug( | |
| "[IMG Caption] Provider 支持图像能力,跳过图像转述" |
| logger.debug(f"[IMG Caption] 当前 provider: {current_provider}") | ||
|
|
||
| if current_provider: | ||
| try: | ||
| provider_id = current_provider.meta().id | ||
| logger.debug(f"[IMG Caption] Provider ID: {provider_id}") | ||
|
|
||
| # 从配置中查找当前 provider 的配置 | ||
| full_cfg = self.ctx.get_config(umo=event.unified_msg_origin) | ||
| providers_list = full_cfg.get("provider", []) | ||
| logger.debug( | ||
| f"[IMG Caption] 配置中的 provider 数量: {len(providers_list)}" | ||
| ) | ||
| logger.debug( | ||
| f"[IMG Caption] 所有 provider IDs: {[p.get('id') for p in providers_list]}" | ||
| ) | ||
|
|
||
| for provider_cfg in providers_list: | ||
| if provider_cfg.get("id") == provider_id: | ||
| modalities = provider_cfg.get("modalities", []) | ||
| logger.debug( | ||
| f"[IMG Caption] 找到 provider 配置,modalities: {modalities}" | ||
| ) | ||
| if "image" in modalities: | ||
| provider_supports_image = True | ||
| logger.debug( | ||
| "[IMG Caption] Provider 支持图像能力,跳过图像转述" | ||
| ) | ||
| break | ||
| else: | ||
| logger.debug( | ||
| f"[IMG Caption] 未找到 provider_id={provider_id} 的配置" | ||
| ) | ||
| except Exception as e: | ||
| logger.warning(f"[IMG Caption] 获取 provider 信息失败: {e}") | ||
| else: | ||
| logger.debug("[IMG Caption] 当前没有 provider") |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Excessive debug logging clutters the code and may impact performance. Consider reducing the number of debug statements to only the most critical decision points (e.g., lines 204 and 207-209), or consolidate multiple debug logs into fewer, more informative messages. Debug logs at lines 165, 175-180, 185-187, 195-197, and 201 could be removed or reduced.
| logger.debug(f"[IMG Caption] 当前 provider: {current_provider}") | |
| if current_provider: | |
| try: | |
| provider_id = current_provider.meta().id | |
| logger.debug(f"[IMG Caption] Provider ID: {provider_id}") | |
| # 从配置中查找当前 provider 的配置 | |
| full_cfg = self.ctx.get_config(umo=event.unified_msg_origin) | |
| providers_list = full_cfg.get("provider", []) | |
| logger.debug( | |
| f"[IMG Caption] 配置中的 provider 数量: {len(providers_list)}" | |
| ) | |
| logger.debug( | |
| f"[IMG Caption] 所有 provider IDs: {[p.get('id') for p in providers_list]}" | |
| ) | |
| for provider_cfg in providers_list: | |
| if provider_cfg.get("id") == provider_id: | |
| modalities = provider_cfg.get("modalities", []) | |
| logger.debug( | |
| f"[IMG Caption] 找到 provider 配置,modalities: {modalities}" | |
| ) | |
| if "image" in modalities: | |
| provider_supports_image = True | |
| logger.debug( | |
| "[IMG Caption] Provider 支持图像能力,跳过图像转述" | |
| ) | |
| break | |
| else: | |
| logger.debug( | |
| f"[IMG Caption] 未找到 provider_id={provider_id} 的配置" | |
| ) | |
| except Exception as e: | |
| logger.warning(f"[IMG Caption] 获取 provider 信息失败: {e}") | |
| else: | |
| logger.debug("[IMG Caption] 当前没有 provider") | |
| # Removed excessive debug logging; retain only critical decision point logs below. | |
| if current_provider: | |
| try: | |
| provider_id = current_provider.meta().id | |
| # Removed: logger.debug(f"[IMG Caption] Provider ID: {provider_id}") | |
| # 从配置中查找当前 provider 的配置 | |
| full_cfg = self.ctx.get_config(umo=event.unified_msg_origin) | |
| providers_list = full_cfg.get("provider", []) | |
| # Removed: logger.debug(f"[IMG Caption] 配置中的 provider 数量: {len(providers_list)}") | |
| # Removed: logger.debug(f"[IMG Caption] 所有 provider IDs: {[p.get('id') for p in providers_list]}") | |
| for provider_cfg in providers_list: | |
| if provider_cfg.get("id") == provider_id: | |
| modalities = provider_cfg.get("modalities", []) | |
| # Removed: logger.debug(f"[IMG Caption] 找到 provider 配置,modalities: {modalities}") | |
| if "image" in modalities: | |
| provider_supports_image = True | |
| # Removed: logger.debug("[IMG Caption] Provider 支持图像能力,跳过图像转述") | |
| break | |
| else: | |
| # Removed: logger.debug(f"[IMG Caption] 未找到 provider_id={provider_id} 的配置") | |
| except Exception as e: | |
| logger.warning(f"[IMG Caption] 获取 provider 信息失败: {e}") | |
| else: | |
| # Removed: logger.debug("[IMG Caption] 当前没有 provider") |
| logger.debug(f"[IMG Caption] 当前 provider: {current_provider}") | ||
|
|
||
| if current_provider: | ||
| try: | ||
| provider_id = current_provider.meta().id | ||
| logger.debug(f"[IMG Caption] Provider ID: {provider_id}") | ||
|
|
||
| # 从配置中查找当前 provider 的配置 | ||
| full_cfg = self.ctx.get_config(umo=event.unified_msg_origin) | ||
| providers_list = full_cfg.get("provider", []) | ||
| logger.debug( | ||
| f"[IMG Caption] 配置中的 provider 数量: {len(providers_list)}" | ||
| ) | ||
| logger.debug( | ||
| f"[IMG Caption] 所有 provider IDs: {[p.get('id') for p in providers_list]}" | ||
| ) | ||
|
|
||
| for provider_cfg in providers_list: | ||
| if provider_cfg.get("id") == provider_id: | ||
| modalities = provider_cfg.get("modalities", []) | ||
| logger.debug( | ||
| f"[IMG Caption] 找到 provider 配置,modalities: {modalities}" | ||
| ) | ||
| if "image" in modalities: | ||
| provider_supports_image = True | ||
| logger.debug( | ||
| "[IMG Caption] Provider 支持图像能力,跳过图像转述" | ||
| ) | ||
| break | ||
| else: | ||
| logger.debug( | ||
| f"[IMG Caption] 未找到 provider_id={provider_id} 的配置" | ||
| ) | ||
| except Exception as e: | ||
| logger.warning(f"[IMG Caption] 获取 provider 信息失败: {e}") | ||
| else: | ||
| logger.debug("[IMG Caption] 当前没有 provider") |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Excessive debug logging clutters the code and may impact performance. Consider reducing the number of debug statements to only the most critical decision points (e.g., lines 204 and 207-209), or consolidate multiple debug logs into fewer, more informative messages. Debug logs at lines 165, 175-180, 185-187, 195-197, and 201 could be removed or reduced.
| logger.debug(f"[IMG Caption] 当前 provider: {current_provider}") | |
| if current_provider: | |
| try: | |
| provider_id = current_provider.meta().id | |
| logger.debug(f"[IMG Caption] Provider ID: {provider_id}") | |
| # 从配置中查找当前 provider 的配置 | |
| full_cfg = self.ctx.get_config(umo=event.unified_msg_origin) | |
| providers_list = full_cfg.get("provider", []) | |
| logger.debug( | |
| f"[IMG Caption] 配置中的 provider 数量: {len(providers_list)}" | |
| ) | |
| logger.debug( | |
| f"[IMG Caption] 所有 provider IDs: {[p.get('id') for p in providers_list]}" | |
| ) | |
| for provider_cfg in providers_list: | |
| if provider_cfg.get("id") == provider_id: | |
| modalities = provider_cfg.get("modalities", []) | |
| logger.debug( | |
| f"[IMG Caption] 找到 provider 配置,modalities: {modalities}" | |
| ) | |
| if "image" in modalities: | |
| provider_supports_image = True | |
| logger.debug( | |
| "[IMG Caption] Provider 支持图像能力,跳过图像转述" | |
| ) | |
| break | |
| else: | |
| logger.debug( | |
| f"[IMG Caption] 未找到 provider_id={provider_id} 的配置" | |
| ) | |
| except Exception as e: | |
| logger.warning(f"[IMG Caption] 获取 provider 信息失败: {e}") | |
| else: | |
| logger.debug("[IMG Caption] 当前没有 provider") | |
| # Removed excessive debug logs; only log at decision points below | |
| if current_provider: | |
| try: | |
| provider_id = current_provider.meta().id | |
| # (Optional) Could log provider_id here if needed for troubleshooting | |
| # 从配置中查找当前 provider 的配置 | |
| full_cfg = self.ctx.get_config(umo=event.unified_msg_origin) | |
| providers_list = full_cfg.get("provider", []) | |
| # Removed debug logs for provider list details | |
| for provider_cfg in providers_list: | |
| if provider_cfg.get("id") == provider_id: | |
| modalities = provider_cfg.get("modalities", []) | |
| # Removed debug log for modalities | |
| if "image" in modalities: | |
| provider_supports_image = True | |
| # Removed debug log for image capability | |
| break | |
| else: | |
| # Removed debug log for missing provider config | |
| except Exception as e: | |
| logger.warning(f"[IMG Caption] 获取 provider 信息失败: {e}") | |
| else: | |
| # Removed debug log for missing provider |
| logger.debug(f"[IMG Caption] 当前 provider: {current_provider}") | ||
|
|
||
| if current_provider: | ||
| try: | ||
| provider_id = current_provider.meta().id | ||
| logger.debug(f"[IMG Caption] Provider ID: {provider_id}") | ||
|
|
||
| # 从配置中查找当前 provider 的配置 | ||
| full_cfg = self.ctx.get_config(umo=event.unified_msg_origin) | ||
| providers_list = full_cfg.get("provider", []) | ||
| logger.debug( | ||
| f"[IMG Caption] 配置中的 provider 数量: {len(providers_list)}" | ||
| ) | ||
| logger.debug( | ||
| f"[IMG Caption] 所有 provider IDs: {[p.get('id') for p in providers_list]}" | ||
| ) | ||
|
|
||
| for provider_cfg in providers_list: | ||
| if provider_cfg.get("id") == provider_id: | ||
| modalities = provider_cfg.get("modalities", []) | ||
| logger.debug( | ||
| f"[IMG Caption] 找到 provider 配置,modalities: {modalities}" | ||
| ) | ||
| if "image" in modalities: | ||
| provider_supports_image = True | ||
| logger.debug( | ||
| "[IMG Caption] Provider 支持图像能力,跳过图像转述" | ||
| ) | ||
| break | ||
| else: | ||
| logger.debug( | ||
| f"[IMG Caption] 未找到 provider_id={provider_id} 的配置" | ||
| ) | ||
| except Exception as e: | ||
| logger.warning(f"[IMG Caption] 获取 provider 信息失败: {e}") | ||
| else: | ||
| logger.debug("[IMG Caption] 当前没有 provider") |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Excessive debug logging clutters the code and may impact performance. Consider reducing the number of debug statements to only the most critical decision points (e.g., lines 204 and 207-209), or consolidate multiple debug logs into fewer, more informative messages. Debug logs at lines 165, 175-180, 185-187, 195-197, and 201 could be removed or reduced.
| logger.debug(f"[IMG Caption] 当前 provider: {current_provider}") | |
| if current_provider: | |
| try: | |
| provider_id = current_provider.meta().id | |
| logger.debug(f"[IMG Caption] Provider ID: {provider_id}") | |
| # 从配置中查找当前 provider 的配置 | |
| full_cfg = self.ctx.get_config(umo=event.unified_msg_origin) | |
| providers_list = full_cfg.get("provider", []) | |
| logger.debug( | |
| f"[IMG Caption] 配置中的 provider 数量: {len(providers_list)}" | |
| ) | |
| logger.debug( | |
| f"[IMG Caption] 所有 provider IDs: {[p.get('id') for p in providers_list]}" | |
| ) | |
| for provider_cfg in providers_list: | |
| if provider_cfg.get("id") == provider_id: | |
| modalities = provider_cfg.get("modalities", []) | |
| logger.debug( | |
| f"[IMG Caption] 找到 provider 配置,modalities: {modalities}" | |
| ) | |
| if "image" in modalities: | |
| provider_supports_image = True | |
| logger.debug( | |
| "[IMG Caption] Provider 支持图像能力,跳过图像转述" | |
| ) | |
| break | |
| else: | |
| logger.debug( | |
| f"[IMG Caption] 未找到 provider_id={provider_id} 的配置" | |
| ) | |
| except Exception as e: | |
| logger.warning(f"[IMG Caption] 获取 provider 信息失败: {e}") | |
| else: | |
| logger.debug("[IMG Caption] 当前没有 provider") | |
| # Removed excessive debug logs; only log at decision points below | |
| if current_provider: | |
| try: | |
| provider_id = current_provider.meta().id | |
| # 从配置中查找当前 provider 的配置 | |
| full_cfg = self.ctx.get_config(umo=event.unified_msg_origin) | |
| providers_list = full_cfg.get("provider", []) | |
| for provider_cfg in providers_list: | |
| if provider_cfg.get("id") == provider_id: | |
| modalities = provider_cfg.get("modalities", []) | |
| if "image" in modalities: | |
| provider_supports_image = True | |
| break | |
| except Exception as e: | |
| logger.warning(f"[IMG Caption] 获取 provider 信息失败: {e}") | |
| # No need to log if no provider; decision point below will log outcome |
| logger.debug("[IMG Caption] 当前没有 provider") | ||
|
|
||
| if not provider_supports_image: | ||
| logger.debug("[IMG Caption] 当前 provider 不支持图像,启用图像转述") | ||
| await self._ensure_img_caption(req, cfg, img_cap_prov_id) | ||
| else: | ||
| logger.debug( | ||
| "[IMG Caption] 当前 provider 支持图像,直接传递图片 URL" | ||
| ) |
Copilot
AI
Nov 3, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Excessive debug logging clutters the code and may impact performance. Consider reducing the number of debug statements to only the most critical decision points (e.g., lines 204 and 207-209), or consolidate multiple debug logs into fewer, more informative messages. Debug logs at lines 165, 175-180, 185-187, 195-197, and 201 could be removed or reduced.
fixes #3198
Motivation / 动机
Modifications / 改动点
packages/astrbot/process_llm_request.py调用图片转述之前添加了当前供应商能力的判断
Verification Steps / 验证步骤
将对话供应商设为
支持/不支持图像会根据供应商情况选择是否使用图像转述
Screenshots or Test Results / 运行截图或测试结果
当前供应商支持图像能力的情况
当前供应商不支持图像能力的情况
同时也可以看出,相同情况下,转述效果是远不如模型的原生识图的
Compatibility & Breaking Changes / 兼容性与破坏性变更
Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.Sourcery 摘要
Bug 修复:
Original summary in English
Sourcery 总结
在调用图像描述功能之前,检查当前 LLM 提供商的图像支持,并且仅在提供商不具备图像能力时才调用它。
Bug 修复:
功能增强:
Original summary in English
Summary by Sourcery
Check the current LLM provider's image support before invoking image captioning and only call it when the provider lacks image capability.
Bug Fixes:
Enhancements: