Skip to content

Commit

Permalink
Fix ImportError caused by outdated "MessageContentText" and "ThreadMe…
Browse files Browse the repository at this point in the history
…ssage" import

Updated the import statement to align with the new update in "openai.types.beta.threads", resolving the ImportError that prevented successful library usage.
  • Loading branch information
MaHDiaLaGaB committed Mar 30, 2024
1 parent 9607a05 commit 7b5b0bd
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,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

0 comments on commit 7b5b0bd

Please sign in to comment.