mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 12:32:30 +08:00
Feat: Add thought info to every component. (#9134)
### What problem does this PR solve? #9082 #6365 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,3 +1,18 @@
|
||||
#
|
||||
# Copyright 2025 The InfiniFlow Authors. All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
import os
|
||||
import importlib
|
||||
import inspect
|
||||
|
||||
@ -94,3 +94,9 @@ class ArXiv(ToolBase, ABC):
|
||||
return f"ArXiv error: {last_e}"
|
||||
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return """
|
||||
Keywords: {}
|
||||
Looking for the most relevant articles.
|
||||
""".format(self.get_input().get("query", "-_-!"))
|
||||
@ -165,3 +165,6 @@ class ToolBase(ComponentBase):
|
||||
})
|
||||
self._canvas.add_refernce(chunks, aggs)
|
||||
self.set_output("formalized_content", "\n".join(kb_prompt({"chunks": chunks, "doc_aggs": aggs}, 200000, True)))
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return self._canvas.get_component_name(self._id) + " is running..."
|
||||
@ -189,4 +189,5 @@ class CodeExec(ToolBase, ABC):
|
||||
def _encode_code(self, code: str) -> str:
|
||||
return base64.b64encode(code.encode("utf-8")).decode("utf-8")
|
||||
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return "Running a short script to process data."
|
||||
|
||||
@ -112,3 +112,9 @@ class DuckDuckGo(ToolBase, ABC):
|
||||
return f"DuckDuckGo error: {last_e}"
|
||||
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return """
|
||||
Keywords: {}
|
||||
Looking for the most relevant articles.
|
||||
""".format(self.get_input().get("query", "-_-!"))
|
||||
@ -204,4 +204,12 @@ class Email(ToolBase, ABC):
|
||||
self.set_output("_ERROR", str(last_e))
|
||||
return False
|
||||
|
||||
assert False, self.output()
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
inputs = self.get_input()
|
||||
return """
|
||||
To: {}
|
||||
Subject: {}
|
||||
Your email is on its way—sit tight!
|
||||
""".format(inputs.get("to_email", "-_-!"), inputs.get("subject", "-_-!"))
|
||||
@ -128,6 +128,5 @@ class ExeSQL(ToolBase, ABC):
|
||||
self.set_output("formalized_content", "\n\n".join(formalized_content))
|
||||
return self.output("formalized_content")
|
||||
|
||||
|
||||
def debug(self, **kwargs):
|
||||
return self._run([], **kwargs)
|
||||
def thoughts(self) -> str:
|
||||
return "Query sent—waiting for the data."
|
||||
@ -86,3 +86,6 @@ class GitHub(ToolBase, ABC):
|
||||
return f"GitHub error: {last_e}"
|
||||
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return "Scanning GitHub repos related to `{}`.".format(self.get_input().get("query", "-_-!"))
|
||||
@ -152,3 +152,8 @@ class Google(ToolBase, ABC):
|
||||
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return """
|
||||
Keywords: {}
|
||||
Looking for the most relevant articles.
|
||||
""".format(self.get_input().get("query", "-_-!"))
|
||||
@ -91,3 +91,6 @@ class GoogleScholar(ToolBase, ABC):
|
||||
return f"GoogleScholar error: {last_e}"
|
||||
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return "Looking for scholarly papers on `{}`,” prioritising reputable sources.".format(self.get_input().get("query", "-_-!"))
|
||||
@ -103,3 +103,6 @@ class PubMed(ToolBase, ABC):
|
||||
return f"PubMed error: {last_e}"
|
||||
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return "Looking for scholarly papers on `{}`,” prioritising reputable sources.".format(self.get_input().get("query", "-_-!"))
|
||||
@ -159,3 +159,9 @@ class Retrieval(ToolBase, ABC):
|
||||
form_cnt = "\n".join(kb_prompt(kbinfos, 200000, True))
|
||||
self.set_output("formalized_content", form_cnt)
|
||||
return form_cnt
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return """
|
||||
Keywords: {}
|
||||
Looking for the most relevant articles.
|
||||
""".format(self.get_input().get("query", "-_-!"))
|
||||
@ -134,6 +134,12 @@ class TavilySearch(ToolBase, ABC):
|
||||
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return """
|
||||
Keywords: {}
|
||||
Looking for the most relevant articles.
|
||||
""".format(self.get_input().get("query", "-_-!"))
|
||||
|
||||
|
||||
class TavilyExtractParam(ToolParamBase):
|
||||
"""
|
||||
@ -216,3 +222,6 @@ class TavilyExtract(ToolBase, ABC):
|
||||
return f"Tavily error: {last_e}"
|
||||
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return "Opened {}—pulling out the main text…".format(self.get_input().get("urls", "-_-!"))
|
||||
@ -109,3 +109,6 @@ class WenCai(ToolBase, ABC):
|
||||
return f"WenCai error: {last_e}"
|
||||
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return "Pulling live financial data for `{}`.".format(self.get_input().get("query", "-_-!"))
|
||||
@ -96,3 +96,9 @@ class Wikipedia(ToolBase, ABC):
|
||||
return f"Wikipedia error: {last_e}"
|
||||
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return """
|
||||
Keywords: {}
|
||||
Looking for the most relevant articles.
|
||||
""".format(self.get_input().get("query", "-_-!"))
|
||||
@ -109,3 +109,6 @@ class YahooFinance(ToolBase, ABC):
|
||||
return f"YahooFinance error: {last_e}"
|
||||
|
||||
assert False, self.output()
|
||||
|
||||
def thoughts(self) -> str:
|
||||
return "Pulling live financial data for `{}`.".format(self.get_input().get("stock_code", "-_-!"))
|
||||
Reference in New Issue
Block a user