diff --git a/site/test_routes.py b/site/test_routes.py index a55c75c..97a2d56 100644 --- a/site/test_routes.py +++ b/site/test_routes.py @@ -16,6 +16,7 @@ import os from psycopg2 import sql as psysql from flask import Blueprint, jsonify, request import db +import llm_client test_bp = Blueprint("test", __name__) @@ -39,6 +40,7 @@ def test(): "POST /test createdb — создать БД (если нет)", "POST /test tables — список таблиц", "POST /test exec {...} — INSERT/UPDATE/DDL (без fetch)", + "POST /test llm {...} — тест LLM (промпт → ответ)", "POST /test sql {...} — SELECT (с fetch)", ], }) @@ -99,4 +101,14 @@ def test(): return jsonify({"error": err}), 500 return jsonify(result) + if action == "llm": + # Тест LLM: отправить промпт → получить ответ + prompt = data.get("prompt", "Скажи 'Привет, мир!'") + model = data.get("model") # None = default + max_tokens = data.get("max_tokens", 500) + result = llm_client.ask(prompt, model=model, max_tokens=max_tokens) + if "error" in result: + return jsonify(result), 500 + return jsonify(result) + return jsonify({"error": f"unknown action: {action}"}), 400