|
@@ -14,6 +14,7 @@ import nest_asyncio
|
|
|
# 使得异步代码可以在已运行的事件循环中嵌套
|
|
|
nest_asyncio.apply()
|
|
|
|
|
|
+
|
|
|
# asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
|
|
# query: str = Field(..., description="query to look up in retrieval")
|
|
|
class FileSearchToolInput(BaseModel):
|
|
@@ -22,9 +23,7 @@ class FileSearchToolInput(BaseModel):
|
|
|
|
|
|
class FileSearchTool(BaseTool):
|
|
|
name: str = "file_search"
|
|
|
- description: str = (
|
|
|
- "根据关键词或短语检索指定文件中的内容,返回匹配的文本片段的内容"
|
|
|
- )
|
|
|
+ description: str = "根据关键词或短语检索指定文件中的内容,返回匹配的文本片段的内容"
|
|
|
|
|
|
args_schema: Type[BaseModel] = FileSearchToolInput
|
|
|
|
|
@@ -140,26 +139,6 @@ class FileSearchTool(BaseTool):
|
|
|
self.__dirkeys and len(self.__dirkeys) > 0
|
|
|
):
|
|
|
return '## important:You can use the "retrieval or file_search" tool to search for relevant information.'
|
|
|
-'''
|
|
|
- return (
|
|
|
- "## 工具使用规范"
|
|
|
- + "可调用工具:"
|
|
|
- + "- file_search:根据关键词或短语检索指定文件中的内容,返回匹配的文本片段的内容"
|
|
|
- + "**调用规则**:"
|
|
|
- + "1. 当问题涉及以下情况时必须调用本工具:"
|
|
|
- + " - 询问文件/文档中的具体内容"
|
|
|
- + " - 需要查找数据、条款或技术细节"
|
|
|
- + ' - 用户明确要求"查文件"或"搜索资料"'
|
|
|
- + "2. 调用时需遵循:"
|
|
|
- + " ```json"
|
|
|
- + " {"
|
|
|
- + ' "action": "file_search",'
|
|
|
- + ' "action_input": {'
|
|
|
- + ' "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.'
|