mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
feat: add apifyApiToken credentials v1
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
import { INodeParams, INodeCredential } from '../src/Interface'
|
||||||
|
|
||||||
|
class ApifyApi implements INodeCredential {
|
||||||
|
label: string
|
||||||
|
name: string
|
||||||
|
version: number
|
||||||
|
description: string
|
||||||
|
inputs: INodeParams[]
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.label = 'Apify API'
|
||||||
|
this.name = 'apifyApi'
|
||||||
|
this.version = 1.0
|
||||||
|
this.description =
|
||||||
|
'You can find the Apify API token on your <a target="_blank" href="https://my.apify.com/account#/integrations">Apify account</a> page.'
|
||||||
|
this.inputs = [
|
||||||
|
{
|
||||||
|
label: 'Apify API',
|
||||||
|
name: 'apifyApiToken',
|
||||||
|
type: 'password'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { credClass: ApifyApi }
|
||||||
+16
-8
@@ -1,4 +1,5 @@
|
|||||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
import { INode, INodeData, INodeParams, ICommonObject } from '../../../src/Interface'
|
||||||
|
import { getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
import { TextSplitter } from 'langchain/text_splitter'
|
import { TextSplitter } from 'langchain/text_splitter'
|
||||||
import { ApifyDatasetLoader } from 'langchain/document_loaders/web/apify_dataset'
|
import { ApifyDatasetLoader } from 'langchain/document_loaders/web/apify_dataset'
|
||||||
import { Document } from 'langchain/document'
|
import { Document } from 'langchain/document'
|
||||||
@@ -9,24 +10,22 @@ class ApifyWebsiteContentCrawler_DocumentLoaders implements INode {
|
|||||||
description: string
|
description: string
|
||||||
type: string
|
type: string
|
||||||
icon: string
|
icon: string
|
||||||
|
version: number
|
||||||
category: string
|
category: string
|
||||||
baseClasses: string[]
|
baseClasses: string[]
|
||||||
inputs: INodeParams[]
|
inputs: INodeParams[]
|
||||||
|
credential: INodeParams
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'Apify Website Content Crawler'
|
this.label = 'Apify Website Content Crawler'
|
||||||
this.name = 'apifyWebsiteContentCrawler'
|
this.name = 'apifyWebsiteContentCrawler'
|
||||||
this.type = 'Document'
|
this.type = 'Document'
|
||||||
this.icon = 'apify-symbol-transparent.svg'
|
this.icon = 'apify-symbol-transparent.svg'
|
||||||
|
this.version = 1.0
|
||||||
this.category = 'Document Loaders'
|
this.category = 'Document Loaders'
|
||||||
this.description = 'Load data from Apify Website Content Crawler'
|
this.description = 'Load data from Apify Website Content Crawler'
|
||||||
this.baseClasses = [this.type]
|
this.baseClasses = [this.type]
|
||||||
this.inputs = [
|
this.inputs = [
|
||||||
{
|
|
||||||
label: 'Apify API Token',
|
|
||||||
name: 'apifyApiToken',
|
|
||||||
type: 'password'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: 'Input',
|
label: 'Input',
|
||||||
name: 'input',
|
name: 'input',
|
||||||
@@ -43,13 +42,22 @@ class ApifyWebsiteContentCrawler_DocumentLoaders implements INode {
|
|||||||
optional: true
|
optional: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
this.credential = {
|
||||||
|
label: 'Connect Apify API',
|
||||||
|
name: 'credential',
|
||||||
|
type: 'credential',
|
||||||
|
credentialNames: ['apifyApi']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async init(nodeData: INodeData): Promise<any> {
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||||
const apifyApiToken = nodeData.inputs?.apifyApiToken as string
|
|
||||||
const input = typeof nodeData.inputs?.input === 'object' ? nodeData.inputs?.input : JSON.parse(nodeData.inputs?.input as string)
|
const input = typeof nodeData.inputs?.input === 'object' ? nodeData.inputs?.input : JSON.parse(nodeData.inputs?.input as string)
|
||||||
|
|
||||||
|
// Get Apify API token from credential data
|
||||||
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
|
const apifyApiToken = getCredentialParam('apifyApiToken', credentialData, nodeData)
|
||||||
|
|
||||||
const loader = await ApifyDatasetLoader.fromActorCall('apify/website-content-crawler', input, {
|
const loader = await ApifyDatasetLoader.fromActorCall('apify/website-content-crawler', input, {
|
||||||
datasetMappingFunction: (item) =>
|
datasetMappingFunction: (item) =>
|
||||||
new Document({
|
new Document({
|
||||||
|
|||||||
Reference in New Issue
Block a user