mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
Merge branch 'main' of https://github.com/govind-kumarr/Flowise into feature/DynamoDb-Integration
This commit is contained in:
@@ -50,7 +50,7 @@ class LLMChain_Chains implements INode {
|
||||
{
|
||||
label: 'Output Prediction',
|
||||
name: 'outputPrediction',
|
||||
baseClasses: ['string']
|
||||
baseClasses: ['string', 'json']
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -43,6 +43,10 @@ class AzureChatOpenAI_ChatModels implements INode {
|
||||
{
|
||||
label: 'gpt-35-turbo',
|
||||
name: 'gpt-35-turbo'
|
||||
},
|
||||
{
|
||||
label: 'gpt-35-turbo-16k',
|
||||
name: 'gpt-35-turbo-16k'
|
||||
}
|
||||
],
|
||||
default: 'gpt-35-turbo',
|
||||
@@ -70,14 +74,10 @@ class AzureChatOpenAI_ChatModels implements INode {
|
||||
{
|
||||
label: 'Azure OpenAI Api Version',
|
||||
name: 'azureOpenAIApiVersion',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
label: '2023-03-15-preview',
|
||||
name: '2023-03-15-preview'
|
||||
}
|
||||
],
|
||||
default: '2023-03-15-preview'
|
||||
type: 'string',
|
||||
placeholder: '2023-06-01-preview',
|
||||
description:
|
||||
'Description of Supported API Versions. Please refer <a target="_blank" href="https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#chat-completions">examples</a>'
|
||||
},
|
||||
{
|
||||
label: 'Max Tokens',
|
||||
|
||||
@@ -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.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 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><switch><g><path d="M28.8 47.4c1 0 1.9.8 1.9 1.9 0 1-.8 1.9-1.9 1.9-1 0-1.9-.8-1.9-1.9 0-1.1.9-1.9 1.9-1.9m29.4-11.6c-1 0-1.9-.8-1.9-1.9 0-1 .8-1.9 1.9-1.9 1 0 1.9.8 1.9 1.9 0 1-.9 1.9-1.9 1.9m0-7.7c-3.2 0-5.8 2.6-5.8 5.8 0 .6.1 1.2.3 1.8L33.6 45.9c-1.1-1.6-2.9-2.5-4.8-2.5-2.2 0-4.2 1.3-5.2 3.2l-17.2-9c-1.8-1-3.2-3.9-3-6.7.1-1.4.6-2.5 1.3-2.9.5-.3 1-.2 1.7.1l.1.1c4.6 2.4 19.5 10.2 20.1 10.5 1 .4 1.5.6 3.2-.2l30.8-16c.5-.2 1-.6 1-1.3 0-.9-.9-1.3-.9-1.3-1.8-.8-4.5-2.1-7.1-3.3C48 14 41.6 11 38.8 9.5c-2.4-1.3-4.4-.2-4.7 0l-.7.3C20.7 16.2 3.9 24.5 2.9 25.1c-1.7 1-2.8 3.1-2.9 5.7-.2 4.1 1.9 8.4 4.9 9.9l18.2 9.4c.4 2.8 2.9 5 5.7 5 3.2 0 5.7-2.5 5.8-5.7l20-10.8c1 .8 2.3 1.2 3.6 1.2 3.2 0 5.8-2.6 5.8-5.8 0-3.3-2.6-5.9-5.8-5.9" fill="#4285fd"/></g></switch></svg>
|
||||
|
After Width: | Height: | Size: 826 B |
@@ -43,7 +43,7 @@ class AzureOpenAIEmbedding_Embeddings implements INode {
|
||||
label: 'Azure OpenAI Api Version',
|
||||
name: 'azureOpenAIApiVersion',
|
||||
type: 'string',
|
||||
placeholder: 'YOUR-API-VERSION',
|
||||
placeholder: '2023-03-15-preview',
|
||||
description:
|
||||
'Description of Supported API Versions. Please refer <a target="_blank" href="https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#embeddings">examples</a>'
|
||||
},
|
||||
|
||||
@@ -105,18 +105,10 @@ class AzureOpenAI_LLMs implements INode {
|
||||
{
|
||||
label: 'Azure OpenAI Api Version',
|
||||
name: 'azureOpenAIApiVersion',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
label: '2023-03-15-preview',
|
||||
name: '2023-03-15-preview'
|
||||
},
|
||||
{
|
||||
label: '2022-12-01',
|
||||
name: '2022-12-01'
|
||||
}
|
||||
],
|
||||
default: '2023-03-15-preview'
|
||||
type: 'string',
|
||||
placeholder: '2023-06-01-preview',
|
||||
description:
|
||||
'Description of Supported API Versions. Please refer <a target="_blank" href="https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#completions">examples</a>'
|
||||
},
|
||||
{
|
||||
label: 'Max Tokens',
|
||||
|
||||
@@ -38,12 +38,7 @@ class ChatPromptTemplate_Prompts implements INode {
|
||||
{
|
||||
label: 'Format Prompt Values',
|
||||
name: 'promptValues',
|
||||
type: 'string',
|
||||
rows: 4,
|
||||
placeholder: `{
|
||||
"input_language": "English",
|
||||
"output_language": "French"
|
||||
}`,
|
||||
type: 'json',
|
||||
optional: true,
|
||||
acceptVariable: true,
|
||||
list: true
|
||||
|
||||
@@ -31,12 +31,7 @@ class PromptTemplate_Prompts implements INode {
|
||||
{
|
||||
label: 'Format Prompt Values',
|
||||
name: 'promptValues',
|
||||
type: 'string',
|
||||
rows: 4,
|
||||
placeholder: `{
|
||||
"input_language": "English",
|
||||
"output_language": "French"
|
||||
}`,
|
||||
type: 'json',
|
||||
optional: true,
|
||||
acceptVariable: true,
|
||||
list: true
|
||||
|
||||
@@ -245,47 +245,6 @@ export class CustomChainHandler extends BaseCallbackHandler {
|
||||
}
|
||||
}
|
||||
|
||||
export const returnJSONStr = (jsonStr: string): string => {
|
||||
let jsonStrArray = jsonStr.split(':')
|
||||
|
||||
let wholeString = ''
|
||||
for (let i = 0; i < jsonStrArray.length; i++) {
|
||||
if (jsonStrArray[i].includes(',') && jsonStrArray[i + 1] !== undefined) {
|
||||
const splitValueAndTitle = jsonStrArray[i].split(',')
|
||||
const value = splitValueAndTitle[0]
|
||||
const newTitle = splitValueAndTitle[1]
|
||||
wholeString += handleEscapeDoubleQuote(value) + ',' + newTitle + ':'
|
||||
} else {
|
||||
wholeString += wholeString === '' ? jsonStrArray[i] + ':' : handleEscapeDoubleQuote(jsonStrArray[i])
|
||||
}
|
||||
}
|
||||
return wholeString
|
||||
}
|
||||
|
||||
const handleEscapeDoubleQuote = (value: string): string => {
|
||||
let newValue = ''
|
||||
if (value.includes('"')) {
|
||||
const valueArray = value.split('"')
|
||||
for (let i = 0; i < valueArray.length; i++) {
|
||||
if ((i + 1) % 2 !== 0) {
|
||||
switch (valueArray[i]) {
|
||||
case '':
|
||||
newValue += '"'
|
||||
break
|
||||
case '}':
|
||||
newValue += '"}'
|
||||
break
|
||||
default:
|
||||
newValue += '\\"' + valueArray[i] + '\\"'
|
||||
}
|
||||
} else {
|
||||
newValue += valueArray[i]
|
||||
}
|
||||
}
|
||||
}
|
||||
return newValue === '' ? value : newValue
|
||||
}
|
||||
|
||||
export const availableDependencies = [
|
||||
'@dqbd/tiktoken',
|
||||
'@getzep/zep-js',
|
||||
|
||||
Reference in New Issue
Block a user