An app about an ai devlopment tool for childs of class 6th to 8th

import openai
from flask import Flask, request, jsonify
import os

app = Flask(name)

Set up OpenAI API key (replace with your key)

openai.api_key = “your_openai_api_key”

@app.route(‘/ask’, methods=[‘POST’])
def ask_ai():
data = request.json
user_input = data.get(“question”, “”)

if not user_input:
    return jsonify({"error": "Question is required"}), 400

try:
    response = openai.Completion.create(
        engine="text-davinci-003",  # Choose a GPT engine
        prompt=user_input,
        max_tokens=150
    )
    answer = response.choices[0].text.strip()
    return jsonify({"answer": answer})
except Exception as e:
    return jsonify({"error": str(e)}), 500

if name == ‘main’:
app.run(debug=True)

Welcome. (last seen one minute after posting)

Just to note, the code in this topic is of no value, all obsolete methods.

Refer to the current API reference examples, not an AI to write for you.