From 342d63764d35d647f9e344309b74f540eef4f499 Mon Sep 17 00:00:00 2001 From: alswp006 Date: Fri, 5 Sep 2025 00:24:38 +0900 Subject: [PATCH] Add minimal controller endpoints for LLM chatbot (HTTP test first) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit As part of building the LLM chatbot, I’m adding minimal controller methods first to enable frontend ↔ backend HTTP tests. This change only exposes simple endpoints (e.g., GET /experiment/agent/modelInfo, POST /experiment/agent/generate-content) with basic validation and mock responses—no service/DB/LLM integration yet. We’ll iterate and harden the logic in follow-up tasks. - Unblock frontend integration and smoke testing - Defer business logic to later PRs Issue-ID:AIMLFW-235 Change-Id: I5a142ab8cedc70b0cf6eb37fafd59b9250882046 Signed-off-by: alswp006 --- trainingmgr/controller/agent_controller.py | 47 ++++++++++++++++++++++++++++++ trainingmgr/trainingmgr_main.py | 2 ++ 2 files changed, 49 insertions(+) create mode 100644 trainingmgr/controller/agent_controller.py diff --git a/trainingmgr/controller/agent_controller.py b/trainingmgr/controller/agent_controller.py new file mode 100644 index 0000000..d9b5fc1 --- /dev/null +++ b/trainingmgr/controller/agent_controller.py @@ -0,0 +1,47 @@ +# ================================================================================== +# +# Copyright (c) 2025 Minje Kim All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ================================================================================== +from flask import Blueprint, request, jsonify + +agent_controller = Blueprint("agent_controller", __name__) + +@agent_controller.route("/modelInfo", methods=["GET"]) +def model_info(): + return jsonify({ + "llm": { + "model": "" + } + }), 200 + +@agent_controller.route("/generate-content", methods=["POST"]) +def generate_content(): + body = request.get_json(silent=True) or {} + text = body.get("text") + if not isinstance(text, str) or not text.strip(): + return jsonify({ + "title": "Bad Request", + "status": 400, + "detail": "The 'text' field is required and must be a non-empty string." + }), 400 + dry_run = bool(body.get("dry_run", True)) + return jsonify({ + "action": "noop", + "request": {"text": text, "dry_run": dry_run}, + "response": {"note": "Received successfully"}, + "status": "ok", + "error_message": None + }), 200 \ No newline at end of file diff --git a/trainingmgr/trainingmgr_main.py b/trainingmgr/trainingmgr_main.py index 4bf7736..0b1157b 100644 --- a/trainingmgr/trainingmgr_main.py +++ b/trainingmgr/trainingmgr_main.py @@ -41,6 +41,7 @@ from trainingmgr.schemas import TrainingJobSchema , FeatureGroupSchema from trainingmgr.db.featuregroup_db import get_feature_group_by_name_db, delete_feature_group_by_name from trainingmgr.controller import featuregroup_controller, training_job_controller from trainingmgr.controller.pipeline_controller import pipeline_controller +from trainingmgr.controller.agent_controller import agent_controller from trainingmgr.common.trainingConfig_parser import getField from trainingmgr.handler.async_handler import start_async_handler from trainingmgr.service.mme_service import get_modelinfo_by_modelId_service @@ -52,6 +53,7 @@ from middleware.loggingMiddleware import LoggingMiddleware APP.wsgi_app = LoggingMiddleware(APP.wsgi_app) APP.register_blueprint(featuregroup_controller, url_prefix='/ai-ml-model-training/v1') APP.register_blueprint(training_job_controller, url_prefix='/ai-ml-model-training/v1') +APP.register_blueprint(agent_controller, url_prefix="/experiment/agent") APP.register_blueprint(pipeline_controller) PS_DB_OBJ = None -- 2.16.6