mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
add groq
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
import { INodeParams, INodeCredential } from '../src/Interface'
|
||||||
|
|
||||||
|
class GroqApi implements INodeCredential {
|
||||||
|
label: string
|
||||||
|
name: string
|
||||||
|
version: number
|
||||||
|
inputs: INodeParams[]
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.label = 'Groq API'
|
||||||
|
this.name = 'groqApi'
|
||||||
|
this.version = 1.0
|
||||||
|
this.inputs = [
|
||||||
|
{
|
||||||
|
label: 'Groq Api Key',
|
||||||
|
name: 'groqApiKey',
|
||||||
|
type: 'password'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { credClass: GroqApi }
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
import { BaseCache } from '@langchain/core/caches'
|
||||||
|
import { ChatGroq, ChatGroqInput } from '@langchain/groq'
|
||||||
|
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||||
|
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
|
|
||||||
|
class Groq_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 = 'GroqChat'
|
||||||
|
this.name = 'groqChat'
|
||||||
|
this.version = 2.0
|
||||||
|
this.type = 'GroqChat'
|
||||||
|
this.icon = 'groq.png'
|
||||||
|
this.category = 'Chat Models'
|
||||||
|
this.description = 'Wrapper around Groq API with LPU Inference Engine'
|
||||||
|
this.baseClasses = [this.type, ...getBaseClasses(ChatGroq)]
|
||||||
|
this.credential = {
|
||||||
|
label: 'Connect Credential',
|
||||||
|
name: 'credential',
|
||||||
|
type: 'credential',
|
||||||
|
credentialNames: ['groqApi'],
|
||||||
|
optional: true
|
||||||
|
}
|
||||||
|
this.inputs = [
|
||||||
|
{
|
||||||
|
label: 'Cache',
|
||||||
|
name: 'cache',
|
||||||
|
type: 'BaseCache',
|
||||||
|
optional: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Model Name',
|
||||||
|
name: 'modelName',
|
||||||
|
type: 'string',
|
||||||
|
placeholder: 'ft:gpt-3.5-turbo:my-org:custom_suffix:id'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Temperature',
|
||||||
|
name: 'temperature',
|
||||||
|
type: 'number',
|
||||||
|
step: 0.1,
|
||||||
|
default: 0.9,
|
||||||
|
optional: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
async init(nodeData: INodeData, _: string, options: ICommonObject): Promise<any> {
|
||||||
|
const modelName = nodeData.inputs?.modelName as string
|
||||||
|
const cache = nodeData.inputs?.cache as BaseCache
|
||||||
|
const temperature = nodeData.inputs?.temperature as string
|
||||||
|
const streaming = nodeData.inputs?.streaming as boolean
|
||||||
|
|
||||||
|
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||||
|
const groqApiKey = getCredentialParam('groqApiKey', credentialData, nodeData)
|
||||||
|
|
||||||
|
const obj: ChatGroqInput = {
|
||||||
|
modelName,
|
||||||
|
temperature: parseFloat(temperature),
|
||||||
|
apiKey: groqApiKey,
|
||||||
|
streaming: streaming ?? true
|
||||||
|
}
|
||||||
|
if (cache) obj.cache = cache
|
||||||
|
|
||||||
|
const model = new ChatGroq(obj)
|
||||||
|
return model
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { nodeClass: Groq_ChatModels }
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -33,6 +33,7 @@
|
|||||||
"@langchain/cohere": "^0.0.5",
|
"@langchain/cohere": "^0.0.5",
|
||||||
"@langchain/community": "^0.0.30",
|
"@langchain/community": "^0.0.30",
|
||||||
"@langchain/google-genai": "^0.0.10",
|
"@langchain/google-genai": "^0.0.10",
|
||||||
|
"@langchain/groq": "^0.0.2",
|
||||||
"@langchain/mistralai": "^0.0.7",
|
"@langchain/mistralai": "^0.0.7",
|
||||||
"@langchain/openai": "^0.0.14",
|
"@langchain/openai": "^0.0.14",
|
||||||
"@langchain/pinecone": "^0.0.3",
|
"@langchain/pinecone": "^0.0.3",
|
||||||
|
|||||||
@@ -855,7 +855,8 @@ export const isFlowValidForStream = (reactFlowNodes: IReactFlowNode[], endingNod
|
|||||||
'chatAnthropic_LlamaIndex',
|
'chatAnthropic_LlamaIndex',
|
||||||
'chatOllama',
|
'chatOllama',
|
||||||
'awsChatBedrock',
|
'awsChatBedrock',
|
||||||
'chatMistralAI'
|
'chatMistralAI',
|
||||||
|
'groqChat'
|
||||||
],
|
],
|
||||||
LLMs: ['azureOpenAI', 'openAI', 'ollama']
|
LLMs: ['azureOpenAI', 'openAI', 'ollama']
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user