From 627fd002ae14b5c253c21576505d8cdaeae7d204 Mon Sep 17 00:00:00 2001 From: BUJIQI <145289312+BUJIQI@users.noreply.github.com> Date: Thu, 17 Apr 2025 17:17:09 +0800 Subject: [PATCH] Update utils.py (#7091) ### What problem does this PR solve? when there are multiple entities, the variable `v` may be a list, which will lead to this error: ``` | File "/mnt/d/wrf/ragflow/ragflow/graphrag/utils.py", line 59, in replace_all | result = result.replace(f"{{{k}}}", v) | TypeError: replace() argument 2 must be str, not list ``` this pr assign this `v` to be a str ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) - [ ] New Feature (non-breaking change which adds functionality) - [ ] Documentation Update - [ ] Refactoring - [ ] Performance Improvement - [ ] Other (please describe): --- graphrag/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphrag/utils.py b/graphrag/utils.py index 13e62ec04..20313e702 100644 --- a/graphrag/utils.py +++ b/graphrag/utils.py @@ -56,7 +56,7 @@ def perform_variable_replacements( def replace_all(input: str) -> str: result = input for k, v in variables.items(): - result = result.replace(f"{{{k}}}", v) + result = result.replace(f"{{{k}}}", str(v)) return result result = replace_all(result)