🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming
feat: rename file_or_path -> path
莘权 马4ea8793e8a5f
diff --git a/metagpt/tools/libs/editor.py b/metagpt/tools/libs/editor.pyindex 225697a60..a054d3773 100644--- a/metagpt/tools/libs/editor.py+++ b/metagpt/tools/libs/editor.py@@ -1096,7 +1096,7 @@ class Editor(BaseModel):return path@staticmethod- async def similarity_search(query: str, file_or_path: Union[str, Path]) -> List[str]:+ async def similarity_search(query: str, path: Union[str, Path]) -> List[str]:"""Given a filename or a pathname, performs a similarity search for a given query across the specified file or path.This method searches the index repository for the provided query, classifying the specified@@ -1106,7 +1106,7 @@ class Editor(BaseModel):Args:query (str): The search query string to look for in the indexed files.- file_or_path (Union[str, Path]): A pathname or filename to search within.+ path (Union[str, Path]): A pathname or filename to search within.Returns:List[str]: A list of results as strings, containing the text from the merged results@@ -1115,10 +1115,10 @@ class Editor(BaseModel):Example:>>> query = "The problem to be analyzed from the document">>> file_or_path = "The pathname or filename you want to search within"- >>> texts: List[str] = await Editor.similarity_search(query=query, file_or_path=file_or_path)+ >>> texts: List[str] = await Editor.similarity_search(query=query, path=file_or_path)>>> print(texts)"""- return await IndexRepo.cross_repo_search(query=query, file_or_path=file_or_path)+ return await IndexRepo.cross_repo_search(query=query, file_or_path=path)@staticmethoddef is_large_file(content: str, mix_token_count: int = 0) -> bool:diff --git a/tests/metagpt/tools/libs/test_editor.py b/tests/metagpt/tools/libs/test_editor.pyindex c6a45da06..f00dca554 100644--- a/tests/metagpt/tools/libs/test_editor.py+++ b/tests/metagpt/tools/libs/test_editor.py@@ -772,11 +772,11 @@ async def test_index_repo():chat_path, upload_path, src_path = await mock_index_repo()editor = Editor()- rsp = await editor.similarity_search(query="业务线", file_or_path=chat_path)+ rsp = await editor.similarity_search(query="业务线", path=chat_path)assert rsp- rsp = await editor.similarity_search(query="业务线", file_or_path=upload_path)+ rsp = await editor.similarity_search(query="业务线", path=upload_path)assert rsp- rsp = await editor.similarity_search(query="业务线", file_or_path=src_path)+ rsp = await editor.similarity_search(query="业务线", path=src_path)assert rspshutil.rmtree(CHATS_ROOT)@@ -811,7 +811,7 @@ async def test_similarity_search(query, filename):os.system(f"cp {str(filename)} {str(save_to)}")editor = Editor()- rsp = await editor.similarity_search(query=query, file_or_path=save_to)+ rsp = await editor.similarity_search(query=query, path=save_to)assert rspsave_to.unlink(missing_ok=True)