Refactor: completion -> completions (#14584)

### What problem does this PR solve?

Keep only /completions, deprecated /completion

### Type of change

- [x] Refactoring
This commit is contained in:
Wang Qi
2026-05-06 17:19:22 +08:00
committed by GitHub
parent a190a6d67f
commit f32034e83e
10 changed files with 24 additions and 22 deletions

View File

@@ -403,14 +403,14 @@ async def deprecated_file_upload_info():
@add_tenant_id_to_kwargs
async 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)

View File

@@ -846,6 +846,7 @@ async def test_db_connection():
@manager.route("/agents/chat/completion", methods=["POST"]) # noqa: F821
@manager.route("/agents/chat/completions", methods=["POST"]) # noqa: F821
@login_required
@add_tenant_id_to_kwargs
async def agent_chat_completion(tenant_id, agent_id=None):

View File

@@ -174,6 +174,7 @@ def delete_search(search_id):
@manager.route("/searches/<search_id>/completion", methods=["POST"]) # noqa: F821
@manager.route("/searches/<search_id>/completions", methods=["POST"]) # noqa: F821
@login_required
@validate_request("question")
async def completion(search_id):

View File

@@ -160,7 +160,7 @@ class CanvasReplicaService:
@classmethod
def 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)