jack 1 month ago
parent
commit
2c6ae7daf3
1 changed files with 22 additions and 3 deletions
  1. 22 3
      app/core/tools/file_search_tool.py

+ 22 - 3
app/core/tools/file_search_tool.py

@@ -47,7 +47,7 @@ class FileSearchTool(BaseTool):
         self.__keys = []
         self.__keys = []
         self.__dirkeys = []
         self.__dirkeys = []
         self.loop = None
         self.loop = None
-
+'''
     def configure(self, session: Session, run: Run, **kwargs):
     def configure(self, session: Session, run: Run, **kwargs):
         # 获取当前事件循环
         # 获取当前事件循环
         # document_id = []
         # document_id = []
@@ -166,6 +166,25 @@ class FileSearchTool(BaseTool):
         return files
         return files
         """
         """
 
 
+    def instruction_supplement(self) -> str:
+        """
+        为 Retrieval 提供文件选择信息,用于 llm 调用抉择
+        """
+        # if len(self.__filenames) == 0:
+        #    return ""
+        # else:
+        filenames_info = [
+            f"({index}){filename}" for index, filename in enumerate(self.__filenames)
+        ]
+        return (
+            'You can use the "retrieval" tool to retrieve relevant context from the following attached files. '
+            + 'Each line represents a file in the format "(index)filename":\n'
+            + "\n".join(filenames_info)
+            + "\nMake sure to be extremely concise when using attached files. "
+        )
+
+
+
     def instruction_supplement(self) -> str:
     def instruction_supplement(self) -> str:
         """
         """
         为 Retrieval 提供文件选择信息,用于 llm 调用抉择
         为 Retrieval 提供文件选择信息,用于 llm 调用抉择
@@ -180,9 +199,9 @@ class FileSearchTool(BaseTool):
         return 'You can use the "retrieval" tool to search for relevant information. Please specify the keywords or context you are looking for to retrieve the most relevant content.'
         return 'You can use the "retrieval" tool to search for relevant information. Please specify the keywords or context you are looking for to retrieve the most relevant content.'
 
 
     #'You can use the "retrieval" to search for relevant information within the attached files. Please specify the keywords or context you are looking for to retrieve the most relevant content.'
     #'You can use the "retrieval" to search for relevant information within the attached files. Please specify the keywords or context you are looking for to retrieve the most relevant content.'
+'''
 
 
 
 
-'''
     def configure(self, session: Session, run: Run, **kwargs):
     def configure(self, session: Session, run: Run, **kwargs):
         # 获取当前事件循环
         # 获取当前事件循环
         document_id = []
         document_id = []
@@ -295,4 +314,4 @@ class FileSearchTool(BaseTool):
                 + "\n".join(filenames_info)
                 + "\n".join(filenames_info)
                 + "\nMake sure to be extremely concise when using attached files. "
                 + "\nMake sure to be extremely concise when using attached files. "
             )
             )
-'''
+