I uploaded a files to the assistant. The assistant works on Playground and got the right answer. when we tried the same question via API and it doesn’t find the right answer. Some time it works sometime it is not working
thread = client.beta.threads.create()
thread_message = client.beta.threads.messages.create(
thread_id=thread.id,
role="user",
content=userQuery
)
assistant_id ="Copied from Playground"
run = client.beta.threads.runs.create(
thread_id=thread.id,
assistant_id=assistant_id,
instructions=ass_instructions
)
run = client.beta.threads.runs.retrieve(
thread_id=thread.id,
run_id=run.id
)
while run.status in ['queued', 'in_progress']:
time.sleep(1) # Wait for 1 second
run = client.beta.threads.runs.retrieve(
thread_id=thread.id,
run_id=run.id
)
if run.status == 'completed':
messages = client.beta.threads.messages.list(
thread_id=thread.id,
)
messages = client.beta.threads.messages.list(
thread_id=thread.id)
for message in messages.data:
if message.role == "assistant":
output = message.content[0].text.value
elif run.status == 'cancelling':
return JsonResponse({'message': "error", 'response': "Error in assistants."})
else:
st = run.status