Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions packages/components/nodes/documentloaders/Github/Github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ class Github_DocumentLoaders implements INode {
placeholder: '<GITHUB_ACCESS_TOKEN>',
optional: true
},
{
label: 'Recursive',
name: 'recursive',
type: 'boolean',
optional: true
},
{
label: 'Text Splitter',
name: 'textSplitter',
Expand All @@ -59,41 +65,33 @@ class Github_DocumentLoaders implements INode {
async init(nodeData: INodeData): 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 = {
branch,
recursive: false,
recursive,
unknown: 'warn'
}

if (accessToken) options.accessToken = accessToken

const loader = new GithubRepoLoader(repoLink, options)
let docs = []

if (textSplitter) {
docs = await loader.loadAndSplit(textSplitter)
} else {
docs = await loader.load()
}
const docs = textSplitter ? await loader.loadAndSplit(textSplitter) : await loader.load()

if (metadata) {
const parsedMetadata = typeof metadata === 'object' ? metadata : JSON.parse(metadata)
let finaldocs = []
for (const doc of docs) {
const newdoc = {
return docs.map((doc) => {
return {
...doc,
metadata: {
...doc.metadata,
...parsedMetadata
}
}
finaldocs.push(newdoc)
}
return finaldocs
})
}

return docs
Expand Down