Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
birksy89 committed Oct 30, 2024
2 parents e72a069 + ebc4641 commit dfaf8c6
Show file tree
Hide file tree
Showing 14 changed files with 579 additions and 260 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Download and Install [NodeJS](https://nodejs.org/en/download) >= 18.15.0
## 🐳 Docker

### Docker Compose

1. Clone the Flowise project
2. Go to `docker` folder at the root of the project
3. Copy `.env.example` file, paste it into the same location, and rename to `.env`
Expand Down
25 changes: 25 additions & 0 deletions packages/components/credentials/CerebrasApi.credential.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { INodeParams, INodeCredential } from '../src/Interface'

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

constructor() {
this.label = 'Cerebras API Key'
this.name = 'cerebrasAIApi'
this.version = 1.0
this.inputs = [
{
label: 'Cerebras API Key',
name: 'cerebrasApiKey',
type: 'password',
description: 'API Key (cloud.cerebras.ai)'
}
]
}
}

module.exports = { credClass: CerebrasAPIAuth }
5 changes: 0 additions & 5 deletions packages/components/credentials/CouchbaseApi.credential.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Temporary disabled due to the incompatibility with the docker node-alpine:
* https://github.com/FlowiseAI/Flowise/pull/2303
import { INodeParams, INodeCredential } from '../src/Interface'

