Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
Feature/add delete to service (#555)
crazywoola004b3caa43e1
diff --git a/api/app.py b/api/app.pyindex 1b67c0cbd2e..886b5350401 100644--- a/api/app.py+++ b/api/app.py@@ -149,6 +149,10 @@ def register_blueprints(app):from controllers.web import bp as web_bpfrom controllers.console import bp as console_app_bp+ CORS(service_api_bp,+ allow_headers=['Content-Type', 'Authorization', 'X-App-Code'],+ methods=['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS', 'PATCH']+ )app.register_blueprint(service_api_bp)CORS(web_bp,diff --git a/api/controllers/service_api/app/conversation.py b/api/controllers/service_api/app/conversation.pyindex d52eb3fea73..b58cd5a7873 100644--- a/api/controllers/service_api/app/conversation.py+++ b/api/controllers/service_api/app/conversation.py@@ -1,4 +1,5 @@# -*- coding:utf-8 -*-+from flask import requestfrom flask_restful import fields, marshal_with, reqparsefrom flask_restful.inputs import int_rangefrom werkzeug.exceptions import NotFound@@ -56,16 +57,14 @@ class ConversationDetailApi(AppApiResource):conversation_id = str(c_id)- parser = reqparse.RequestParser()- parser.add_argument('user', type=str, location='args')- args = parser.parse_args()+ user = request.get_json().get('user')- if end_user is None and args['user'] is not None:- end_user = create_or_update_end_user_for_user_id(app_model, args['user'])+ if end_user is None and user is not None:+ end_user = create_or_update_end_user_for_user_id(app_model, user)try:ConversationService.delete(app_model, conversation_id, end_user)- return {"result": "success"}, 204+ return {"result": "success"}except services.errors.conversation.ConversationNotExistsError:raise NotFound("Conversation Not Exists.")@@ -95,3 +94,4 @@ class ConversationRenameApi(AppApiResource):api.add_resource(ConversationRenameApi, '/conversations/<uuid:c_id>/name', endpoint='conversation_name')api.add_resource(ConversationApi, '/conversations')api.add_resource(ConversationApi, '/conversations/<uuid:c_id>', endpoint='conversation')+api.add_resource(ConversationDetailApi, '/conversations/<uuid:c_id>', endpoint='conversation_detail')diff --git a/web/app/components/develop/template/template_chat.en.mdx b/web/app/components/develop/template/template_chat.en.mdxindex b690815b112..7e6c6644491 100644--- a/web/app/components/develop/template/template_chat.en.mdx+++ b/web/app/components/develop/template/template_chat.en.mdx@@ -334,6 +334,53 @@ For versatile conversational apps using a Q&A format, call the chat-messages API</Row>+---++<Heading+ url='/conversations/{converation_id}'+ method='DELETE'+ title='Conversation deletion'+ name='#delete'+/>+<Row>+ <Col>+ Delete conversation.++ ### Request Body++ <Properties>+ <Property name='user' type='string' key='user'>+ The user identifier, defined by the developer, must ensure uniqueness within the app.+ </Property>+ </Properties>+ </Col>+ <Col sticky>++ <CodeGroup title="Request" tag="DELETE" label="/conversations/{converation_id}" targetCode={`curl --location --request DELETE '${props.appDetail.api_base_url}/conversations/{conversation_id}' \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{ \n "user": "abc-123"\n}'`}>++ ```bash {{ title: 'cURL' }}+ curl --location --request DELETE 'https://cloud.langgenius.dev/api/conversations/{convsation_id}' \+ --header 'Content-Type: application/json' \+ --header 'Accept: application/json' \+ --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \+ --data '{+ "user": "abc-123"+ }'+ ```++ </CodeGroup>++ <CodeGroup title="Response">+ ```json {{ title: 'Response' }}+ {+ "result": "success"+ }+ ```+ </CodeGroup>+ </Col>+</Row>++---<Headingdiff --git a/web/app/components/develop/template/template_chat.zh.mdx b/web/app/components/develop/template/template_chat.zh.mdxindex a6a611d64a4..3dc70a43a6d 100644--- a/web/app/components/develop/template/template_chat.zh.mdx+++ b/web/app/components/develop/template/template_chat.zh.mdx@@ -333,6 +333,52 @@ import { Row, Col, Properties, Property, Heading, SubProperty } from '../md.tsx'</Col></Row>+---++<Heading+ url='/conversations/{converation_id}'+ method='DELETE'+ title='删除会话'+ name='#delete'+/>+<Row>+ <Col>+ 删除会话。++ ### Request Body++ <Properties>+ <Property name='user' type='string' key='user'>+ 用户标识,由开发者定义规则,需保证用户标识在应用内唯一。+ </Property>+ </Properties>+ </Col>+ <Col sticky>++ <CodeGroup title="Request" tag="DELETE" label="/conversations/{converation_id}" targetCode={`curl --location --request DELETE '${props.appDetail.api_base_url}/conversations/{conversation_id}' \\\n--header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \\\n--header 'Content-Type: application/json' \\\n--data-raw '{ \n "user": "abc-123"\n}'`}>++ ```bash {{ title: 'cURL' }}+ curl --location --request DELETE 'https://cloud.langgenius.dev/api/conversations/{convsation_id}' \+ --header 'Content-Type: application/json' \+ --header 'Accept: application/json' \+ --header 'Authorization: Bearer ENTER-YOUR-SECRET-KEY' \+ --data '{+ "user": "abc-123"+ }'+ ```++ </CodeGroup>++ <CodeGroup title="Response">+ ```json {{ title: 'Response' }}+ {+ "result": "success"+ }+ ```+ </CodeGroup>+ </Col>+</Row>+---