mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
Addition of Cache Option for Chat Models
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { NIBittensorChatModel, BittensorInput } from 'langchain/experimental/chat_models/bittensor'
|
||||
import { BaseCache } from 'langchain/schema'
|
||||
|
||||
class Bittensor_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -16,13 +17,19 @@ class Bittensor_ChatModels implements INode {
|
||||
constructor() {
|
||||
this.label = 'NIBittensorChat'
|
||||
this.name = 'NIBittensorChatModel'
|
||||
this.version = 1.0
|
||||
this.version = 2.0
|
||||
this.type = 'BittensorChat'
|
||||
this.icon = 'logo.png'
|
||||
this.category = 'Chat Models'
|
||||
this.description = 'Wrapper around Bittensor subnet 1 large language models'
|
||||
this.baseClasses = [this.type, ...getBaseClasses(NIBittensorChatModel)]
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Cache',
|
||||
name: 'cache',
|
||||
type: 'LLMCache',
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'System prompt',
|
||||
name: 'system_prompt',
|
||||
@@ -35,9 +42,13 @@ class Bittensor_ChatModels implements INode {
|
||||
|
||||
async init(nodeData: INodeData, _: string): Promise<any> {
|
||||
const system_prompt = nodeData.inputs?.system_prompt as string
|
||||
const cache = nodeData.inputs?.llmCache as BaseCache
|
||||
|
||||
const obj: Partial<BittensorInput> = {
|
||||
systemPrompt: system_prompt
|
||||
}
|
||||
if (cache) obj.cache = cache
|
||||
|
||||
const model = new NIBittensorChatModel(obj)
|
||||
return model
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user