class CouchbaseApi implements INodeCredential {
Expand Down Expand Up @@ -36,4 +32,3 @@ class CouchbaseApi implements INodeCredential {
}

module.exports = { credClass: CouchbaseApi }
*/
10 changes: 10 additions & 0 deletions packages/components/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -1188,6 +1188,16 @@
{
"name": "voyageAIEmbeddings",
"models": [
{
"label": "voyage-3",
"name": "voyage-3",
"description": "High-performance embedding model with excellent retrieval quality, 32K token context, and 1024 dimension size."
},
{
"label": "voyage-3-lite",
"name": "voyage-3-lite",
"description": "Lightweight embedding model optimized for low latency and cost, 32K token context, and 512 dimension size."
},
{
"label": "voyage-2",
"name": "voyage-2",
Expand Down
237 changes: 147 additions & 90 deletions packages/components/nodes/agents/OpenAIAssistant/OpenAIAssistant.ts

Large diffs are not rendered by default.

161 changes: 161 additions & 0 deletions packages/components/nodes/chatmodels/ChatCerebras/ChatCerebras.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
import { ChatOpenAI, OpenAIChatInput } from '@langchain/openai'
import { BaseCache } from '@langchain/core/caches'
import { BaseLLMParams } from '@langchain/core/language_models/llms'
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'

class ChatCerebras_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 = 'ChatCerebras'
this.name = 'chatCerebras'
this.version = 1.0
this.type = 'ChatCerebras'
this.icon = 'cerebras.png'
this.category = 'Chat Models'
this.description = 'Models available via Cerebras'
this.baseClasses = [this.type, ...getBaseClasses(ChatOpenAI)]
this.credential = {
label: 'Connect Credential',
name: 'credential',
type: 'credential',
credentialNames: ['cerebrasAIApi'],
optional: true
}
this.inputs = [
{
label: 'Cache',
name: 'cache',
type: 'BaseCache',
optional: true
},
{
label: 'Model Name',
name: 'modelName',
type: 'string',
placeholder: 'llama3.1-8b'
},
{
label: 'Temperature',
name: 'temperature',
type: 'number',
step: 0.1,
default: 0.9,
optional: true
},
{
label: 'Max Tokens',
name: 'maxTokens',
type: 'number',
step: 1,
optional: true,
additionalParams: true
},
{
label: 'Top Probability',
name: 'topP',
type: 'number',
step: 0.1,
optional: true,
additionalParams: true
},
{
label: 'Frequency Penalty',
name: 'frequencyPenalty',
type: 'number',
step: 0.1,
optional: true,
additionalParams: true
},
{
label: 'Presence Penalty',
name: 'presencePenalty',
type: 'number',
step: 0.1,
optional: true,
additionalParams: true
},
{
label: 'Timeout',
name: 'timeout',
type: 'number',
step: 1,
optional: true,
additionalParams: true
},
{
label: 'BasePath',
name: 'basepath',
type: 'string',
optional: true,
default: 'https://api.cerebras.ai/v1',
additionalParams: true
},
{
label: 'BaseOptions',
name: 'baseOptions',
type: 'json',
optional: true,
additionalParams: true
}
]
}

async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
const temperature = nodeData.inputs?.temperature as string
const modelName = nodeData.inputs?.modelName as string
const maxTokens = nodeData.inputs?.maxTokens as string
const topP = nodeData.inputs?.topP as string
const frequencyPenalty = nodeData.inputs?.frequencyPenalty as string
const presencePenalty = nodeData.inputs?.presencePenalty as string
const timeout = nodeData.inputs?.timeout as string
const streaming = nodeData.inputs?.streaming as boolean
const basePath = nodeData.inputs?.basepath as string
const baseOptions = nodeData.inputs?.baseOptions
const cache = nodeData.inputs?.cache as BaseCache

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

const obj: Partial<OpenAIChatInput> & BaseLLMParams & { cerebrasAIApiKey?: string } = {
temperature: parseFloat(temperature),
modelName,
openAIApiKey: cerebrasAIApiKey,
streaming: streaming ?? true
}

if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
if (topP) obj.topP = parseFloat(topP)
if (frequencyPenalty) obj.frequencyPenalty = parseFloat(frequencyPenalty)
if (presencePenalty) obj.presencePenalty = parseFloat(presencePenalty)
if (timeout) obj.timeout = parseInt(timeout, 10)
if (cache) obj.cache = cache

let parsedBaseOptions: any | undefined = undefined

if (baseOptions) {
try {
parsedBaseOptions = typeof baseOptions === 'object' ? baseOptions : JSON.parse(baseOptions)
} catch (exception) {
throw new Error("Invalid JSON in the ChatCerebras's BaseOptions: " + exception)
}
}
const model = new ChatOpenAI(obj, {
basePath,
baseOptions: parsedBaseOptions
})
return model
}
}

module.exports = { nodeClass: ChatCerebras_ChatModels }
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ baseUrl
```json
{
"config_id": "bedrock",
"messages": [{
"role":"user",
"content":"Hello! What can you do for me?"
}]
"messages": [
{
"role": "user",
"content": "Hello! What can you do for me?"
}
]
}
```
```
5 changes: 0 additions & 5 deletions packages/components/nodes/vectorstores/Couchbase/Couchbase.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* Temporary disabled due to the incompatibility with the docker node-alpine:
* https://github.com/FlowiseAI/Flowise/pull/2303
import { flatten } from 'lodash'
import { Embeddings } from '@langchain/core/embeddings'
import { Document } from '@langchain/core/documents'
Expand Down Expand Up @@ -231,4 +227,3 @@ class Couchbase_VectorStores implements INode {
}

module.exports = { nodeClass: Couchbase_VectorStores }
*/
1 change: 1 addition & 0 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"assemblyai": "^4.2.2",
"axios": "1.6.2",
"cheerio": "^1.0.0-rc.12",
"couchbase": "4.4.1",
"chromadb": "^1.5.11",
"cohere-ai": "^7.7.5",
"crypto-js": "^4.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { MigrationInterface, QueryRunner } from 'typeorm'

export class AddVectorStoreConfigToDocStore1715861032479 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const columnExists = await queryRunner.hasColumn('document_store', 'vectorStoreConfig')
if (!columnExists) {
await queryRunner.query(`ALTER TABLE \`document_store\` ADD COLUMN \`vectorStoreConfig\` TEXT;`)
await queryRunner.query(`ALTER TABLE \`document_store\` ADD COLUMN \`embeddingConfig\` TEXT;`)
await queryRunner.query(`ALTER TABLE \`document_store\` ADD COLUMN \`recordManagerConfig\` TEXT;`)
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`document_store\` DROP COLUMN \`vectorStoreConfig\`;`)
await queryRunner.query(`ALTER TABLE \`document_store\` DROP COLUMN \`embeddingConfig\`;`)
await queryRunner.query(`ALTER TABLE \`document_store\` DROP COLUMN \`recordManagerConfig\`;`)
}
}
2 changes: 2 additions & 0 deletions packages/server/src/database/migrations/mariadb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { AddFeedback1707213626553 } from './1707213626553-AddFeedback'
import { AddUpsertHistoryEntity1709814301358 } from './1709814301358-AddUpsertHistoryEntity'
import { AddLead1710832127079 } from './1710832127079-AddLead'
import { AddLeadToChatMessage1711538023578 } from './1711538023578-AddLeadToChatMessage'
import { AddVectorStoreConfigToDocStore1715861032479 } from './1715861032479-AddVectorStoreConfigToDocStore'
import { AddDocumentStore1711637331047 } from './1711637331047-AddDocumentStore'
import { AddAgentReasoningToChatMessage1714679514451 } from './1714679514451-AddAgentReasoningToChatMessage'
import { AddTypeToChatFlow1716300000000 } from './1716300000000-AddTypeToChatFlow'
Expand Down Expand Up @@ -50,6 +51,7 @@ export const mariadbMigrations = [
AddLeadToChatMessage1711538023578,
AddAgentReasoningToChatMessage1714679514451,
AddTypeToChatFlow1716300000000,
AddVectorStoreConfigToDocStore1715861032479,
AddApiKey1720230151480,
AddActionToChatMessage1721078251523,
LongTextColumn1722301395521,
Expand Down
10 changes: 5 additions & 5 deletions packages/ui/src/views/canvas/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
}

.chatflow-canvas .react-flow__handle-connecting {
cursor: not-allowed;
background: #db4e4e !important;
cursor: not-allowed;
background: #db4e4e !important;
}

.chatflow-canvas .react-flow__handle-valid {
cursor: crosshair;
background: #5dba62 !important;
}
cursor: crosshair;
background: #5dba62 !important;
}
Loading

0 comments on commit dfaf8c6

Please sign in to comment.