Sorry, something went wrong.
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
Sorry, something went wrong.
| ) or plugin_context.get_config(umo=event.unified_msg_origin).get( | ||
| "provider_settings", {} |
There was a problem hiding this comment.
issue (bug_risk): Guard against plugin_context.get_config returning None before calling .get.
plugin_context.get_config(umo=event.unified_msg_origin) may return None, which would cause an AttributeError when calling .get. Consider defaulting to an empty dict, e.g. (plugin_context.get_config(umo=event.unified_msg_origin) or {}).get("provider_settings", {}), to make this robust in partially configured environments.
Sorry, something went wrong.
There was a problem hiding this comment.
This pull request introduces configurable image caption prompts and conditional image URL handling within the main agent. Key changes include updating _process_quote_message to utilize a custom prompt from the configuration and modifying build_main_agent to skip appending image URLs when a specific image caption provider is active. The review feedback suggests refactoring duplicated configuration logic for better maintainability and ensuring that fallback settings are consistently applied to the message parser.
Sorry, something went wrong.
| cfg = ( | ||
| config.provider_settings if config else None | ||
| ) or plugin_context.get_config(umo=event.unified_msg_origin).get( | ||
| "provider_settings", {} | ||
| ) |
There was a problem hiding this comment.
The logic for retrieving cfg with fallback is duplicated here and in _decorate_llm_request (line 888). Since _process_quote_message is called from _decorate_llm_request, it would be more efficient and maintainable to pass cfg as an argument to this function instead of recalculating it, especially since plugin_context.get_config might involve overhead.
References
Sorry, something went wrong.
| quoted_message_settings = _get_quoted_message_parser_settings( | ||
| config.provider_settings | ||
| ) | ||
| cfg = config.provider_settings or plugin_context.get_config( | ||
| umo=event.unified_msg_origin | ||
| ).get("provider_settings", {}) | ||
| img_cap_prov_id = cfg.get("default_image_caption_provider_id") or "" |
There was a problem hiding this comment.
The cfg variable (which includes fallback settings from the plugin configuration) should be used when initializing quoted_message_settings. Currently, quoted_message_settings only uses config.provider_settings, which may be empty even if the user has configured settings globally. Using cfg ensures that the parser settings correctly respect the fallback configuration, maintaining consistency with how img_cap_prov_id is handled. Additionally, new functionality such as handling attachments should be accompanied by corresponding unit tests.
Sorry, something went wrong.
This PR resolves two issues related to image captioning configuration and behavior when handling quoted/embedded images:
Modifications / 改动点
Modified astr_main_agent.py:
This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Before Changes / 改动前:
After the change / 改动后:
Checklist / 检查清单
😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
/ 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。
👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
/ 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
/ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txt 和 pyproject.toml 文件相应位置。
😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Honor provider-configured image captioning settings and avoid sending duplicate image URLs when a dedicated caption provider is configured.
Bug Fixes: