mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-08 07:12:38 +02:00
feat: rename similarity_search
This commit is contained in:
parent
42ae38a3df
commit
3d6286ca9a
4 changed files with 14 additions and 14 deletions
|
|
@ -35,7 +35,7 @@ class DataAnalyst(RoleZero):
|
|||
"DataAnalyst",
|
||||
"RoleZero",
|
||||
"Browser",
|
||||
"Editor:write,read,search_index_repo",
|
||||
"Editor:write,read,similarity_search",
|
||||
"SearchEnhancedQA",
|
||||
]
|
||||
custom_tools: list[str] = ["web scraping", "Terminal", "Editor:write,read,search_index_repo"]
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ class RoleZero(Role):
|
|||
"scroll_up",
|
||||
"search_dir",
|
||||
"search_file",
|
||||
"search_index_repo",
|
||||
"similarity_search",
|
||||
# "set_workdir",
|
||||
"write",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -936,25 +936,25 @@ class Editor(BaseModel):
|
|||
return path
|
||||
|
||||
@staticmethod
|
||||
async def search_index_repo(query: str, file_or_path: Union[str, Path]) -> List[str]:
|
||||
"""Searches the index repository for a given query across specified files or paths.
|
||||
async def similarity_search(query: str, file_or_path: Union[str, Path]) -> List[str]:
|
||||
"""Performs a similarity search for a given query across specified files or paths.
|
||||
|
||||
This method classifies the provided files or paths, performing a search on each cluster
|
||||
of files while handling other types of files separately. It merges results from structured
|
||||
indices with any results from non-indexed files.
|
||||
This method searches the index repository for the provided query, classifying the specified
|
||||
files or paths. It performs a search on each cluster of files and handles non-indexed files
|
||||
separately, merging results from structured indices with any direct results from non-indexed files.
|
||||
|
||||
Args:
|
||||
query (str): The search query string to look for in the indexed files.
|
||||
file_or_path (Union[str, Path]): A path or a filename to search within.
|
||||
file_or_path (Union[str, Path]): A path or filename to search within.
|
||||
|
||||
Returns:
|
||||
List[str]: A list of search results as strings, containing the text from the merged results
|
||||
and any direct results from other files.
|
||||
List[str]: A list of results as strings, containing the text from the merged results
|
||||
and any direct results from non-indexed files.
|
||||
|
||||
Example:
|
||||
>>> query = "The problem to be analyzed from the document"
|
||||
>>> file_or_path = "The document or folder you want to query"
|
||||
>>> texts: List[str] = await Editor.search_index_repo(query=query, file_or_path=file_or_path)
|
||||
>>> texts: List[str] = await Editor.similarity_search(query=query, file_or_path=file_or_path)
|
||||
>>> print(texts)
|
||||
"""
|
||||
return await IndexRepo.cross_repo_search(query=query, file_or_path=file_or_path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue