Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve ImportError for 'MessageContentText' Due to Typing Update in openai.types.beta.threads #12437

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
logan-markewich marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@

def from_openai_thread_message(thread_message: Any) -> ChatMessage:
"""From OpenAI thread message."""
from openai.types.beta.threads import MessageContentText, ThreadMessage
from openai.types.beta.threads import TextContentBlock, Message

thread_message = cast(ThreadMessage, thread_message)
thread_message = cast(Message, thread_message)

# we don't have a way of showing images, just do text for now
text_contents = [
t for t in thread_message.content if isinstance(t, MessageContentText)
t for t in thread_message.content if isinstance(t, TextContentBlock)
]
text_content_str = " ".join([t.text.value for t in text_contents])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ version = "0.2.0"
python = ">=3.8.1,<4.0"
llama-index-core = "^0.10.1"
llama-index-llms-openai = "^0.1.5"
openai = ">=1.14.0"

[tool.poetry.group.dev.dependencies]
ipython = "8.10.0"
Expand Down