mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-07-31 21:42:02 +08:00
Feat: Retrieval
supports internet search. (#5974)
### What problem does this PR solve? #5973 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
parent
46bdfb9661
commit
dd8779b257
@ -24,6 +24,7 @@ from api.db.services.llm_service import LLMBundle
|
|||||||
from api import settings
|
from api import settings
|
||||||
from agent.component.base import ComponentBase, ComponentParamBase
|
from agent.component.base import ComponentBase, ComponentParamBase
|
||||||
from rag.app.tag import label_question
|
from rag.app.tag import label_question
|
||||||
|
from rag.utils.tavily_conn import Tavily
|
||||||
|
|
||||||
|
|
||||||
class RetrievalParam(ComponentParamBase):
|
class RetrievalParam(ComponentParamBase):
|
||||||
@ -40,6 +41,7 @@ class RetrievalParam(ComponentParamBase):
|
|||||||
self.kb_ids = []
|
self.kb_ids = []
|
||||||
self.rerank_id = ""
|
self.rerank_id = ""
|
||||||
self.empty_response = ""
|
self.empty_response = ""
|
||||||
|
self.tavily_api_key = ""
|
||||||
|
|
||||||
def check(self):
|
def check(self):
|
||||||
self.check_decimal_float(self.similarity_threshold, "[Retrieval] Similarity threshold")
|
self.check_decimal_float(self.similarity_threshold, "[Retrieval] Similarity threshold")
|
||||||
@ -75,6 +77,11 @@ class Retrieval(ComponentBase, ABC):
|
|||||||
self._param.similarity_threshold, 1 - self._param.keywords_similarity_weight,
|
self._param.similarity_threshold, 1 - self._param.keywords_similarity_weight,
|
||||||
aggs=False, rerank_mdl=rerank_mdl,
|
aggs=False, rerank_mdl=rerank_mdl,
|
||||||
rank_feature=label_question(query, kbs))
|
rank_feature=label_question(query, kbs))
|
||||||
|
if self._param.tavily_api_key:
|
||||||
|
tav = Tavily(self._param.tavily_api_key)
|
||||||
|
tav_res = tav.retrieve_chunks(query)
|
||||||
|
kbinfos["chunks"].extend(tav_res["chunks"])
|
||||||
|
kbinfos["doc_aggs"].extend(tav_res["doc_aggs"])
|
||||||
|
|
||||||
if not kbinfos["chunks"]:
|
if not kbinfos["chunks"]:
|
||||||
df = Retrieval.be_output("")
|
df = Retrieval.be_output("")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user