mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-20 15:09:17 +08:00
feat: add request_params field to jina_reader tool (#5610)
This commit is contained in:
parent
cbbe28f40d
commit
6610b4cee5
@ -1,3 +1,4 @@
|
||||
import json
|
||||
from typing import Any, Union
|
||||
|
||||
from yarl import URL
|
||||
@ -26,6 +27,15 @@ class JinaReaderTool(BuiltinTool):
|
||||
if 'api_key' in self.runtime.credentials and self.runtime.credentials.get('api_key'):
|
||||
headers['Authorization'] = "Bearer " + self.runtime.credentials.get('api_key')
|
||||
|
||||
request_params = tool_parameters.get('request_params')
|
||||
if request_params is not None and request_params != '':
|
||||
try:
|
||||
request_params = json.loads(request_params)
|
||||
if not isinstance(request_params, dict):
|
||||
raise ValueError("request_params must be a JSON object")
|
||||
except (json.JSONDecodeError, ValueError) as e:
|
||||
raise ValueError(f"Invalid request_params: {e}")
|
||||
|
||||
target_selector = tool_parameters.get('target_selector')
|
||||
if target_selector is not None and target_selector != '':
|
||||
headers['X-Target-Selector'] = target_selector
|
||||
@ -53,7 +63,8 @@ class JinaReaderTool(BuiltinTool):
|
||||
response = ssrf_proxy.get(
|
||||
str(URL(self._jina_reader_endpoint + url)),
|
||||
headers=headers,
|
||||
timeout=(10, 60)
|
||||
params=request_params,
|
||||
timeout=(10, 60),
|
||||
)
|
||||
|
||||
if tool_parameters.get('summary', False):
|
||||
|
@ -25,6 +25,22 @@ parameters:
|
||||
pt_BR: used for linking to webpages
|
||||
llm_description: url for scraping
|
||||
form: llm
|
||||
- name: request_params
|
||||
type: string
|
||||
required: false
|
||||
label:
|
||||
en_US: Request params
|
||||
zh_Hans: 请求参数
|
||||
pt_BR: Request params
|
||||
human_description:
|
||||
en_US: |
|
||||
request parameters, format: {"key1": "value1", "key2": "value2"}
|
||||
zh_Hans: |
|
||||
请求参数,格式:{"key1": "value1", "key2": "value2"}
|
||||
pt_BR: |
|
||||
request parameters, format: {"key1": "value1", "key2": "value2"}
|
||||
llm_description: request parameters
|
||||
form: llm
|
||||
- name: target_selector
|
||||
type: string
|
||||
required: false
|
||||
|
Loading…
x
Reference in New Issue
Block a user