`content_image_url` throws error in local vision model

Aperta
#20 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
38/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
ollama, python
Ambito
ai

Direzione di ricerca

Inizia con content_image_url e il percorso ContentImageRemote, quindi segui la richiesta attraverso chatlas/_chat.py e chatlas/_openai.py. Confronta la richiesta per l’immagine remota con l’esempio funzionante di content_image_file e riproduci la chiamata Ollama llama3.2-vision; l’attività è completata quando l’immagine dell’URL viene accettata senza l’errore di input immagine non valido.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
Python
Stelle
179
Fork
32
Merge medio
1g 3h
PR unite (30g)
10

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di posit-dev/chatlas

Tutte le issue di posit-dev/chatlas

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.