mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
Addition of Cache Option for Chat Models
This commit is contained in:
@@ -2,6 +2,7 @@ import { ICommonObject, INode, INodeData, INodeParams } from '../../../src/Inter
|
||||
import { getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||
import { ChatGoogleVertexAI, GoogleVertexAIChatInput } from 'langchain/chat_models/googlevertexai'
|
||||
import { GoogleAuthOptions } from 'google-auth-library'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class GoogleVertexAI_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -18,7 +19,7 @@ class GoogleVertexAI_ChatModels implements INode {
|
||||
constructor() {
|
||||
this.label = 'ChatGoogleVertexAI'
|
||||
this.name = 'chatGoogleVertexAI'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'ChatGoogleVertexAI'
|
||||
this.icon = 'vertexai.svg'
|
||||
this.category = 'Chat Models'
|
||||
@@ -34,6 +35,12 @@ class GoogleVertexAI_ChatModels implements INode {
|
||||
'Google Vertex AI credential. If you are using a GCP service like Cloud Run, or if you have installed default credentials on your local machine, you do not need to set this credential.'
|
||||
}
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Cache',
|
||||
name: 'cache',
|
||||
type: 'LLMCache',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Model Name',
|
||||
name: 'modelName',
|
||||
@@ -113,6 +120,7 @@ class GoogleVertexAI_ChatModels implements INode {
|
||||
const modelName = nodeData.inputs?.modelName as string
|
||||
const maxOutputTokens = nodeData.inputs?.maxOutputTokens as string
|
||||
const topP = nodeData.inputs?.topP as string
|
||||
const cache = nodeData.inputs?.llmCache as BaseCache
|
||||
|
||||
const obj: GoogleVertexAIChatInput<GoogleAuthOptions> = {
|
||||
temperature: parseFloat(temperature),
|
||||
@@ -122,6 +130,7 @@ class GoogleVertexAI_ChatModels implements INode {
|
||||
|
||||
if (maxOutputTokens) obj.maxOutputTokens = parseInt(maxOutputTokens, 10)
|
||||
if (topP) obj.topP = parseFloat(topP)
|
||||
if (cache) obj.cache = cache
|
||||
|
||||
const model = new ChatGoogleVertexAI(obj)
|
||||
return model
|
||||
|
||||
Reference in New Issue
Block a user