import openai
client = openai.OpenAI()
openai.api_key = ‘sk-’
assistant = client.beta.assistants.create(
name = “Salesman”,
instructions = “You are a salesman that sells villas in bali.”,
tools = [{“type”: “code_interpreter”}],
model = “gpt-4-1106-preview”
)
thread = client.beta.threads.create()
Student asks question
message = client.beta.threads.messages.create(
thread_id = thread.id,
role = “user”,
content = “what is the biggest and most expensive villa in bali”
)
run = client.beta.threads.runs.create(
thread_id = thread.id,
assistant_id = assistant.id,
instructions = “Please address the user as Maxi.”
)
import time
time.sleep(20)
run_status = client.beta.threads.runs.retrieve(
thread_id = thread.id,
run_id = run.id
)
if run_status.status == ‘completed’:
messages = client.beta.threads.messages.list(
thread_id = thread.id
)
for msg in messages.data:
role = msg.role
content = msg.content[0].text.value
print(f"{role.capitalize()}: {content}")
I tried making the assistent in my code but i just get the openai.OpenAIError
how can i solve this?