Skip to content

Commit

Permalink
Merge branch 'main' into feature/adding-returndirect-to-customtool-node
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickreinan authored Jun 12, 2024
2 parents 9a4308a + 5ba468b commit 3591b72
Show file tree
Hide file tree
Showing 14 changed files with 323 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
**/logs
**/*.log

## pnpm
.pnpm-store/

## build
**/dist
**/build
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flowise",
"version": "1.8.1",
"version": "1.8.2",
"private": true,
"homepage": "https://flowiseai.com",
"workspaces": [
Expand Down
23 changes: 23 additions & 0 deletions packages/components/credentials/FireworksApi.credential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { INodeParams, INodeCredential } from '../src/Interface'

class FireworksApi implements INodeCredential {
label: string
name: string
version: number
inputs: INodeParams[]

constructor() {
this.label = 'Fireworks API'
this.name = 'fireworksApi'
this.version = 1.0
this.inputs = [
{
label: 'Fireworks Api Key',
name: 'fireworksApiKey',
type: 'password'
}
]
}
}

module.exports = { credClass: FireworksApi }
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { BaseCache } from '@langchain/core/caches'
import { ChatFireworks } from '@langchain/community/chat_models/fireworks'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'

class ChatFireworks_ChatModels implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]

constructor() {
this.label = 'ChatFireworks'
this.name = 'chatFireworks'
this.version = 1.0
this.type = 'ChatFireworks'
this.icon = 'Fireworks.png'
this.category = 'Chat Models'
this.description = 'Wrapper around Fireworks Chat Endpoints'
this.baseClasses = [this.type, ...getBaseClasses(ChatFireworks)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['fireworksApi']
}
this.inputs = [
{
label: 'Cache',
name: 'cache',
type: 'BaseCache',
optional: true
},
{
label: 'Model',
name: 'modelName',
type: 'string',
default: 'accounts/fireworks/models/llama-v2-13b-chat',
placeholder: 'accounts/fireworks/models/llama-v2-13b-chat'
},
{
label: 'Temperature',
name: 'temperature',
type: 'number',
step: 0.1,
default: 0.9,
optional: true
}
]
}

async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const cache = nodeData.inputs?.cache as BaseCache
const temperature = nodeData.inputs?.temperature as string
const modelName = nodeData.inputs?.modelName as string

const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const fireworksApiKey = getCredentialParam('fireworksApiKey', credentialData, nodeData)

const obj: Partial<ChatFireworks> = {
fireworksApiKey,
model: modelName,
modelName,
temperature: temperature ? parseFloat(temperature) : undefined
}
if (cache) obj.cache = cache

const model = new ChatFireworks(obj)
return model
}
}

module.exports = { nodeClass: ChatFireworks_ChatModels }
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions packages/components/nodes/llms/Fireworks/Fireworks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import { getBaseClasses, getCredentialData, getCredentialParam, ICommonObject, INode, INodeData, INodeParams } from '../../../src'
import { Fireworks } from '@langchain/community/llms/fireworks'
import { BaseCache } from '@langchain/core/caches'

class Fireworks_LLMs implements INode {
label: string
name: string
version: number
type: string
icon: string
category: string
description: string
baseClasses: string[]
credential: INodeParams
inputs: INodeParams[]

constructor() {
this.label = 'Fireworks'
this.name = 'fireworks'
this.version = 1.0
this.type = 'Fireworks'
this.icon = 'fireworks.png'
this.category = 'LLMs'
this.description = 'Wrapper around Fireworks API for large language models'
this.baseClasses = [this.type, ...getBaseClasses(Fireworks)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['fireworksApi']
}
this.inputs = [
{
label: 'Cache',
name: 'cache',
type: 'BaseCache',
optional: true
},
{
label: 'Model Name',
name: 'modelName',
type: 'string',
default: 'accounts/fireworks/models/llama-v3-70b-instruct-hf',
description: 'For more details see https://fireworks.ai/models',
optional: true
}
]
}

async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const cache = nodeData.inputs?.cache as BaseCache
const modelName = nodeData.inputs?.modelName as string

const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const fireworksKey = getCredentialParam('fireworksApiKey', credentialData, nodeData)

const obj: any = {
fireworksApiKey: fireworksKey,
modelName: modelName
}
if (cache) obj.cache = cache

const fireworks = new Fireworks(obj)
return fireworks
}
}

module.exports = { nodeClass: Fireworks_LLMs }
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions packages/components/nodes/tools/Searxng/SearXNG.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
119 changes: 119 additions & 0 deletions packages/components/nodes/tools/Searxng/Searxng.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { SearxngSearch } from '@langchain/community/tools/searxng_search'
import { INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses } from '../../../src/utils'

