mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 13:00:56 +03:00
update credentials
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { GithubRepoLoader, GithubRepoLoaderParams } from 'langchain/document_loaders/web/github'
|
||||
import { getCredentialData, getCredentialParam } from '../../../src'
|
||||
|
||||
class Github_DocumentLoaders implements INode {
|
||||
label: string
|
||||
@@ -10,6 +11,7 @@ class Github_DocumentLoaders implements INode {
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
credential: INodeParams
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
@@ -20,6 +22,14 @@ class Github_DocumentLoaders implements INode {
|
||||
this.category = 'Document Loaders'
|
||||
this.description = `Load data from a GitHub repository`
|
||||
this.baseClasses = [this.type]
|
||||
this.credential = {
|
||||
label: 'Connect Credential',
|
||||
name: 'credential',
|
||||
type: 'credential',
|
||||
description: 'Only needed when accessing private repo',
|
||||
optional: true,
|
||||
credentialNames: ['githubApi']
|
||||
}
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Repo Link',
|
||||
@@ -33,13 +43,6 @@ class Github_DocumentLoaders implements INode {
|
||||
type: 'string',
|
||||
default: 'main'
|
||||
},
|
||||
{
|
||||
label: 'Access Token',
|
||||
name: 'accessToken',
|
||||
type: 'password',
|
||||
placeholder: '<GITHUB_ACCESS_TOKEN>',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Recursive',
|
||||
name: 'recursive',
|
||||
@@ -62,23 +65,25 @@ class Github_DocumentLoaders implements INode {
|
||||
]
|
||||
}
|
||||
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||
const repoLink = nodeData.inputs?.repoLink as string
|
||||
const branch = nodeData.inputs?.branch as string
|
||||
const recursive = nodeData.inputs?.recursive as boolean
|
||||
const accessToken = nodeData.inputs?.accessToken as string
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||
const metadata = nodeData.inputs?.metadata
|
||||
|
||||
const options: GithubRepoLoaderParams = {
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const accessToken = getCredentialParam('accessToken', credentialData, nodeData)
|
||||
|
||||
const githubOptions: GithubRepoLoaderParams = {
|
||||
branch,
|
||||
recursive,
|
||||
unknown: 'warn'
|
||||
}
|
||||
|
||||
if (accessToken) options.accessToken = accessToken
|
||||
if (accessToken) githubOptions.accessToken = accessToken
|
||||
|
||||
const loader = new GithubRepoLoader(repoLink, options)
|
||||
const loader = new GithubRepoLoader(repoLink, githubOptions)
|
||||
const docs = textSplitter ? await loader.loadAndSplit(textSplitter) : await loader.load()
|
||||
|
||||
if (metadata) {
|
||||
|
||||
Reference in New Issue
Block a user