`content_image_url` throws error in local vision model

未关闭
#20 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
ollama, python
领域
ai

调研方向

从 content_image_url 和 ContentImageRemote 路径开始,然后跟踪请求经过 chatlas/_chat.py 和 chatlas/_openai.py 的流程。将远程图像请求与可正常工作的 content_image_file 示例进行比较,并复现 Ollama llama3.2-vision 调用;当 URL 图像能够被接受且不再出现无效图像输入错误时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Hi- thanks for creating this package! I'm testing out some local vision workflows with ollama and llama3.2-vision. I seem to get an error when using the content_image_url function to fetch an image:

from chatlas import ChatOllama, content_image_url, content_image_file

# Initialize chat with ollama llama3.2-vision
chat = ChatOllama(model="llama3.2-vision")

# Using content_image_url
chat.chat(
    "What do you see in this image?",
    content_image_url("https://www.python.org/static/img/python-logo.png"),
    echo="all"
)

Throws this error:



                                                           👤 User turn:

What do you see in this image?

<< 👤 other content >>

🌆 python-logo.png


                                                        🤖 Assistant turn:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "\.venv\lib\site-packages\chatlas\_chat.py", line 356, in chat
    for _ in response:
  File "\.venv\lib\site-packages\chatlas\_chat.py", line 1169, in __next__
    chunk = next(self._generator)
  File "\.venv\lib\site-packages\chatlas\_chat.py", line 833, in _chat_impl
    for chunk in self._submit_turns(
  File "\.venv\lib\site-packages\chatlas\_chat.py", line 884, in _submit_turns
    response = self.provider.chat_perform(
  File "\.venv\lib\site-packages\chatlas\_openai.py", line 247, in chat_perform
    return self._client.chat.completions.create(**kwargs)  # type: ignore
  File "\.venv\lib\site-packages\openai\_utils\_utils.py", line 275, in wrapper
    return func(*args, **kwargs)
  File "\.venv\lib\site-packages\openai\resources\chat\completions.py", line 829, in create
    return self._post(
  File "\.venv\lib\site-packages\openai\_base_client.py", line 1280, in post
    return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
  File "\.venv\lib\site-packages\openai\_base_client.py", line 957, in request
    return self._request(
  File "\.venv\lib\site-packages\openai\_base_client.py", line 1061, in _request
    raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'error': {'message': 'invalid image input', 'type': 'invalid_request_error', 'param': None, 'code': None}}

The content_image_url("https://www.python.org/static/img/python-logo.png") seems to fetch the image and store it as a ContentImageRemote object.

Also, this works fine with content_image_file function:

chat.chat(
    "What do you see in this image?",
    content_image_file("python-logo.png"),
    echo="all"
)
                                👤 User turn:                                                                
                                                                                                             
What do you see in this image?                                                                               
                                                                                                             
<< 👤 other content >>                                                                                       
                                                                                                             
🌆 Dw2mJn+YhmuMAAAAAElFTkSuQmCC                                                                              
                                                                                                             
                                                                                                             
                              🤖 Assistant turn:                                                             
                                                                                                             
The image features the Python logo, which is a stylized representation of the                                
word "python" and serves as an emblem for the official implementation of the                                 
Python programming language.                                                                                 
                                                                                                             
Key Features:                                                                                                
                                                                                                             
 • Color scheme:                                                                                             
    • Primary color: Blue                                                                                    
    • Secondary color: Yellow                                                                                
 • Positioning: Left side of the screen                                                                      
                                                                                                             
Purpose: The logo is used to represent the official Python programming                                       
language, providing a clear visual identifier for users.    

I've tested this with version 0.2.0 and version 0.2.1.dev1+g6e81eb3 of chatlas.

主要语言
Python
星标
179
派生
32
平均合并
1 天 3 小时
30 天内合并 PR
10

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

posit-dev/chatlas 的其他 Issue

查看 posit-dev/chatlas 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。