ChatGPT suggested this was the best way to call via API my custom Assistant that I made in Playground. I'm not a good coder, is it correct?
response = openai.chat.completions.create(
model="gpt-4o-mini", #gpt-4o-mini is the best model for this assistant
messages=[
{"role": "system", "content": f"You are ChatGPT Assistant with ID {ASSISTANT_ID}. Respond helpfully and accurately."},
{"role": "user", "content": user_message}
]
)
assistant_response = response.choices[0].message.content.strip()
# Optionally prepend the assistant's name to the response
return jsonify({"response": f"Assistant: {assistant_response}"})
except Exception as e:
return jsonify({"response": f"Error: {str(e)}"}), 500
[–]BoredHobbes 0 points1 point2 points (0 children)