I am attaching an api to my webpage, it is supposed to be an AI that will help people find services, but the API does not remember any prior messages sent by the user. Also I wanted to use an assistant from the dashboard that I created but I am not sure how to deploy the assistant, cause the instructions I find are unclear.
from openai import OpenAI
from flask import Flask, request, jsonify, render_template
client = OpenAI(my API key)
app = Flask(__name__)
prompt = "my prompt"
@app.route('/')
def index():
return render_template('depthnav_trial.html')
@app.route('/', methods=['POST'])
def chat():
data = request.get_json()
message = data.get('message')
response = chat_client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "system", "content": prompt},
{"role": "user", "content": message}
],
max_tokens=50
)
return jsonify({'reply': response.choices[0].message.content.strip()})
if __name__ == '__main__':
app.run(port=5000, debug=True)