From dc4d4342cdbbcbbdda6b9b5a3256ba1c7469d716 Mon Sep 17 00:00:00 2001 From: dek Date: Mon, 10 Mar 2025 03:28:15 +0100 Subject: [PATCH] Fix: broken /api/v1/chats endpoint (#5785) ### What problem does this PR solve? The `/api/v1/chats` API endpoint was broken, any GET request got the following response: ``` {"code":100,"data":null,"message":"TypeError(\"'int' object is not callable\")"} ``` With this log ragflow-server side: ``` 2025-03-07 14:36:26,297 ERROR 20 'int' object is not callable Traceback (most recent call last): File "/ragflow/.venv/lib/python3.10/site-packages/flask/app.py", line 880, in full_dispatch_request rv = self.dispatch_request() File "/ragflow/.venv/lib/python3.10/site-packages/flask/app.py", line 865, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return] File "/ragflow/api/utils/api_utils.py", line 303, in decorated_function return func(*args, **kwargs) File "/ragflow/api/apps/sdk/chat.py", line 323, in list_chat logging.WARN(f"Don't exist the kb {kb_id}") TypeError: 'int' object is not callable 2025-03-07 14:36:26,298 INFO 20 172.18.0.6 - - [07/Mar/2025 14:36:26] "GET /api/v1/chats HTTP/1.1" 200 - ``` This was caused by the incorrect use of `logging.WARN` as a method (it's a loglevel object), instead of the correct `logging.warning()` method. This PR fixes that, and also rewrites the message to be grammaticaly correct. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/apps/sdk/chat.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/apps/sdk/chat.py b/api/apps/sdk/chat.py index da6fcc51d..bfeba2b0f 100644 --- a/api/apps/sdk/chat.py +++ b/api/apps/sdk/chat.py @@ -318,7 +318,7 @@ def list_chat(tenant_id): for kb_id in res["kb_ids"]: kb = KnowledgebaseService.query(id=kb_id) if not kb: - logging.WARN(f"Don't exist the kb {kb_id}") + logging.warning(f"The kb {kb_id} does not exist.") continue kb_list.append(kb[0].to_json()) del res["kb_ids"]