mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 19:00:59 +03:00
Feat/update ollama for function calling (#2892)
update ollama for function calling
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { ChatOllama } from '@langchain/community/chat_models/ollama'
|
||||
import { ChatOllama, ChatOllamaInput } from '@langchain/ollama'
|
||||
import { BaseChatModelParams } from '@langchain/core/language_models/chat_models'
|
||||
import { BaseCache } from '@langchain/core/caches'
|
||||
import { INode, INodeData, INodeParams } from '../../../src/Interface'
|
||||
import { getBaseClasses } from '../../../src/utils'
|
||||
import { OllamaInput } from '@langchain/community/llms/ollama'
|
||||
import { BaseChatModelParams } from '@langchain/core/language_models/chat_models'
|
||||
|
||||
class ChatOllama_ChatModels implements INode {
|
||||
label: string
|
||||
@@ -20,7 +19,7 @@ class ChatOllama_ChatModels implements INode {
|
||||
constructor() {
|
||||
this.label = 'ChatOllama'
|
||||
this.name = 'chatOllama'
|
||||
this.version = 2.0
|
||||
this.version = 3.0
|
||||
this.type = 'ChatOllama'
|
||||
this.icon = 'Ollama.svg'
|
||||
this.category = 'Chat Models'
|
||||
@@ -55,6 +54,15 @@ class ChatOllama_ChatModels implements INode {
|
||||
default: 0.9,
|
||||
optional: true
|
||||
},
|
||||
{
|
||||
label: 'Keep Alive',
|
||||
name: 'keepAlive',
|
||||
type: 'string',
|
||||
description: 'How long to keep connection alive. A duration string (such as "10m" or "24h")',
|
||||
default: '5m',
|
||||
optional: true,
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'Top P',
|
||||
name: 'topP',
|
||||
@@ -115,16 +123,6 @@ class ChatOllama_ChatModels implements INode {
|
||||
optional: true,
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'Number of GQA groups',
|
||||
name: 'numGqa',
|
||||
type: 'number',
|
||||
description:
|
||||
'The number of GQA groups in the transformer layer. Required for some models, for example it is 8 for llama2:70b. Refer to <a target="_blank" href="https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values">docs</a> for more details',
|
||||
step: 1,
|
||||
optional: true,
|
||||
additionalParams: true
|
||||
},
|
||||
{
|
||||
label: 'Number of GPU',
|
||||
name: 'numGpu',
|
||||
@@ -199,17 +197,16 @@ class ChatOllama_ChatModels implements INode {
|
||||
const mirostatEta = nodeData.inputs?.mirostatEta as string
|
||||
const mirostatTau = nodeData.inputs?.mirostatTau as string
|
||||
const numCtx = nodeData.inputs?.numCtx as string
|
||||
const numGqa = nodeData.inputs?.numGqa as string
|
||||
const keepAlive = nodeData.inputs?.keepAlive as string
|
||||
const numGpu = nodeData.inputs?.numGpu as string
|
||||
const numThread = nodeData.inputs?.numThread as string
|
||||
const repeatLastN = nodeData.inputs?.repeatLastN as string
|
||||
const repeatPenalty = nodeData.inputs?.repeatPenalty as string
|
||||
const stop = nodeData.inputs?.stop as string
|
||||
const tfsZ = nodeData.inputs?.tfsZ as string
|
||||
|
||||
const cache = nodeData.inputs?.cache as BaseCache
|
||||
|
||||
const obj: OllamaInput & BaseChatModelParams = {
|
||||
const obj: ChatOllamaInput & BaseChatModelParams = {
|
||||
baseUrl,
|
||||
temperature: parseFloat(temperature),
|
||||
model: modelName
|
||||
@@ -221,16 +218,12 @@ class ChatOllama_ChatModels implements INode {
|
||||
if (mirostatEta) obj.mirostatEta = parseFloat(mirostatEta)
|
||||
if (mirostatTau) obj.mirostatTau = parseFloat(mirostatTau)
|
||||
if (numCtx) obj.numCtx = parseFloat(numCtx)
|
||||
if (numGqa) obj.numGqa = parseFloat(numGqa)
|
||||
if (numGpu) obj.numGpu = parseFloat(numGpu)
|
||||
if (numThread) obj.numThread = parseFloat(numThread)
|
||||
if (repeatLastN) obj.repeatLastN = parseFloat(repeatLastN)
|
||||
if (repeatPenalty) obj.repeatPenalty = parseFloat(repeatPenalty)
|
||||
if (tfsZ) obj.tfsZ = parseFloat(tfsZ)
|
||||
if (stop) {
|
||||
const stopSequences = stop.split(',')
|
||||
obj.stop = stopSequences
|
||||
}
|
||||
if (keepAlive) obj.keepAlive = keepAlive
|
||||
if (cache) obj.cache = cache
|
||||
|
||||
const model = new ChatOllama(obj)
|
||||
|
||||
Reference in New Issue
Block a user