Access message from threads and assistant

I struggled to find it out and finally was able to do this in python as below. I will post the code shortly in github

run = openai.beta.threads.runs.create(
  thread_id=thread.id,
  assistant_id=assistant.id
)
print(run)


while run.status !="completed":
  run = openai.beta.threads.runs.retrieve(
    thread_id=thread.id,
    run_id=run.id
  )
  print(run.status)

messages = openai.beta.threads.messages.list(
  thread_id=thread.id
)

print(messages.data[0].content[0].text.value)
6 Likes