yanndebray / programming-GPTs

Book in writing ... 🦜
https://yanndebray.github.io/programming-GPTs/
MIT License
3 stars 0 forks source link

chap 5 - support image outputs in code interpreter #21

Closed yanndebray closed 1 month ago

yanndebray commented 1 month ago

Example: plot function 1/sin(x)

AttributeError: 'ImageFileContentBlock' object has no attribute 'text'
Traceback:
File "C:\Users\ydebray\Downloads\gpt-programming-book\env\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 600, in _run_script
    exec(code, module.__dict__)
File "C:\Users\ydebray\Downloads\gpt-programming-book\chap5\code_interpreter.py", line 115, in <module>
    st.chat_message('assistant',avatar=avatar['assistant']).write(line.content[0].text.value)
File "C:\Users\ydebray\Downloads\gpt-programming-book\env\lib\site-packages\pydantic\main.py", line 755, in __getattr__
    raise AttributeError(f'{type(self).__name__!r} object has no attribute {item!r}') from exc
[
  "Message(id='msg_KGjc0NInvSi38Y16DFSFTDoz', assistant_id='asst_5zjj3Cp5W2DOT6sRLeT6Cf23', attachments=[], completed_at=None, content=[ImageFileContentBlock(image_file=ImageFile(file_id='file-0dhn9eURNlHGJbNJkQvqr0wY'), type='image_file'), TextContentBlock(text=Text(annotations=[], value='Here is the plot of the function \\\\( \\\\frac{1}{\\\\sin(x)} \\\\). The plot shows the behavior of the function over the range of \\\\([-2\\\\pi, 2\\\\pi]\\\\).'), type='text')], created_at=1716945774, incomplete_at=None, incomplete_details=None, metadata={}, object='thread.message', role='assistant', run_id='run_qphSwg615K1aZG4ml6yBzcU8', status=None, thread_id='thread_TJIOSZyHsk6vu1rJ6DEsux6j')",
  "Message(id='msg_S8q6tSmXfzdqMWH5sntSyMv8', assistant_id=None, attachments=[], completed_at=None, content=[TextContentBlock(text=Text(annotations=[], value='plot function 1/sin(x)'), type='text')], created_at=1716945760, incomplete_at=None, incomplete_details=None, metadata={}, object='thread.message', role='user', run_id=None, status=None, thread_id='thread_TJIOSZyHsk6vu1rJ6DEsux6j')"
]
yanndebray commented 1 month ago

image

image

image