From fe8a5563bf774fecd128c3755132f8f7008f82b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CNaeel=E2=80=9D?= Date: Sun, 14 Jun 2026 07:00:50 +0400 Subject: [PATCH] =?UTF-8?q?feat(test):=20action=20'llm'=20=E2=80=94=20?= =?UTF-8?q?=D1=82=D0=B5=D1=81=D1=82=20LLM=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7?= =?UTF-8?q?=20/test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit POST /test {"action":"llm", "prompt":"...", "model":"...", "max_tokens":500} → вызывает llm_client.ask() → возвращает {text, model, usage} --- site/test_routes.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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