diff --git a/api/apps/canvas_app.py b/api/apps/canvas_app.py index acc173dde1..b1ea62a1bb 100644 --- a/api/apps/canvas_app.py +++ b/api/apps/canvas_app.py @@ -18,6 +18,8 @@ from flask import request, Response from flask_login import login_required, current_user from api.db.services.canvas_service import CanvasTemplateService, UserCanvasService +from api.db.services.dialog_service import full_question +from api.db.services.user_service import TenantService from api.settings import RetCode from api.utils import get_uuid from api.utils.api_utils import get_json_result, server_error_response, validate_request, get_data_error_result @@ -108,6 +110,9 @@ def run(): canvas = Canvas(cvs.dsl, current_user.id) if "message" in req: canvas.messages.append({"role": "user", "content": req["message"], "id": message_id}) + if len([m for m in canvas.messages if m["role"] == "user"]) > 1: + ten = TenantService.get_by_user_id(current_user.id)[0] + req["message"] = full_question(ten["tenant_id"], ten["llm_id"], canvas.messages) canvas.add_user_input(req["message"]) answer = canvas.run(stream=stream) print(canvas) diff --git a/api/apps/llm_app.py b/api/apps/llm_app.py index 4b229f4c5a..878c6a0bd7 100644 --- a/api/apps/llm_app.py +++ b/api/apps/llm_app.py @@ -287,7 +287,7 @@ def delete_llm(): @manager.route('/delete_factory', methods=['POST']) @login_required @validate_request("llm_factory") -def delete_llm(): +def delete_factory(): req = request.json TenantLLMService.filter_delete( [TenantLLM.tenant_id == current_user.id, TenantLLM.llm_factory == req["llm_factory"]])