Ver código fonte

feat: add request_params field to jina_reader tool (#5610)

tags/0.6.13
Xiao Ley 1 ano atrás
pai
commit
6610b4cee5
Nenhuma conta vinculada ao e-mail do autor do commit

+ 12
- 1
api/core/tools/provider/builtin/jina/tools/jina_reader.py Ver arquivo

import json
from typing import Any, Union from typing import Any, Union


from yarl import URL from yarl import URL
if 'api_key' in self.runtime.credentials and self.runtime.credentials.get('api_key'): if 'api_key' in self.runtime.credentials and self.runtime.credentials.get('api_key'):
headers['Authorization'] = "Bearer " + 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') target_selector = tool_parameters.get('target_selector')
if target_selector is not None and target_selector != '': if target_selector is not None and target_selector != '':
headers['X-Target-Selector'] = target_selector headers['X-Target-Selector'] = target_selector
response = ssrf_proxy.get( response = ssrf_proxy.get(
str(URL(self._jina_reader_endpoint + url)), str(URL(self._jina_reader_endpoint + url)),
headers=headers, headers=headers,
timeout=(10, 60)
params=request_params,
timeout=(10, 60),
) )


if tool_parameters.get('summary', False): if tool_parameters.get('summary', False):

+ 16
- 0
api/core/tools/provider/builtin/jina/tools/jina_reader.yaml Ver arquivo

pt_BR: used for linking to webpages pt_BR: used for linking to webpages
llm_description: url for scraping llm_description: url for scraping
form: llm 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 - name: target_selector
type: string type: string
required: false required: false

Carregando…
Cancelar
Salvar