Add minimal controller endpoints for LLM chatbot (HTTP test first) 74/14874/6
authoralswp006 <alswp006@gmail.com>
Thu, 4 Sep 2025 15:24:38 +0000 (00:24 +0900)
committerMinje Kim <alswp006@gmail.com>
Mon, 15 Sep 2025 14:17:55 +0000 (14:17 +0000)
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 <alswp006@gmail.com>
trainingmgr/controller/agent_controller.py [new file with mode: 0644]
trainingmgr/trainingmgr_main.py

diff --git a/trainingmgr/controller/agent_controller.py b/trainingmgr/controller/agent_controller.py
new file mode 100644 (file)
index 0000000..d9b5fc1
--- /dev/null
@@ -0,0 +1,47 @@
+# ==================================================================================
+#
+#       Copyright (c) 2025 Minje Kim <alswp006@gmail.com> 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
index 4bf7736..0b1157b 100644 (file)
@@ -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