feat: Jina Search & Jina Reader CSS selectors (#4523)
parent
e8e213ad1e
commit
6b5685ef0c
@ -0,0 +1,30 @@
|
||||
from typing import Any, Union
|
||||
|
||||
from yarl import URL
|
||||
|
||||
from core.helper import ssrf_proxy
|
||||
from core.tools.entities.tool_entities import ToolInvokeMessage
|
||||
from core.tools.tool.builtin_tool import BuiltinTool
|
||||
|
||||
|
||||
class JinaSearchTool(BuiltinTool):
|
||||
_jina_search_endpoint = 'https://s.jina.ai/'
|
||||
|
||||
def _invoke(
|
||||
self,
|
||||
user_id: str,
|
||||
tool_parameters: dict[str, Any],
|
||||
) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
||||
query = tool_parameters['query']
|
||||
|
||||
headers = {
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
|
||||
response = ssrf_proxy.get(
|
||||
str(URL(self._jina_search_endpoint + query)),
|
||||
headers=headers,
|
||||
timeout=(10, 60)
|
||||
)
|
||||
|
||||
return self.create_text_message(response.text)
|
||||
@ -0,0 +1,21 @@
|
||||
identity:
|
||||
name: jina_search
|
||||
author: Dify
|
||||
label:
|
||||
en_US: JinaSearch
|
||||
zh_Hans: JinaSearch
|
||||
pt_BR: JinaSearch
|
||||
description:
|
||||
human:
|
||||
en_US: Search on the web and get the top 5 results. Useful for grounding using information from the web.
|
||||
llm: A tool for searching results on the web for grounding. Input should be a simple question.
|
||||
parameters:
|
||||
- name: query
|
||||
type: string
|
||||
required: true
|
||||
label:
|
||||
en_US: Question (Query)
|
||||
human_description:
|
||||
en_US: used to find information on the web
|
||||
llm_description: simple question to ask on the web
|
||||
form: llm
|
||||
Loading…
Reference in New Issue