Files
alighasami 3d5eaf9445
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

86 lines
2.1 KiB
TypeScript

import {
type IExecuteFunctions,
type INodeExecutionData,
type INodeProperties,
} from 'n8n-workflow';
import { outputSchemaField, parseJsonOutputField } from '../common/fields';
import { parseJsonIfPresent } from '../common/output.utils';
import { executeRequestWithSessionManagement } from '../common/session.utils';
export const description: INodeProperties[] = [
{
displayName: 'Prompt',
name: 'prompt',
type: 'string',
typeOptions: {
rows: 4,
},
required: true,
default: '',
placeholder: 'e.g. Is there a login form in this page?',
displayOptions: {
show: {
resource: ['extraction'],
operation: ['query'],
},
},
description: 'The prompt to query the page content',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: ['extraction'],
operation: ['query'],
},
},
options: [
{
...outputSchemaField,
},
{
...parseJsonOutputField,
},
{
displayName: 'Include Visual Analysis',
name: 'includeVisualAnalysis',
type: 'boolean',
default: false,
description: 'Whether to analyze the web page visually when fulfilling the request',
},
],
},
];
export async function execute(
this: IExecuteFunctions,
index: number,
): Promise<INodeExecutionData[]> {
const prompt = this.getNodeParameter('prompt', index, '') as string;
const additionalFields = this.getNodeParameter('additionalFields', index, {});
const outputSchema = additionalFields.outputSchema;
const includeVisualAnalysis = additionalFields.includeVisualAnalysis;
const result = await executeRequestWithSessionManagement.call(this, index, {
method: 'POST',
path: '/sessions/{sessionId}/windows/{windowId}/page-query',
body: {
prompt,
configuration: {
experimental: {
includeVisualAnalysis: includeVisualAnalysis ? 'enabled' : 'disabled',
},
...(outputSchema ? { outputSchema } : {}),
},
},
});
const nodeOutput = parseJsonIfPresent.call(this, index, result);
return this.helpers.returnJsonArray(nodeOutput);
}