|
@@ -10,10 +10,10 @@ from core.tools.tool.builtin_tool import BuiltinTool
|
|
|
class JinaReaderTool(BuiltinTool):
|
|
|
_jina_reader_endpoint = 'https://r.jina.ai/'
|
|
|
|
|
|
- def _invoke(self,
|
|
|
+ def _invoke(self,
|
|
|
user_id: str,
|
|
|
- tool_parameters: dict[str, Any],
|
|
|
- ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
|
|
+ tool_parameters: dict[str, Any],
|
|
|
+ ) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
|
|
|
"""
|
|
|
invoke tools
|
|
|
"""
|
|
@@ -34,6 +34,15 @@ class JinaReaderTool(BuiltinTool):
|
|
|
if wait_for_selector is not None and wait_for_selector != '':
|
|
|
headers['X-Wait-For-Selector'] = wait_for_selector
|
|
|
|
|
|
+ if tool_parameters.get('image_caption', False):
|
|
|
+ headers['X-With-Generated-Alt'] = 'true'
|
|
|
+
|
|
|
+ if tool_parameters.get('gather_all_links_at_the_end', False):
|
|
|
+ headers['X-With-Links-Summary'] = 'true'
|
|
|
+
|
|
|
+ if tool_parameters.get('gather_all_images_at_the_end', False):
|
|
|
+ headers['X-With-Images-Summary'] = 'true'
|
|
|
+
|
|
|
proxy_server = tool_parameters.get('proxy_server', None)
|
|
|
if proxy_server is not None and proxy_server != '':
|
|
|
headers['X-Proxy-Url'] = proxy_server
|
|
@@ -42,12 +51,12 @@ class JinaReaderTool(BuiltinTool):
|
|
|
headers['X-No-Cache'] = 'true'
|
|
|
|
|
|
response = ssrf_proxy.get(
|
|
|
- str(URL(self._jina_reader_endpoint + url)),
|
|
|
+ str(URL(self._jina_reader_endpoint + url)),
|
|
|
headers=headers,
|
|
|
timeout=(10, 60)
|
|
|
)
|
|
|
|
|
|
if tool_parameters.get('summary', False):
|
|
|
return self.create_text_message(self.summary(user_id, response.text))
|
|
|
-
|
|
|
+
|
|
|
return self.create_text_message(response.text)
|