|
@@ -18,17 +18,20 @@ nest_asyncio.apply()
|
|
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
|
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
|
# query: str = Field(..., description="query to look up in retrieval")
|
|
# query: str = Field(..., description="query to look up in retrieval")
|
|
class FileSearchToolInput(BaseModel):
|
|
class FileSearchToolInput(BaseModel):
|
|
- query: str = Field(..., description="要搜索的关键词或短语,支持精确匹配.")
|
|
|
|
|
|
+ query: str = Field(
|
|
|
|
+ ...,
|
|
|
|
+ description="The keyword or phrase to search for, supporting exact matches.",
|
|
|
|
+ )
|
|
|
|
|
|
|
|
|
|
class FileSearchTool(BaseTool):
|
|
class FileSearchTool(BaseTool):
|
|
name: str = "file_search"
|
|
name: str = "file_search"
|
|
description: str = (
|
|
description: str = (
|
|
- "当问题涉及以下情况时必须调用本工具:"
|
|
|
|
- + " - 询问文件/文档中的具体内容"
|
|
|
|
- + " - 需要查找数据、条款或技术细节"
|
|
|
|
- + ' - 用户明确要求"查文件"或"搜索资料"'
|
|
|
|
- "根据上面要求的关键词或短语检索指定需要文件中的内容,这里可以返回匹配的文本片段的内容"
|
|
|
|
|
|
+ "This tool must be called when the question involves the following situations:"
|
|
|
|
+ + " - Asking for specific content in files/documents"
|
|
|
|
+ + " - Need to find data, terms, or technical details"
|
|
|
|
+ + ' - The user explicitly requests "search files" or "search materials"'
|
|
|
|
+ "Retrieves content from specified files based on the keywords or phrases requested above, returning matching text snippets."
|
|
)
|
|
)
|
|
|
|
|
|
args_schema: Type[BaseModel] = FileSearchToolInput
|
|
args_schema: Type[BaseModel] = FileSearchToolInput
|
|
@@ -144,7 +147,7 @@ class FileSearchTool(BaseTool):
|
|
if (self.__keys and len(self.__keys) > 0) or (
|
|
if (self.__keys and len(self.__keys) > 0) or (
|
|
self.__dirkeys and len(self.__dirkeys) > 0
|
|
self.__dirkeys and len(self.__dirkeys) > 0
|
|
):
|
|
):
|
|
- return ""
|
|
|
|
|
|
+ return "## important:You can use the "retrieval" tool to search for relevant information."
|
|
else:
|
|
else:
|
|
return ""
|
|
return ""
|
|
|
|
|