|
@@ -19,15 +19,18 @@ nest_asyncio.apply()
|
|
|
|
|
|
class FileSearchToolInput(BaseModel):
|
|
|
# query: str = Field(..., description="query to look up in retrieval")
|
|
|
- query: str = Field(description="query to look up in retrieval.")
|
|
|
+ query: str = Field(description="要搜索的关键词或短语,支持精确匹配.")
|
|
|
|
|
|
|
|
|
class FileSearchTool(BaseTool):
|
|
|
name: str = "file_search"
|
|
|
description: str = (
|
|
|
+ "根据关键词或短语检索指定文件中的内容,返回匹配的文本片段的内容"
|
|
|
+ """
|
|
|
"A search engine optimized for comprehensive, accurate, and trusted results. "
|
|
|
"Useful for when you need to answer questions about current events. "
|
|
|
"Input should be a search query."
|
|
|
+ """
|
|
|
)
|
|
|
|
|
|
args_schema: Type[BaseModel] = FileSearchToolInput
|
|
@@ -143,12 +146,12 @@ class FileSearchTool(BaseTool):
|
|
|
if (self.__keys and len(self.__keys) > 0) or (
|
|
|
self.__dirkeys and len(self.__dirkeys) > 0
|
|
|
):
|
|
|
- return '## important:You can use the "retrieval or file_search" tool to search for relevant information.'
|
|
|
- """
|
|
|
+ # return '## important:You can use the "retrieval or file_search" tool to search for relevant information.'
|
|
|
+
|
|
|
return (
|
|
|
"## 工具使用规范"
|
|
|
+ "可调用工具:"
|
|
|
- + "- file_search:用于在文件库中搜索与问题相关的具体内容"
|
|
|
+ + "- file_search:根据关键词或短语检索指定文件中的内容,返回匹配的文本片段的内容"
|
|
|
+ "**调用规则**:"
|
|
|
+ "1. 当问题涉及以下情况时必须调用本工具:"
|
|
|
+ " - 询问文件/文档中的具体内容"
|
|
@@ -159,11 +162,11 @@ class FileSearchTool(BaseTool):
|
|
|
+ " {"
|
|
|
+ ' "action": "file_search",'
|
|
|
+ ' "action_input": {'
|
|
|
- + ' "query": "精炼后的搜索语句,需包含至少多个关键要素的一句话(用户问题的原始上下文)"'
|
|
|
+ + ' "query": "精炼后的要搜索的关键词或短语,支持精确匹配"'
|
|
|
+ " }"
|
|
|
+ " }"
|
|
|
)
|
|
|
- """
|
|
|
+
|
|
|
else:
|
|
|
return ""
|
|
|
# return '## important:You can use the "retrieval" tool to search for relevant information.\n If you are asking about the content of the files, please specify any keywords, topics, or context you are looking for to help retrieve the most relevant content.'
|