Merge branch 'main' into feature/ChatHistory2

This commit is contained in:
chungyau97
2023-09-21 13:58:15 +08:00
9 changed files with 101 additions and 113 deletions
@@ -114,7 +114,7 @@ class GoogleVertexAI_ChatModels implements INode {
const maxOutputTokens = nodeData.inputs?.maxOutputTokens as string const maxOutputTokens = nodeData.inputs?.maxOutputTokens as string
const topP = nodeData.inputs?.topP as string const topP = nodeData.inputs?.topP as string
const obj: Partial<GoogleVertexAIChatInput> = { const obj: GoogleVertexAIChatInput<GoogleAuthOptions> = {
temperature: parseFloat(temperature), temperature: parseFloat(temperature),
model: modelName model: modelName
} }
@@ -1,8 +1,10 @@
import { INode, INodeData, INodeParams } from '../../../src/Interface' import { INode, INodeData, INodeParams } from '../../../src/Interface'
import { TextSplitter } from 'langchain/text_splitter' import { TextSplitter } from 'langchain/text_splitter'
import { CheerioWebBaseLoader } from 'langchain/document_loaders/web/cheerio' import { CheerioWebBaseLoader, WebBaseLoaderParams } from 'langchain/document_loaders/web/cheerio'
import { test } from 'linkifyjs' import { test } from 'linkifyjs'
import { parse } from 'css-what'
import { webCrawl, xmlScrape } from '../../../src' import { webCrawl, xmlScrape } from '../../../src'
import { SelectorType } from 'cheerio'
class Cheerio_DocumentLoaders implements INode { class Cheerio_DocumentLoaders implements INode {
label: string label: string
@@ -18,7 +20,7 @@ class Cheerio_DocumentLoaders implements INode {
constructor() { constructor() {
this.label = 'Cheerio Web Scraper' this.label = 'Cheerio Web Scraper'
this.name = 'cheerioWebScraper' this.name = 'cheerioWebScraper'
this.version = 1.0 this.version = 1.1
this.type = 'Document' this.type = 'Document'
this.icon = 'cheerio.svg' this.icon = 'cheerio.svg'
this.category = 'Document Loaders' this.category = 'Document Loaders'
@@ -66,6 +68,14 @@ class Cheerio_DocumentLoaders implements INode {
'Only used when "Get Relative Links Method" is selected. Set 0 to retrieve all relative links, default limit is 10.', 'Only used when "Get Relative Links Method" is selected. Set 0 to retrieve all relative links, default limit is 10.',
warning: `Retrieving all links might take long time, and all links will be upserted again if the flow's state changed (eg: different URL, chunk size, etc)` warning: `Retrieving all links might take long time, and all links will be upserted again if the flow's state changed (eg: different URL, chunk size, etc)`
}, },
{
label: 'Selector (CSS)',
name: 'selector',
type: 'string',
description: 'Specify a CSS selector to select the content to be extracted',
optional: true,
additionalParams: true
},
{ {
label: 'Metadata', label: 'Metadata',
name: 'metadata', name: 'metadata',
@@ -88,10 +98,18 @@ class Cheerio_DocumentLoaders implements INode {
throw new Error('Invalid URL') throw new Error('Invalid URL')
} }
const selector: SelectorType = nodeData.inputs?.selector as SelectorType
let params: WebBaseLoaderParams = {}
if (selector) {
parse(selector) // comes with cheerio - will throw error if invalid
params['selector'] = selector
}
async function cheerioLoader(url: string): Promise<any> { async function cheerioLoader(url: string): Promise<any> {
try { try {
let docs = [] let docs = []
const loader = new CheerioWebBaseLoader(url) const loader = new CheerioWebBaseLoader(url, params)
if (textSplitter) { if (textSplitter) {
docs = await loader.loadAndSplit(textSplitter) docs = await loader.loadAndSplit(textSplitter)
} else { } else {
@@ -17,7 +17,7 @@ class OpenAI_LLMs implements INode {
constructor() { constructor() {
this.label = 'OpenAI' this.label = 'OpenAI'
this.name = 'openAI' this.name = 'openAI'
this.version = 1.0 this.version = 2.0
this.type = 'OpenAI' this.type = 'OpenAI'
this.icon = 'openai.png' this.icon = 'openai.png'
this.category = 'LLMs' this.category = 'LLMs'
@@ -36,23 +36,19 @@ class OpenAI_LLMs implements INode {
type: 'options', type: 'options',
options: [ options: [
{ {
label: 'text-davinci-003', label: 'gpt-3.5-turbo-instruct',
name: 'text-davinci-003' name: 'gpt-3.5-turbo-instruct'
}, },
{ {
label: 'text-davinci-002', label: 'babbage-002',
name: 'text-davinci-002' name: 'babbage-002'
}, },
{ {
label: 'text-curie-001', label: 'davinci-002',
name: 'text-curie-001' name: 'davinci-002'
},
{
label: 'text-babbage-001',
name: 'text-babbage-001'
} }
], ],
default: 'text-davinci-003', default: 'gpt-3.5-turbo-instruct',
optional: true optional: true
}, },
{ {
@@ -1,6 +1,7 @@
import { Chroma, ChromaLibArgs } from 'langchain/vectorstores/chroma' import { Chroma, ChromaLibArgs } from 'langchain/vectorstores/chroma'
import { Embeddings } from 'langchain/embeddings/base' import { Embeddings } from 'langchain/embeddings/base'
import type { Collection } from 'chromadb' import type { Collection } from 'chromadb'
import { ChromaClient } from 'chromadb'
interface ChromaAuth { interface ChromaAuth {
chromaApiKey?: string chromaApiKey?: string
@@ -23,7 +24,6 @@ export class ChromaExtended extends Chroma {
async ensureCollection(): Promise<Collection> { async ensureCollection(): Promise<Collection> {
if (!this.collection) { if (!this.collection) {
if (!this.index) { if (!this.index) {
const { ChromaClient } = await Chroma.imports()
const obj: any = { const obj: any = {
path: this.url path: this.url
} }
@@ -37,8 +37,9 @@ export class ChromaExtended extends Chroma {
this.index = new ChromaClient(obj) this.index = new ChromaClient(obj)
} }
try { try {
this.collection = await this.index.getOrCreateCollection({ this.collection = await this.index!.getOrCreateCollection({
name: this.collectionName name: this.collectionName,
...(this.collectionMetadata && { metadata: this.collectionMetadata })
}) })
} catch (err) { } catch (err) {
throw new Error(`Chroma getOrCreateCollection error: ${err}`) throw new Error(`Chroma getOrCreateCollection error: ${err}`)
+3 -3
View File
@@ -1,6 +1,6 @@
{ {
"name": "flowise-components", "name": "flowise-components",
"version": "1.3.5", "version": "1.3.6",
"description": "Flowiseai Components", "description": "Flowiseai Components",
"main": "dist/src/index", "main": "dist/src/index",
"types": "dist/src/index.d.ts", "types": "dist/src/index.d.ts",
@@ -32,7 +32,7 @@
"apify-client": "^2.7.1", "apify-client": "^2.7.1",
"axios": "^0.27.2", "axios": "^0.27.2",
"cheerio": "^1.0.0-rc.12", "cheerio": "^1.0.0-rc.12",
"chromadb": "^1.5.3", "chromadb": "^1.5.11",
"cohere-ai": "^6.2.0", "cohere-ai": "^6.2.0",
"d3-dsv": "2", "d3-dsv": "2",
"dotenv": "^16.0.0", "dotenv": "^16.0.0",
@@ -42,7 +42,7 @@
"google-auth-library": "^9.0.0", "google-auth-library": "^9.0.0",
"graphql": "^16.6.0", "graphql": "^16.6.0",
"html-to-text": "^9.0.5", "html-to-text": "^9.0.5",
"langchain": "^0.0.147", "langchain": "^0.0.152",
"langfuse-langchain": "^1.0.14-alpha.0", "langfuse-langchain": "^1.0.14-alpha.0",
"langsmith": "^0.0.32", "langsmith": "^0.0.32",
"linkifyjs": "^4.1.1", "linkifyjs": "^4.1.1",
@@ -328,7 +328,7 @@
"id": "openAI_2", "id": "openAI_2",
"label": "OpenAI", "label": "OpenAI",
"name": "openAI", "name": "openAI",
"version": 1, "version": 2,
"type": "OpenAI", "type": "OpenAI",
"baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"], "baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"],
"category": "LLMs", "category": "LLMs",
@@ -347,23 +347,19 @@
"type": "options", "type": "options",
"options": [ "options": [
{ {
"label": "text-davinci-003", "label": "gpt-3.5-turbo-instruct",
"name": "text-davinci-003" "name": "gpt-3.5-turbo-instruct"
}, },
{ {
"label": "text-davinci-002", "label": "babbage-002",
"name": "text-davinci-002" "name": "babbage-002"
}, },
{ {
"label": "text-curie-001", "label": "davinci-002",
"name": "text-curie-001" "name": "davinci-002"
},
{
"label": "text-babbage-001",
"name": "text-babbage-001"
} }
], ],
"default": "text-davinci-003", "default": "gpt-3.5-turbo-instruct",
"optional": true, "optional": true,
"id": "openAI_2-input-modelName-options" "id": "openAI_2-input-modelName-options"
}, },
@@ -442,7 +438,7 @@
], ],
"inputAnchors": [], "inputAnchors": [],
"inputs": { "inputs": {
"modelName": "text-davinci-003", "modelName": "gpt-3.5-turbo-instruct",
"temperature": 0.7, "temperature": 0.7,
"maxTokens": "", "maxTokens": "",
"topP": "", "topP": "",
@@ -743,7 +739,7 @@
"id": "openAI_3", "id": "openAI_3",
"label": "OpenAI", "label": "OpenAI",
"name": "openAI", "name": "openAI",
"version": 1, "version": 2,
"type": "OpenAI", "type": "OpenAI",
"baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"], "baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"],
"category": "LLMs", "category": "LLMs",
@@ -762,23 +758,19 @@
"type": "options", "type": "options",
"options": [ "options": [
{ {
"label": "text-davinci-003", "label": "gpt-3.5-turbo-instruct",
"name": "text-davinci-003" "name": "gpt-3.5-turbo-instruct"
}, },
{ {
"label": "text-davinci-002", "label": "babbage-002",
"name": "text-davinci-002" "name": "babbage-002"
}, },
{ {
"label": "text-curie-001", "label": "davinci-002",
"name": "text-curie-001" "name": "davinci-002"
},
{
"label": "text-babbage-001",
"name": "text-babbage-001"
} }
], ],
"default": "text-davinci-003", "default": "gpt-3.5-turbo-instruct",
"optional": true, "optional": true,
"id": "openAI_3-input-modelName-options" "id": "openAI_3-input-modelName-options"
}, },
@@ -857,7 +849,7 @@
], ],
"inputAnchors": [], "inputAnchors": [],
"inputs": { "inputs": {
"modelName": "text-davinci-003", "modelName": "gpt-3.5-turbo-instruct",
"temperature": 0.7, "temperature": 0.7,
"maxTokens": "", "maxTokens": "",
"topP": "", "topP": "",
@@ -1008,7 +1000,7 @@
"id": "openAI_4", "id": "openAI_4",
"label": "OpenAI", "label": "OpenAI",
"name": "openAI", "name": "openAI",
"version": 1, "version": 2,
"type": "OpenAI", "type": "OpenAI",
"baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"], "baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"],
"category": "LLMs", "category": "LLMs",
@@ -1027,23 +1019,19 @@
"type": "options", "type": "options",
"options": [ "options": [
{ {
"label": "text-davinci-003", "label": "gpt-3.5-turbo-instruct",
"name": "text-davinci-003" "name": "gpt-3.5-turbo-instruct"
}, },
{ {
"label": "text-davinci-002", "label": "babbage-002",
"name": "text-davinci-002" "name": "babbage-002"
}, },
{ {
"label": "text-curie-001", "label": "davinci-002",
"name": "text-curie-001" "name": "davinci-002"
},
{
"label": "text-babbage-001",
"name": "text-babbage-001"
} }
], ],
"default": "text-davinci-003", "default": "gpt-3.5-turbo-instruct",
"optional": true, "optional": true,
"id": "openAI_4-input-modelName-options" "id": "openAI_4-input-modelName-options"
}, },
@@ -1122,7 +1110,7 @@
], ],
"inputAnchors": [], "inputAnchors": [],
"inputs": { "inputs": {
"modelName": "text-davinci-003", "modelName": "gpt-3.5-turbo-instruct",
"temperature": 0.7, "temperature": 0.7,
"maxTokens": "", "maxTokens": "",
"topP": "", "topP": "",
@@ -296,7 +296,7 @@
"id": "openAI_1", "id": "openAI_1",
"label": "OpenAI", "label": "OpenAI",
"name": "openAI", "name": "openAI",
"version": 1, "version": 2,
"type": "OpenAI", "type": "OpenAI",
"baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"], "baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"],
"category": "LLMs", "category": "LLMs",
@@ -315,23 +315,19 @@
"type": "options", "type": "options",
"options": [ "options": [
{ {
"label": "text-davinci-003", "label": "gpt-3.5-turbo-instruct",
"name": "text-davinci-003" "name": "gpt-3.5-turbo-instruct"
}, },
{ {
"label": "text-davinci-002", "label": "babbage-002",
"name": "text-davinci-002" "name": "babbage-002"
}, },
{ {
"label": "text-curie-001", "label": "davinci-002",
"name": "text-curie-001" "name": "davinci-002"
},
{
"label": "text-babbage-001",
"name": "text-babbage-001"
} }
], ],
"default": "text-davinci-003", "default": "gpt-3.5-turbo-instruct",
"optional": true, "optional": true,
"id": "openAI_1-input-modelName-options" "id": "openAI_1-input-modelName-options"
}, },
@@ -410,7 +406,7 @@
], ],
"inputAnchors": [], "inputAnchors": [],
"inputs": { "inputs": {
"modelName": "text-davinci-003", "modelName": "gpt-3.5-turbo-instruct",
"temperature": 0.7, "temperature": 0.7,
"maxTokens": "", "maxTokens": "",
"topP": "", "topP": "",
@@ -452,7 +448,7 @@
"id": "openAI_2", "id": "openAI_2",
"label": "OpenAI", "label": "OpenAI",
"name": "openAI", "name": "openAI",
"version": 1, "version": 2,
"type": "OpenAI", "type": "OpenAI",
"baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"], "baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"],
"category": "LLMs", "category": "LLMs",
@@ -471,23 +467,19 @@
"type": "options", "type": "options",
"options": [ "options": [
{ {
"label": "text-davinci-003", "label": "gpt-3.5-turbo-instruct",
"name": "text-davinci-003" "name": "gpt-3.5-turbo-instruct"
}, },
{ {
"label": "text-davinci-002", "label": "babbage-002",
"name": "text-davinci-002" "name": "babbage-002"
}, },
{ {
"label": "text-curie-001", "label": "davinci-002",
"name": "text-curie-001" "name": "davinci-002"
},
{
"label": "text-babbage-001",
"name": "text-babbage-001"
} }
], ],
"default": "text-davinci-003", "default": "gpt-3.5-turbo-instruct",
"optional": true, "optional": true,
"id": "openAI_2-input-modelName-options" "id": "openAI_2-input-modelName-options"
}, },
@@ -565,8 +557,9 @@
} }
], ],
"inputAnchors": [], "inputAnchors": [],
"default": "gpt-3.5-turbo-instruct",
"inputs": { "inputs": {
"modelName": "text-davinci-003", "modelName": "gpt-3.5-turbo-instruct",
"temperature": 0.7, "temperature": 0.7,
"maxTokens": "", "maxTokens": "",
"topP": "", "topP": "",
@@ -155,7 +155,7 @@
"id": "openAI_0", "id": "openAI_0",
"label": "OpenAI", "label": "OpenAI",
"name": "openAI", "name": "openAI",
"version": 1, "version": 2,
"type": "OpenAI", "type": "OpenAI",
"baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"], "baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"],
"category": "LLMs", "category": "LLMs",
@@ -174,23 +174,19 @@
"type": "options", "type": "options",
"options": [ "options": [
{ {
"label": "text-davinci-003", "label": "gpt-3.5-turbo-instruct",
"name": "text-davinci-003" "name": "gpt-3.5-turbo-instruct"
}, },
{ {
"label": "text-davinci-002", "label": "babbage-002",
"name": "text-davinci-002" "name": "babbage-002"
}, },
{ {
"label": "text-curie-001", "label": "davinci-002",
"name": "text-curie-001" "name": "davinci-002"
},
{
"label": "text-babbage-001",
"name": "text-babbage-001"
} }
], ],
"default": "text-davinci-003", "default": "gpt-3.5-turbo-instruct",
"optional": true, "optional": true,
"id": "openAI_0-input-modelName-options" "id": "openAI_0-input-modelName-options"
}, },
@@ -269,7 +265,7 @@
], ],
"inputAnchors": [], "inputAnchors": [],
"inputs": { "inputs": {
"modelName": "text-davinci-003", "modelName": "gpt-3.5-turbo-instruct",
"temperature": 0.7, "temperature": 0.7,
"maxTokens": "", "maxTokens": "",
"topP": "", "topP": "",
@@ -115,7 +115,7 @@
"id": "openAI_0", "id": "openAI_0",
"label": "OpenAI", "label": "OpenAI",
"name": "openAI", "name": "openAI",
"version": 1, "version": 2,
"type": "OpenAI", "type": "OpenAI",
"baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"], "baseClasses": ["OpenAI", "BaseLLM", "BaseLanguageModel"],
"category": "LLMs", "category": "LLMs",
@@ -134,23 +134,19 @@
"type": "options", "type": "options",
"options": [ "options": [
{ {
"label": "text-davinci-003", "label": "gpt-3.5-turbo-instruct",
"name": "text-davinci-003" "name": "gpt-3.5-turbo-instruct"
}, },
{ {
"label": "text-davinci-002", "label": "babbage-002",
"name": "text-davinci-002" "name": "babbage-002"
}, },
{ {
"label": "text-curie-001", "label": "davinci-002",
"name": "text-curie-001" "name": "davinci-002"
},
{
"label": "text-babbage-001",
"name": "text-babbage-001"
} }
], ],
"default": "text-davinci-003", "default": "gpt-3.5-turbo-instruct",
"optional": true, "optional": true,
"id": "openAI_0-input-modelName-options" "id": "openAI_0-input-modelName-options"
}, },
@@ -229,7 +225,7 @@
], ],
"inputAnchors": [], "inputAnchors": [],
"inputs": { "inputs": {
"modelName": "text-davinci-003", "modelName": "gpt-3.5-turbo-instruct",
"temperature": 0.7, "temperature": 0.7,
"maxTokens": "", "maxTokens": "",
"topP": "", "topP": "",