Hello im pretty desperate…I’m trying to implement a chatbot based on chatgpt. Therefore I have looked up a script which should be working, accoriding to the sources - To get started with a first API call…But my request all get a failed run status… I tried several different python script e.q. this one here:
from openai import OpenAI
import time
client = OpenAI(api_key=“xxx”)
assistant = client.beta.assistants.create(
name=“Code Assistant”,
instructions=“You are a code helper for beginners. Write, execute, and explain code to best answer questions.”,
tools=[{“type”: “code_interpreter”}],
model=“gpt-3.5-turbo”
)
thread = client.beta.threads.create()
message = client.beta.threads.messages.create(
thread_id=thread.id,
role=“user”,
content=“How does recursion work? Give an example in Python.”
)
run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant.id,
instructions=“Explain as simply as possible, the user is a beginner.”
)
while True:
run_status = client.beta.threads.runs.retrieve(thread_id=thread.id,
run_id=run.id)
print(f"Run status: {run_status.status}")
if run_status.status == ‘completed’:
break
time.sleep(1) # Wait for a second before checking again
messages = client.beta.threads.messages.list(
thread_id=thread.id
)
assistant_response = messages.data[0].content[0].text.value
print(assistant_response)
Can you spot the problem?
Thank you in advance