AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug]项目是否支持多模态?比如gpt-4o和谷歌gemini的图片编辑功能?

Open ladypiapia opened this issue 1 year ago • 8 comments

发生了什么

感谢开发者的项目,非常棒!请问这个项目目前是否原生支持同时发送文字和图片给模型,然后返回结果呢?就像openai和谷歌支持发送图片和描述然后返回结果?还是说需要另外通过插件的形式来实现?

如何复现?

我切换到gemini-2.0-flash-preview-image-generation这个模型,然后发送一张图片,收到了报错,我期望是发送一张图片,在发送文本描述,最后再收到返回的结果,目前不知道如何操作

AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

AstrBot版本:v3.5.9 部署方式:Docker 部署平台:CentOS服务器 提供商:genimi-gemini-2.0-flash-preview-image-generation 消息平台适配器:钉钉、企业微信、telegram

操作系统

Not sure

报错日志

 [15:24:01] [Core] [INFO] [core.event_bus:50]: [telegram] lady2099/5397545166: [图片]  
 [15:24:01] [Core] [INFO] [respond.stage:131]: 应用流式输出(telegram) 
 [15:24:02] [Core] [WARN] [sources.gemini_source:430]: gemini-2.0-flash-preview-image-generation 不支持函数调用,已自动去除 
 [15:24:02] [Core] [WARN] [sources.gemini_source:425]: gemini-2.0-flash-preview-image-generation 不支持 system prompt,已自动去除(影响人格设置) 
 [15:24:02] [Core] [ERRO] [sources.gemini_source:119]: 发生了错误(gemini_source)。Provider 配置如下: {'id': 'gemini_default', 'type': 'googlegenai_chat_completion', 'provider_type': 'chat_completion', 'enable': True, 'key': ['AIzaSyDgYtNsizol7F_YLntCnYVWWDPpPDH552c'], 'api_base': 'https://generativelanguage.googleapis.com/', 'timeout': 120, 'model_config': {'model': 'gemini-2.0-flash-preview-image-generation'}, 'gm_resp_image_modal': False, 'gm_native_search': False, 'gm_native_coderunner': False, 'gm_safety_settings': {'harassment': 'BLOCK_MEDIUM_AND_ABOVE', 'hate_speech': 'BLOCK_MEDIUM_AND_ABOVE', 'sexually_explicit': 'BLOCK_MEDIUM_AND_ABOVE', 'dangerous_content': 'BLOCK_MEDIUM_AND_ABOVE'}, 'gm_thinking_config': {'budget': 128000}} 
 [15:24:02] [Core] [ERRO] [method.llm_request:257]: Traceback (most recent call last):
  File "/AstrBot/astrbot/core/pipeline/process_stage/method/llm_request.py", line 185, in requesting
    async for llm_response in stream:
  File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 546, in text_chat_stream
    if await self._handle_api_error(e, keys):
  File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 122, in _handle_api_error
    raise e
  File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 542, in text_chat_stream
    async for response in self._query_stream(payloads, func_tool):
  File "/AstrBot/astrbot/core/provider/sources/gemini_source.py", line 417, in _query_stream
    result = await self.client.models.generate_content_stream(
  File "/usr/local/lib/python3.10/site-packages/google/genai/models.py", line 6631, in generate_content_stream
    response = await self._generate_content_stream(
  File "/usr/local/lib/python3.10/site-packages/google/genai/models.py", line 5594, in _generate_content_stream
    response_stream = await self._api_client.async_request_streamed(
  File "/usr/local/lib/python3.10/site-packages/google/genai/_api_client.py", line 802, in async_request_streamed
    response = await self._async_request(http_request=http_request, stream=True)
  File "/usr/local/lib/python3.10/site-packages/google/genai/_api_client.py", line 717, in _async_request
    await errors.APIError.raise_for_async_response(response)
  File "/usr/local/lib/python3.10/site-packages/google/genai/errors.py", line 129, in raise_for_async_response
    raise ClientError(status_code, response_json, response)
google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'The requested combination of response modalities is not supported by the model. models/gemini-2.0-flash-preview-image-generation accepts the following combination of response modalities:\n* TEXT, IMAGE\n', 'status': 'INVALID_ARGUMENT'}}
 
 [15:24:02] [Core] [INFO] [respond.stage:190]: AstrBot -> lady2099/5397545166: AstrBot 请求失败。
错误类型: ClientError
错误信息: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'The requested combination of response modalities is not supported by the model. models/gemini-2.0-flash-preview-image-generation accepts the following combination of response modalities:\n* TEXT, IMAGE\n', 'status': 'INVALID_ARGUMENT'}}  

你愿意提交 PR 吗?

  • [ ] 是的,我愿意提交 PR!

Code of Conduct

  • [x] 我已阅读并同意遵守该项目的 行为准则。

ladypiapia avatar May 13 '25 07:05 ladypiapia

支持,函数调用对4OMINI最佳

Funkyney avatar May 13 '25 09:05 Funkyney

支持,函数调用对4OMINI最佳

请问具体如何实现,需要如何配置?支持哪些平台呢?感谢

ladypiapia avatar May 13 '25 09:05 ladypiapia

Image

Gemini原生提供商支持图片模态输出(不能开启流式输出)。见下例:

Image

Raven95676 avatar May 13 '25 10:05 Raven95676

如果不需要返回图片,则无需额外设置。目前Gemini几乎全系模型都支持图片输入。

Image

实际使用中建议配置图片转述:

Image

Raven95676 avatar May 13 '25 10:05 Raven95676

Image

Gemini原生提供商支持图片模态输出(不能开启流式输出)。见下例:

Image

原来如此,我使用的telegram,开启了流失回复,一直报错,关闭之后可以了,非常感谢

ladypiapia avatar May 13 '25 10:05 ladypiapia

@Raven95676 遇到两个新的问题,辛苦大佬再解答一下: 1.使用gemini-2.0-flash-preview-image-generation模型时,偶尔只返回了文字,没有返回图片,正常应该是文字和图片一起返回,左为正常情况,右为异常情况


2.使用微信客服时,同样是gemini-2.0-flash-preview-image-generation模型,直接发图片会自动给一个提示词,有时候还会发好几个提示词,这个是项目自带的一个优化嘛?那可以自己写提示词不呢?以及如何获取返回的图片呢?

ladypiapia avatar May 14 '25 09:05 ladypiapia

@Raven95676 遇到两个新的问题,辛苦大佬再解答一下: 1.使用gemini-2.0-flash-preview-image-generation模型时,偶尔只返回了文字,没有返回图片,正常应该是文字和图片一起返回,左为正常情况,右为异常情况

2.使用微信客服时,同样是gemini-2.0-flash-preview-image-generation模型,直接发图片会自动给一个提示词,有时候还会发好几个提示词,这个是项目自带的一个优化嘛?那可以自己写提示词不呢?以及如何获取返回的图片呢?

模型问题

Raven95676 avatar May 14 '25 10:05 Raven95676

好吧 谢谢

ladypiapia avatar May 15 '25 02:05 ladypiapia