jack 3 週間 前
コミット
acf0092b59
2 ファイル変更13 行追加5 行削除
  1. 11 3
      app/core/runner/thread_runner.py
  2. 2 2
      app/core/tools/file_search_tool.py

+ 11 - 3
app/core/runner/thread_runner.py

@@ -215,9 +215,17 @@ class ThreadRunner:
             self.event_handler.pub_run_step_created(new_run_step)
             self.event_handler.pub_run_step_in_progress(new_run_step)
 
-            internal_tool_calls = list(
-                filter(lambda _tool_calls: _tool_calls[0] is not None, tool_calls)
-            )
+            # internal_tool_calls = list(
+            #    filter(lambda _tool_calls: _tool_calls[0] is not None, tool_calls)
+            # )
+            seen = set()
+            internal_tool_calls = []
+            for _tool_call in tool_calls:
+                tool_obj = _tool_call[0]
+                if tool_obj is not None and tool_obj not in seen:
+                    seen.add(tool_obj)
+                    internal_tool_calls.append(_tool_call)
+
             external_tool_call_dict = [
                 tool_call_dict for tool, tool_call_dict in tool_calls if tool is None
             ]

+ 2 - 2
app/core/tools/file_search_tool.py

@@ -30,7 +30,7 @@ class FileSearchToolInput(BaseModel):
 
 class FileSearchTool(BaseTool):
     name: str = "file_search"
-    description: str = "根据用户输入的问题从文件中检索相关的内容."
+    description: str = "根据用户输入的问题从文件中检索相关的内容,且仅允许调用一次。"
 
     args_schema: Type[BaseModel] = FileSearchToolInput
 
@@ -145,7 +145,7 @@ class FileSearchTool(BaseTool):
         if (self.__keys and len(self.__keys) > 0) or (
             self.__dirkeys and len(self.__dirkeys) > 0
         ):
-            return ""  #'## Top Important: plase you can use the "file_search" tool to search for relevant. Summarize the content or keywords and provide them for "file_search" tool usage.'
+            return "## Top Important: Please use the 'file_search' tool to search for relevant content or keywords. Summarize the content or keywords and provide them for 'file_search' tool usage. Please ensure that the 'file_search' tool is used only once per request."
         else:
             return ""