mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 17:01:00 +03:00
Extending support for Caching to all LLM's.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { Cohere, CohereInput } from './core'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class Cohere_LLMs implements INode {
|
||||
label: string
|
||||
@@ -17,7 +18,7 @@ class Cohere_LLMs implements INode {
|
||||
constructor() {
|
||||
this.label = 'Cohere'
|
||||
this.name = 'cohere'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'Cohere'
|
||||
this.icon = 'cohere.png'
|
||||
this.category = 'LLMs'
|
||||
@@ -30,6 +31,12 @@ class Cohere_LLMs implements INode {
|
||||
credentialNames: ['cohereApi']
|
||||
}
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Cache',
|
||||
name: 'llmCache',
|
||||
type: 'LLMCache',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Model Name',
|
||||
name: 'modelName',
|
||||
@@ -85,7 +92,7 @@ class Cohere_LLMs implements INode {
|
||||
const temperature = nodeData.inputs?.temperature as string
|
||||
const modelName = nodeData.inputs?.modelName as string
|
||||
const maxTokens = nodeData.inputs?.maxTokens as string
|
||||
|
||||
const llmCache = nodeData.inputs?.llmCache as BaseCache
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const cohereApiKey = getCredentialParam('cohereApiKey', credentialData, nodeData)
|
||||
|
||||
@@ -96,7 +103,7 @@ class Cohere_LLMs implements INode {
|
||||
if (maxTokens) obj.maxTokens = parseInt(maxTokens, 10)
|
||||
if (modelName) obj.model = modelName
|
||||
if (temperature) obj.temperature = parseFloat(temperature)
|
||||
|
||||
if (llmCache) obj.cache = llmCache
|
||||
const model = new Cohere(obj)
|
||||
return model
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user