RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Refactor: completion -> completions (#14584)
Wang Qif32034e83e2a
diff --git a/admin/client/ragflow_client.py b/admin/client/ragflow_client.pyindex 084057bf81..148af4b45f 100644--- a/admin/client/ragflow_client.py+++ b/admin/client/ragflow_client.py@@ -1215,12 +1215,12 @@ class RAGFlowClient:# Prepare payload for completion API# Note: stream parameter is not sent, server defaults to stream=Truepayload = {- "conversation_id": session_id,+ "session_id": session_id,"messages": [{"role": "user", "content": message}]}- response = self.http_client.request("POST", "/conversation/completion", json_body=payload,- use_api_base=False, auth_kind="web", stream=True)+ response = self.http_client.request("POST", "/chat/completions", json_body=payload,+ use_api_base=True, auth_kind="web", stream=True)if response.status_code != 200:print(f"Fail to chat on session, status code: {response.status_code}")diff --git a/api/apps/backward_compat.py b/api/apps/backward_compat.pyindex 63739d8057..6c2b4ee126 100644--- a/api/apps/backward_compat.py+++ b/api/apps/backward_compat.py@@ -403,14 +403,14 @@ async def deprecated_file_upload_info():@add_tenant_id_to_kwargsasync def deprecated_agent_completions(agent_id, tenant_id=None):"""- Deprecated: Use POST /api/v1/agents/chat/completion instead.+ Deprecated: Use POST /api/v1/agents/chat/completions instead.Old path: POST /api/v1/agents/{agent_id}/completions- New path: POST /api/v1/agents/chat/completion+ New path: POST /api/v1/agents/chat/completions"""logging.warning("API endpoint /api/v1/agents/%s/completions is deprecated. "- "Please use /api/v1/agents/chat/completion instead.",+ "Please use /api/v1/agents/chat/completions instead.",agent_id,)return await agent_api.agent_chat_completion(tenant_id=tenant_id, agent_id=agent_id)diff --git a/api/apps/restful_apis/agent_api.py b/api/apps/restful_apis/agent_api.pyindex 35e577f32d..ffe8e805e0 100644--- a/api/apps/restful_apis/agent_api.py+++ b/api/apps/restful_apis/agent_api.py@@ -846,6 +846,7 @@ async def test_db_connection():@manager.route("/agents/chat/completion", methods=["POST"]) # noqa: F821[email protected]("/agents/chat/completions", methods=["POST"]) # noqa: F821@login_required@add_tenant_id_to_kwargsasync def agent_chat_completion(tenant_id, agent_id=None):diff --git a/api/apps/restful_apis/search_api.py b/api/apps/restful_apis/search_api.pyindex dfd3e7ed65..c56d0ff834 100644--- a/api/apps/restful_apis/search_api.py+++ b/api/apps/restful_apis/search_api.py@@ -174,6 +174,7 @@ def delete_search(search_id):@manager.route("/searches/<search_id>/completion", methods=["POST"]) # noqa: F821[email protected]("/searches/<search_id>/completions", methods=["POST"]) # noqa: F821@login_required@validate_request("question")async def completion(search_id):diff --git a/api/apps/services/canvas_replica_service.py b/api/apps/services/canvas_replica_service.pyindex a2aa56b6f9..17b6c99cb0 100644--- a/api/apps/services/canvas_replica_service.py+++ b/api/apps/services/canvas_replica_service.py@@ -160,7 +160,7 @@ class CanvasReplicaService:@classmethoddef load_for_run(cls, canvas_id: str, tenant_id: str, runtime_user_id: str):- """Load current runtime replica used by /completion."""+ """Load current runtime replica used by /completions."""replica_key = cls._replica_key(canvas_id, str(tenant_id), str(runtime_user_id))return cls._read_payload(replica_key)diff --git a/docs/references/http_api_reference.md b/docs/references/http_api_reference.mdindex 5390f1a7e5..8c2eba3a43 100644--- a/docs/references/http_api_reference.md+++ b/docs/references/http_api_reference.md@@ -4487,13 +4487,13 @@ Asks a specified agent a question to start an AI-powered conversation.Uses a single completion endpoint for all agent conversations.:::caution DEPRECATED-The previous endpoint `POST /api/v1/agents/{agent_id}/completions` is deprecated. Please use `POST /api/v1/agents/chat/completion` instead.+The API is deprecated. Please use `POST /api/v1/agents/chat/completions` instead.:::#### Request- Method: POST-- URL: `/api/v1/agents/chat/completion`+- URL: `/api/v1/agents/chat/completions`- Headers:- `'content-Type: application/json'`- `'Authorization: Bearer <YOUR_API_KEY>'`@@ -4534,7 +4534,7 @@ If the **Begin** component does not take parameters:```bashcurl --request POST \- --url http://{address}/api/v1/agents/chat/completion \+ --url http://{address}/api/v1/agents/chat/completions \--header 'Content-Type: application/json' \--header 'Authorization: Bearer <YOUR_API_KEY>' \--data-binary '@@ -4549,7 +4549,7 @@ curl --request POST \```bashcurl --request POST \- --url http://{address}/api/v1/agents/chat/completion \+ --url http://{address}/api/v1/agents/chat/completions \--header 'Content-Type: application/json' \--header 'Authorization: Bearer <YOUR_API_KEY>' \--data-binary '@@ -4586,7 +4586,7 @@ To continue an existing session:```bashcurl --request POST \- --url http://{address}/api/v1/agents/chat/completion \+ --url http://{address}/api/v1/agents/chat/completions \--header 'Content-Type: application/json' \--header 'Authorization: Bearer <YOUR_API_KEY>' \--data-binary '@@ -4692,7 +4692,7 @@ Streaming request:```bashcurl --request POST \- --url http://{address}/api/v1/agents/chat/completion \+ --url http://{address}/api/v1/agents/chat/completions \--header 'Content-Type: application/json' \--header 'Authorization: Bearer <YOUR_API_KEY>' \--data-binary '@@ -4713,7 +4713,7 @@ Non-stream request with existing session:```bashcurl --request POST \- --url http://{address}/api/v1/agents/chat/completion \+ --url http://{address}/api/v1/agents/chat/completions \--header 'Content-Type: application/json' \--header 'Authorization: Bearer <YOUR_API_KEY>' \--data-binary '@@ -7806,14 +7806,14 @@ Failure:### Search completion-**POST** `/api/v1/searches/{search_id}/completion`+**POST** `/api/v1/searches/{search_id}/completions`Generates an answer using the saved search app configuration and returns the result as a Server-Sent Events stream.#### Request- Method: POST-- URL: `/api/v1/searches/{search_id}/completion`+- URL: `/api/v1/searches/{search_id}/completions`- Headers:- `'Content-Type: application/json'`- `'Authorization: Bearer <YOUR_LOGIN_TOKEN>'`@@ -7825,7 +7825,7 @@ Generates an answer using the saved search app configuration and returns the res```bashcurl --request POST \- --url http://{address}/api/v1/searches/{search_id}/completion \+ --url http://{address}/api/v1/searches/{search_id}/completions \--header 'Content-Type: application/json' \--header 'Authorization: Bearer <YOUR_LOGIN_TOKEN>' \--data '{diff --git a/sdk/python/ragflow_sdk/modules/session.py b/sdk/python/ragflow_sdk/modules/session.pyindex 8f7e95dd7e..f9c4799fd7 100644--- a/sdk/python/ragflow_sdk/modules/session.py+++ b/sdk/python/ragflow_sdk/modules/session.py@@ -116,7 +116,7 @@ class Session(Base):"openai-compatible": False,}json_data.update(kwargs)- res = self.post("/agents/chat/completion", json_data, stream=stream)+ res = self.post("/agents/chat/completions", json_data, stream=stream)return resdef update(self, update_message):diff --git a/test/testcases/test_http_api/common.py b/test/testcases/test_http_api/common.pyindex c79b8ebef1..1e90415579 100644--- a/test/testcases/test_http_api/common.py+++ b/test/testcases/test_http_api/common.py@@ -383,7 +383,7 @@ def delete_all_agent_sessions(auth, agent_id, *, page_size=1000):def agent_completions(auth, agent_id, payload=None):- url = f"{HOST_ADDRESS}{AGENT_API_URL}/chat/completion"+ url = f"{HOST_ADDRESS}{AGENT_API_URL}/chat/completions"body = {"agent_id": agent_id}if payload:body.update(payload)diff --git a/test/testcases/test_sdk_api/test_session_management/test_create_session_with_chat_assistant.py b/test/testcases/test_sdk_api/test_session_management/test_create_session_with_chat_assistant.pyindex 7ab43ffd1c..4969589119 100644--- a/test/testcases/test_sdk_api/test_session_management/test_create_session_with_chat_assistant.py+++ b/test/testcases/test_sdk_api/test_session_management/test_create_session_with_chat_assistant.py@@ -160,7 +160,7 @@ def test_session_module_streaming_and_helper_paths_unit(monkeypatch):assert calls[0][2]["session_id"] == "session-chat"assert calls[0][2]["temperature"] == 0.2assert calls[0][3] is True- assert calls[1][1] == "/agents/chat/completion"+ assert calls[1][1] == "/agents/chat/completions"assert calls[1][2]["agent_id"] == "agent-1"assert calls[1][2]["query"] == "hello agent"assert calls[1][2]["session_id"] == "session-agent"diff --git a/web/src/utils/api.ts b/web/src/utils/api.tsindex 4bb5857d0f..b1c2c3e6e1 100644--- a/web/src/utils/api.ts+++ b/web/src/utils/api.ts@@ -161,7 +161,7 @@ export default {completionUrl: `${restAPIv1}/chat/completions`,chatsTts: `${restAPIv1}/chat/audio/speech`,searchCompletion: (searchId: string) =>- `${restAPIv1}/searches/${searchId}/completion`,+ `${restAPIv1}/searches/${searchId}/completions`,chatsMindmap: `${restAPIv1}/chat/mindmap`,chatsRelatedQuestions: `${restAPIv1}/chat/recommendation`,@@ -192,7 +192,7 @@ export default {createAgent: `${restAPIv1}/agents`,updateAgent: (agentId: string) => `${restAPIv1}/agents/${agentId}`,deleteAgent: (agentId: string) => `${restAPIv1}/agents/${agentId}`,- agentChatCompletion: `${restAPIv1}/agents/chat/completion`,+ agentChatCompletion: `${restAPIv1}/agents/chat/completions`,resetAgent: (agentId: string) => `${restAPIv1}/agents/${agentId}/reset`,testDbConnect: `${restAPIv1}/agents/test_db_connection`,getInputElements: `${webAPI}/canvas/input_elements`,