first commit
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
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
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as getPaginated from './getPaginated.operation';
|
||||
import * as query from './query.operation';
|
||||
import * as scrape from './scrape.operation';
|
||||
import { getSessionModeFields } from '../common/fields';
|
||||
|
||||
export { getPaginated, query, scrape };
|
||||
|
||||
export const description: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['extraction'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Query Page',
|
||||
value: 'query',
|
||||
description: 'Query a page to extract data or ask a question given the data on the page',
|
||||
action: 'Query page',
|
||||
},
|
||||
{
|
||||
name: 'Query Page with Pagination',
|
||||
value: 'getPaginated',
|
||||
description: 'Extract content from paginated or dynamically loaded pages',
|
||||
action: 'Query page with pagination',
|
||||
},
|
||||
{
|
||||
name: 'Smart Scrape',
|
||||
value: 'scrape',
|
||||
description: 'Scrape a page and return the data as markdown',
|
||||
action: 'Smart scrape page',
|
||||
},
|
||||
],
|
||||
default: 'getPaginated',
|
||||
},
|
||||
...getSessionModeFields('extraction', ['getPaginated', 'query', 'scrape']),
|
||||
...getPaginated.description,
|
||||
...query.description,
|
||||
];
|
||||
@@ -0,0 +1,125 @@
|
||||
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: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['extraction'],
|
||||
operation: ['getPaginated'],
|
||||
},
|
||||
},
|
||||
description: 'The prompt to extract data from the pages',
|
||||
placeholder: 'e.g. Extract all the product names and prices',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['extraction'],
|
||||
operation: ['getPaginated'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
...outputSchemaField,
|
||||
},
|
||||
{
|
||||
...parseJsonOutputField,
|
||||
},
|
||||
{
|
||||
displayName: 'Interaction Mode',
|
||||
name: 'interactionMode',
|
||||
type: 'options',
|
||||
default: 'auto',
|
||||
description: 'The strategy for interacting with the page',
|
||||
options: [
|
||||
{
|
||||
name: 'Auto',
|
||||
description: 'Automatically choose the most cost-effective mode',
|
||||
value: 'auto',
|
||||
},
|
||||
{
|
||||
name: 'Accurate',
|
||||
description: 'Prioritize accuracy over cost',
|
||||
value: 'accurate',
|
||||
},
|
||||
{
|
||||
name: 'Cost Efficient',
|
||||
description: 'Minimize costs while ensuring effectiveness',
|
||||
value: 'cost-efficient',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
displayName: 'Pagination Mode',
|
||||
name: 'paginationMode',
|
||||
type: 'options',
|
||||
default: 'auto',
|
||||
description: 'The pagination approach to use',
|
||||
options: [
|
||||
{
|
||||
name: 'Auto',
|
||||
description: 'Look for pagination links first, then try infinite scrolling',
|
||||
value: 'auto',
|
||||
},
|
||||
{
|
||||
name: 'Paginated',
|
||||
description: 'Only use pagination links',
|
||||
value: 'paginated',
|
||||
},
|
||||
{
|
||||
name: 'Infinite Scroll',
|
||||
description: 'Scroll the page to load more content',
|
||||
value: 'infinite-scroll',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
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 configFields = ['paginationMode', 'interactionMode', 'outputSchema'];
|
||||
const configuration = configFields.reduce(
|
||||
(config, key) => (additionalFields[key] ? { ...config, [key]: additionalFields[key] } : config),
|
||||
{},
|
||||
);
|
||||
|
||||
const result = await executeRequestWithSessionManagement.call(this, index, {
|
||||
method: 'POST',
|
||||
path: '/sessions/{sessionId}/windows/{windowId}/paginated-extraction',
|
||||
body: {
|
||||
prompt,
|
||||
configuration,
|
||||
},
|
||||
});
|
||||
|
||||
const nodeOutput = parseJsonIfPresent.call(this, index, result);
|
||||
return this.helpers.returnJsonArray(nodeOutput);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import type { IExecuteFunctions, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { executeRequestWithSessionManagement } from '../common/session.utils';
|
||||
|
||||
export async function execute(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const result = await executeRequestWithSessionManagement.call(this, index, {
|
||||
method: 'POST',
|
||||
path: '/sessions/{sessionId}/windows/{windowId}/scrape-content',
|
||||
body: {},
|
||||
});
|
||||
|
||||
return this.helpers.returnJsonArray({ ...result });
|
||||
}
|
||||
Reference in New Issue
Block a user