Open ide127 opened 7 months ago
To be honest, B# and Binary are the +
You're absolutely right in your observation! Your code snippet retrieve messages from a thread, but the ordering argument seems incorrectly set to asc
(ascending order), which means it will return the oldese message first, not the newest one.
I think the order
should be set to desc
(descending).
def get_newest_message(thread_id):
thread_messages = client.beta.threads.messages.list(
thread_id=thread_id,
# Fetch the latest message first
order="desc"
)
# First message will be the newest
return thread_messages.data[0]
While exploring code snippets of OpenAI Thread API, I've reached this code. In my amateur opinion, it seems forgot to add the ordering argument to ensure 'newest' message.