87f2845483
- Cleaned up whitespace and formatting in various files including http.py, language.py, logger.py, safe_exec.py, and SQL migration scripts. - Consolidated import statements and removed unnecessary blank lines. - Updated logging configuration for better clarity. - Enhanced the safe execution code with improved error handling and logging. - Removed commented-out code and unnecessary variables in backfill_zero_trades.py and other scripts. - Added a pyproject.toml for Ruff and Vulture configuration. - Introduced requirements-dev.txt for development dependencies. - Removed commented-out stock entries in init.sql for cleaner migration scripts.
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
"""
|
|
AI chat API routes (optional).
|
|
Currently kept as a minimal compatibility layer for legacy frontend calls.
|
|
"""
|
|
|
|
from flask import Blueprint, jsonify, request
|
|
|
|
from app.utils.logger import get_logger
|
|
|
|
logger = get_logger(__name__)
|
|
|
|
ai_chat_bp = Blueprint("ai_chat", __name__)
|
|
|
|
|
|
@ai_chat_bp.route("/chat/message", methods=["POST"])
|
|
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()
|
|
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},
|
|
}
|
|
)
|
|
|
|
|
|
@ai_chat_bp.route("/chat/history", methods=["GET"])
|
|
def get_chat_history():
|
|
"""Return empty history (compatibility stub)."""
|
|
return jsonify({"code": 1, "msg": "success", "data": []})
|
|
|
|
|
|
@ai_chat_bp.route("/chat/history/save", methods=["POST"])
|
|
def save_chat_history():
|
|
"""No-op save (compatibility stub)."""
|
|
return jsonify({"code": 1, "msg": "success", "data": None})
|