mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 13:00:56 +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 { ApifyDatasetLoader } from 'langchain/document_loaders/web/apify_dataset'
|
||||
import { Document } from 'langchain/document'
|
||||
@@ -9,24 +10,22 @@ class ApifyWebsiteContentCrawler_DocumentLoaders implements INode {
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
version: number
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
inputs: INodeParams[]
|
||||
credential: INodeParams
|
||||
|
||||
constructor() {
|
||||
this.label = 'Apify Website Content Crawler'
|
||||
this.name = 'apifyWebsiteContentCrawler'
|
||||
this.type = 'Document'
|
||||
this.icon = 'apify-symbol-transparent.svg'
|
||||
this.version = 1.0
|
||||
this.category = 'Document Loaders'
|
||||
this.description = 'Load data from Apify Website Content Crawler'
|
||||
this.baseClasses = [this.type]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Apify API Token',
|
||||
name: 'apifyApiToken',
|
||||
type: 'password'
|
||||
},
|
||||
{
|
||||
label: 'Input',
|
||||
name: 'input',
|
||||
@@ -43,13 +42,22 @@ class ApifyWebsiteContentCrawler_DocumentLoaders implements INode {
|
||||
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 apifyApiToken = nodeData.inputs?.apifyApiToken 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, {
|
||||
datasetMappingFunction: (item) =>
|
||||
new Document({
|
||||
|
||||
Reference in New Issue
Block a user