diff --git a/app/w/[id]/components/workflow-block/components/sub-block/components/checkbox-list.tsx b/app/w/[id]/components/workflow-block/components/sub-block/components/checkbox-list.tsx index 3514452f87..22ba6abcda 100644 --- a/app/w/[id]/components/workflow-block/components/sub-block/components/checkbox-list.tsx +++ b/app/w/[id]/components/workflow-block/components/sub-block/components/checkbox-list.tsx @@ -2,7 +2,6 @@ import { Label } from '@/components/ui/label' import { Checkbox } from '@/components/ui/checkbox' import { useSubBlockValue } from '../hooks/use-sub-block-value' import { cn } from '@/lib/utils' -import { useEffect } from 'react' interface CheckboxListProps { blockId: string @@ -19,38 +18,6 @@ export function CheckboxList({ options, layout, }: CheckboxListProps) { - const [value, setValue] = useSubBlockValue(blockId, subBlockId) - - // Initialize values with all options set to false by default - const values = (() => { - const defaultValues = options.reduce( - (acc, option) => ({ - ...acc, - [option.id]: false, - }), - {} - ) - - return { - ...defaultValues, - ...(typeof value === 'object' && value !== null ? value : {}), - } - })() as Record - - // Move initialization to useEffect - useEffect(() => { - if (value === null) { - setValue(values) - } - }, [value, setValue, values]) - - const handleCheckedChange = (id: string, checked: boolean) => { - setValue({ - ...values, - [id]: checked, - }) - } - return (
- {options.map((option) => ( -
- - handleCheckedChange(option.id, checked as boolean) - } - /> - -
- ))} + {options.map((option) => { + const [value, setValue] = useSubBlockValue(blockId, option.id) + return ( +
+ setValue(checked as boolean)} + /> + +
+ ) + })}
) } diff --git a/blocks/blocks/jina.ts b/blocks/blocks/jina.ts index 429205386e..88da96c8e2 100644 --- a/blocks/blocks/jina.ts +++ b/blocks/blocks/jina.ts @@ -9,7 +9,7 @@ export const JinaBlock: BlockConfig = { description: 'Convert website content into text', bgColor: '#333333', icon: JinaAIIcon, - category: 'tools', + category: 'tools' }, tools: { access: ['jina_readurl'] @@ -18,9 +18,9 @@ export const JinaBlock: BlockConfig = { inputs: { url: { type: 'string', required: true }, useReaderLMv2: { type: 'boolean', required: false }, - removeImages: { type: 'boolean', required: false }, gatherLinks: { type: 'boolean', required: false }, - jsonResponse: { type: 'boolean', required: false } + jsonResponse: { type: 'boolean', required: false }, + apiKey: { type: 'string', required: true } }, outputs: { response: { @@ -35,18 +35,17 @@ export const JinaBlock: BlockConfig = { title: 'URL', type: 'short-input', layout: 'full', - placeholder: 'Enter URL to read', + placeholder: 'Enter URL to extract content from' }, { id: 'options', title: 'Options', type: 'checkbox-list', - layout: 'half', + layout: 'full', options: [ - { label: 'Use ReaderLM v2', id: 'useReaderLMv2' }, - { label: 'Remove Images', id: 'removeImages' }, - { label: 'Gather Links', id: 'gatherLinks' }, - { label: 'JSON Response', id: 'jsonResponse' } + { id: 'useReaderLMv2', label: 'Use Reader LM v2' }, + { id: 'gatherLinks', label: 'Gather Links' }, + { id: 'jsonResponse', label: 'JSON Response' } ] }, { @@ -54,9 +53,9 @@ export const JinaBlock: BlockConfig = { title: 'API Key', type: 'short-input', layout: 'full', - placeholder: 'Enter API Key (optional)', + placeholder: 'Enter your Jina API key', password: true } - ], - }, + ] + } } diff --git a/tools/jina/reader.ts b/tools/jina/reader.ts index 6b65460490..a9d224256b 100644 --- a/tools/jina/reader.ts +++ b/tools/jina/reader.ts @@ -3,7 +3,6 @@ import { ToolConfig, ToolResponse } from '../types' export interface ReadUrlParams { url: string useReaderLMv2?: boolean - removeImages?: boolean gatherLinks?: boolean jsonResponse?: boolean apiKey?: string @@ -31,10 +30,6 @@ export const readUrlTool: ToolConfig = { type: 'boolean', description: 'Whether to use ReaderLM-v2 for better quality' }, - removeImages: { - type: 'boolean', - description: 'Whether to remove all images from the response' - }, gatherLinks: { type: 'boolean', description: 'Whether to gather all links at the end' @@ -51,21 +46,26 @@ export const readUrlTool: ToolConfig = { request: { url: (params: ReadUrlParams) => { - const baseUrl = `https://r.jina.ai/https://${params.url.replace(/^https?:\/\//, '')}` - const queryParams = new URLSearchParams() - - if (params.useReaderLMv2) queryParams.append('use_readerlm_v2', 'true') - if (params.removeImages) queryParams.append('remove_images', 'true') - if (params.gatherLinks) queryParams.append('gather_links', 'true') - if (params.jsonResponse) queryParams.append('json_response', 'true') - - return `${baseUrl}${queryParams.toString() ? '?' + queryParams.toString() : ''}` + return `https://r.jina.ai/https://${params.url.replace(/^https?:\/\//, '')}` }, method: 'GET', - headers: (params: ReadUrlParams) => ({ - 'Content-Type': 'application/json', - 'Authorization': `Bearer ${params.apiKey}` - }) + headers: (params: ReadUrlParams) => { + // Start with base headers + const headers: Record = { + 'Accept': params.jsonResponse ? 'application/json' : 'text/plain', + 'Authorization': `Bearer ${params.apiKey}` + } + + // Add conditional headers based on boolean values + if (params.useReaderLMv2 === true) { + headers['X-Respond-With'] = 'readerlm-v2' + } + if (params.gatherLinks === true) { + headers['X-With-Links-Summary'] = 'true' + } + + return headers + } }, transformResponse: async (response: Response) => {