Files

44 lines
1.2 KiB
Python
Raw Permalink Normal View History

2025-12-29 03:06:49 +08:00
"""
AI chat API routes (optional).
Currently kept as a minimal compatibility layer for legacy frontend calls.
"""
from flask import Blueprint, jsonify, request
2025-12-29 03:06:49 +08:00
from app.utils.logger import get_logger
logger = get_logger(__name__)
ai_chat_bp = Blueprint("ai_chat", __name__)
2025-12-29 03:06:49 +08:00
@ai_chat_bp.route("/chat/message", methods=["POST"])
2025-12-29 03:06:49 +08:00
def chat_message():
"""
Minimal placeholder for legacy chat.
Return a friendly message instead of 404, so the UI can evolve gradually.
"""
data = request.get_json() or {}
msg = (data.get("message") or "").strip()
2025-12-29 03:06:49 +08:00
if not msg:
return jsonify({"code": 0, "msg": "Missing message", "data": None}), 400
return jsonify(
{
"code": 1,
"msg": "success",
"data": {"reply": "Chat API is not implemented yet in local-only mode.", "echo": msg},
2025-12-29 03:06:49 +08:00
}
)
2025-12-29 03:06:49 +08:00
@ai_chat_bp.route("/chat/history", methods=["GET"])
2025-12-29 03:06:49 +08:00
def get_chat_history():
"""Return empty history (compatibility stub)."""
return jsonify({"code": 1, "msg": "success", "data": []})
2025-12-29 03:06:49 +08:00
@ai_chat_bp.route("/chat/history/save", methods=["POST"])
2025-12-29 03:06:49 +08:00
def save_chat_history():
"""No-op save (compatibility stub)."""
return jsonify({"code": 1, "msg": "success", "data": None})