mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-01 11:56:24 +02:00
feat: rename file_or_path -> path
This commit is contained in:
parent
a9ec57dbbb
commit
4ea8793e8a
2 changed files with 8 additions and 8 deletions
|
|
@ -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)
|
||||
|
||||
@staticmethod
|
||||
def is_large_file(content: str, mix_token_count: int = 0) -> bool:
|
||||
|
|
|
|||
|
|
@ -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 rsp
|
||||
|
||||
shutil.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 rsp
|
||||
|
||||
save_to.unlink(missing_ok=True)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue