mirror of https://github.com/FlowiseAI/Flowise.git
Merge pull request #455 from govind-kumarr/feature/Gitbook-Integration
added gitBook integrationpull/462/head
commit
4cadd7aa37
|
|
@ -0,0 +1,82 @@
|
|||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { TextSplitter } from 'langchain/text_splitter'
|
||||
import { GitbookLoader } from 'langchain/document_loaders/web/gitbook'
|
||||
|
||||
class Gitbook_DocumentLoaders implements INode {
|
||||
label: string
|
||||
name: string
|
||||
description: string
|
||||
type: string
|
||||
icon: string
|
||||
category: string
|
||||
baseClasses: string[]
|
||||
inputs?: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'GitBook'
|
||||
this.name = 'gitbook'
|
||||
this.type = 'Document'
|
||||
this.icon = 'gitbook_logo.svg'
|
||||
this.category = 'Document Loaders'
|
||||
this.description = `Load data from GitBook`
|
||||
this.baseClasses = [this.type]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Web Path',
|
||||
name: 'webPath',
|
||||
type: 'string',
|
||||
placeholder: 'https://docs.gitbook.com/product-tour/navigation',
|
||||
description: 'If want to load all paths from the GitBook provide only root path e.g.https://docs.gitbook.com/ '
|
||||
},
|
||||
{
|
||||
label: 'Should Load All Paths',
|
||||
name: 'shouldLoadAllPaths',
|
||||
type: 'boolean',
|
||||
description: 'Load from all paths in a given GitBook',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Text Splitter',
|
||||
name: 'textSplitter',
|
||||
type: 'TextSplitter',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Metadata',
|
||||
name: 'metadata',
|
||||
type: 'json',
|
||||
optional: true,
|
||||
additionalParams: true
|
||||
}
|
||||
]
|
||||
}
|
||||
async init(nodeData: INodeData): Promise<any> {
|
||||
const webPath = nodeData.inputs?.webPath as string
|
||||
const shouldLoadAllPaths = nodeData.inputs?.shouldLoadAllPaths as boolean
|
||||
const textSplitter = nodeData.inputs?.textSplitter as TextSplitter
|
||||
const metadata = nodeData.inputs?.metadata
|
||||
|
||||
const loader = shouldLoadAllPaths ? new GitbookLoader(webPath, { shouldLoadAllPaths }) : new GitbookLoader(webPath)
|
||||
|
||||
const docs = textSplitter ? await loader.loadAndSplit() : await loader.load()
|
||||
|
||||
if (metadata) {
|
||||
const parsedMetadata = typeof metadata === 'object' ? metadata : JSON.parse(metadata)
|
||||
return docs.map((doc) => {
|
||||
return {
|
||||
...doc,
|
||||
metadata: {
|
||||
...doc.metadata,
|
||||
...parsedMetadata
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return docs
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
nodeClass: Gitbook_DocumentLoaders
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<svg width="2333" height="512" viewBox="0 0 2333 512" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M411.148 6.38992L649.535 125.583C660.551 131.091 660.723 146.751 649.831 152.499L340.222 315.904C322.959 325.015 302.362 325.241 284.903 316.512L90.5121 219.316C66.8302 209.802 40.3508 227.178 40.3508 253.351C40.3508 274.394 52.2398 293.631 71.0611 303.042L265.953 400.487C277.85 388.374 294.415 380.86 312.736 380.86C330.533 380.86 346.673 387.95 358.487 399.459L601.233 271.344C600.568 267.598 600.221 263.742 600.221 259.805C600.221 223.592 629.578 194.236 665.791 194.236C702.004 194.236 731.361 223.592 731.361 259.805C731.361 296.019 702.004 325.375 665.791 325.375C648.084 325.375 632.016 318.357 620.218 306.95L377.337 435.137C377.974 438.806 378.306 442.579 378.306 446.43C378.306 482.643 348.949 512 312.736 512C276.523 512 247.166 482.643 247.166 446.43C247.166 443.081 247.417 439.79 247.902 436.575L50.187 337.719C19.4291 322.34 0 290.903 0 256.514V237.36C0 211.17 14.4951 187.131 37.6576 174.908L355.829 6.99775C373.092 -2.11324 393.689 -2.33956 411.148 6.38992ZM312.736 471.649C326.664 471.649 337.955 460.358 337.955 446.43C337.955 432.502 326.664 421.211 312.736 421.211C298.808 421.211 287.517 432.502 287.517 446.43C287.517 460.358 298.808 471.649 312.736 471.649ZM691.01 259.805C691.01 273.734 679.719 285.025 665.791 285.025C651.863 285.025 640.572 273.734 640.572 259.805C640.572 245.877 651.863 234.586 665.791 234.586C679.719 234.586 691.01 245.877 691.01 259.805Z" fill="white"/>
|
||||
<path d="M1243.54 158.218C1243.54 172.946 1231.6 184.885 1216.87 184.885C1202.14 184.885 1190.2 172.946 1190.2 158.218C1190.2 143.491 1202.14 131.552 1216.87 131.552C1231.6 131.552 1243.54 143.491 1243.54 158.218Z" fill="white"/>
|
||||
<path d="M1194.66 202.666V398.221H1239.1V202.666H1194.66Z" fill="white"/>
|
||||
<path d="M1301.31 342.689C1301.31 379.842 1318.09 398.219 1357.24 398.219H1390.2V360.267H1366.93C1351.35 360.267 1345.76 354.275 1345.76 338.295V238.22H1390.2V202.665H1345.76V140.443H1301.31V202.665H1265.76V238.22H1301.31V342.689Z" fill="white"/>
|
||||
<path d="M1425.76 113.778V398.222H1532.03C1599.54 398.222 1635.12 363.715 1635.12 316.175C1635.12 275.426 1611.8 260.17 1574.65 253.778C1607.81 246.587 1625.11 222.842 1625.11 188.884C1625.11 142.942 1589.95 113.778 1528.43 113.778H1425.76ZM1471.7 152.13H1529.63C1561.59 152.13 1579.17 169.708 1579.17 194.477C1579.17 219.646 1561.19 238.222 1529.63 238.222H1471.7V152.13ZM1471.7 273.778H1532.43C1567.98 273.778 1587.98 286.212 1587.98 313.778C1587.98 342.142 1569.18 359.47 1532.43 359.47H1471.7V273.778Z" fill="white"/>
|
||||
<path d="M1767.98 398.221C1831.73 398.221 1874.65 355.473 1874.65 291.555C1874.65 228.043 1831.73 184.888 1767.98 184.888C1704.23 184.888 1661.31 228.043 1661.31 291.555C1661.31 355.473 1704.23 398.221 1767.98 398.221ZM1767.98 360.766C1730.79 360.766 1706.68 331.86 1706.68 291.555C1706.68 251.249 1730.79 222.344 1767.98 222.344C1805.17 222.344 1829.69 251.249 1829.69 291.555C1829.69 331.86 1805.17 360.766 1767.98 360.766Z" fill="white"/>
|
||||
<path d="M2007.98 398.221C2071.73 398.221 2114.65 355.473 2114.65 291.555C2114.65 228.043 2071.73 184.888 2007.98 184.888C1944.22 184.888 1901.31 228.043 1901.31 291.555C1901.31 355.473 1944.22 398.221 2007.98 398.221ZM2007.98 360.766C1970.79 360.766 1946.68 331.86 1946.68 291.555C1946.68 251.249 1970.79 222.344 2007.98 222.344C2045.17 222.344 2069.69 251.249 2069.69 291.555C2069.69 331.86 2045.17 360.766 2007.98 360.766Z" fill="white"/>
|
||||
<path d="M2218.59 305.138L2184.46 343.489V398.221H2141.31V113.777H2184.46V291.155L2282.49 184.888H2332.42L2249.35 273.577L2332.42 398.221H2281.29L2218.59 305.138Z" fill="white"/>
|
||||
<path d="M1033.55 398.221C955.248 398.221 901.316 341.093 901.316 256C901.316 170.906 954.05 113.778 1037.15 113.778C1098.67 113.778 1142.51 148.442 1154.92 202.667H1108.39C1097.26 172.256 1071.47 154.127 1035.95 154.127C982.814 154.127 948.457 196.075 948.457 256C948.457 315.924 982.015 357.872 1035.55 357.872C1078.69 357.872 1113.45 333.502 1115.85 288.359V273.777H1034.65V238.222H1159.09V398.221H1125.04L1120.24 355.874C1106.66 375.849 1077.89 398.221 1033.55 398.221Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.1 KiB |
Loading…
Reference in New Issue