class Searxng_Tools implements INode {
label: string
name: string
version: number
description: string
type: string
icon: string
category: string
baseClasses: string[]
inputs: INodeParams[]

constructor() {
this.label = 'SearXNG'
this.name = 'searXNG'
this.version = 1.0
this.type = 'SearXNG'
this.icon = 'SearXNG.svg'
this.category = 'Tools'
this.description = 'Wrapper around SearXNG - a free internet metasearch engine'
this.inputs = [
{
label: 'Base URL',
name: 'apiBase',
type: 'string',
default: 'http://searxng:8080'
},
{
label: 'Categories',
name: 'categories',
description:
'Comma separated list, specifies the active search categories. (see <a target="_blank" href="https://docs.searxng.org/user/configured_engines.html#configured-engines">Configured Engines</a>)',
optional: true,
additionalParams: true,
type: 'string'
},
{
label: 'Engines',
name: 'engines',
description:
'Comma separated list, specifies the active search engines. (see <a target="_blank" href="https://docs.searxng.org/user/configured_engines.html#configured-engines">Configured Engines</a>)',
optional: true,
additionalParams: true,
type: 'string'
},
{
label: 'Language',
name: 'language',
description: 'Code of the language.',
optional: true,
additionalParams: true,
type: 'string'
},
{
label: 'Page No.',
name: 'pageno',
description: 'Search page number.',
optional: true,
additionalParams: true,
type: 'number'
},
{
label: 'Time Range',
name: 'time_range',
description:
'Time range of search for engines which support it. See if an engine supports time range search in the preferences page of an instance.',
optional: true,
additionalParams: true,
type: 'string'
},
{
label: 'Safe Search',
name: 'safesearch',
description:
'Filter search results of engines which support safe search. See if an engine supports safe search in the preferences page of an instance.',
optional: true,
additionalParams: true,
type: 'number'
}
]
this.baseClasses = [this.type, ...getBaseClasses(SearxngSearch)]
}

async init(nodeData: INodeData, _: string): Promise<any> {
const apiBase = nodeData.inputs?.apiBase as string
const categories = nodeData.inputs?.categories as string
const engines = nodeData.inputs?.engines as string
const language = nodeData.inputs?.language as string
const pageno = nodeData.inputs?.pageno as number
const time_range = nodeData.inputs?.time_range as string
const safesearch = nodeData.inputs?.safesearch as 0 | 1 | 2 | undefined
const format = 'json' as 'json'

const params = {
format,
categories,
engines,
language,
pageno,
time_range,
safesearch
}

const headers = {}

const tool = new SearxngSearch({
apiBase,
params,
headers
})

return tool
}
}

module.exports = { nodeClass: Searxng_Tools }
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flowise-components",
"version": "1.8.2",
"version": "1.8.3",
"description": "Flowiseai Components",
"main": "dist/src/index",
"types": "dist/src/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flowise",
"version": "1.8.1",
"version": "1.8.2",
"description": "Flowiseai Server",
"main": "dist/index",
"types": "dist/index.d.ts",
Expand Down
7 changes: 6 additions & 1 deletion packages/server/src/services/documentstore/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,12 @@ const _saveChunksToStorage = async (data: IDocumentStoreLoaderForPreview, entity
await appServer.AppDataSource.getRepository(DocumentStoreFileChunk).delete({ docId: newLoaderId })
if (response.chunks) {
//step 8: now save the new chunks
const totalChars = response.chunks.reduce((acc: number, chunk) => acc + chunk.pageContent.length, 0)
const totalChars = response.chunks.reduce((acc, chunk) => {
if (chunk.pageContent) {
return acc + chunk.pageContent.length
}
return acc
}, 0)
response.chunks.map(async (chunk: IDocument, index: number) => {
const docChunk: DocumentStoreFileChunk = {
docId: newLoaderId,
Expand Down
3 changes: 2 additions & 1 deletion packages/server/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,8 @@ export const isFlowValidForStream = (reactFlowNodes: IReactFlowNode[], endingNod
'chatCohere',
'chatGoogleGenerativeAI',
'chatTogetherAI',
'chatTogetherAI_LlamaIndex'
'chatTogetherAI_LlamaIndex',
'chatFireworks'
],
LLMs: ['azureOpenAI', 'openAI', 'ollama']
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flowise-ui",
"version": "1.8.1",
"version": "1.8.2",
"license": "SEE LICENSE IN LICENSE.md",
"homepage": "https://flowiseai.com",
"author": {
Expand Down

0 comments on commit 3591b72

Please sign in to comment.