Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@
"onlyBuiltDependencies": [
"faiss-node",
"sqlite3"
]
],
"overrides": {
"@langchain/core": "0.2.18"
}
},
"engines": {
"node": ">=18.15.0 <19.0.0 || ^20",
Expand Down
37 changes: 15 additions & 22 deletions packages/components/nodes/chatmodels/ChatOllama/ChatOllama.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ChatOllamaFunction_ChatModels implements INode {
this.type = 'ChatOllamaFunction'
this.icon = 'Ollama.svg'
this.category = 'Chat Models'
this.badge = 'DEPRECATING'
this.description = 'Run open-source function-calling compatible LLM on Ollama'
this.baseClasses = [this.type, ...getBaseClasses(OllamaFunctions)]
this.inputs = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ const initializeMongoDB = async (nodeData: INodeData, options: ICommonObject): P
sessionId
})

// @ts-ignore
mongoDBChatMessageHistory.getMessages = async (): Promise<BaseMessage[]> => {
const document = await collection.findOne({
sessionId: (mongoDBChatMessageHistory as any).sessionId
Expand All @@ -119,6 +120,7 @@ const initializeMongoDB = async (nodeData: INodeData, options: ICommonObject): P
return messages.map(mapStoredMessageToChatMessage)
}

// @ts-ignore
mongoDBChatMessageHistory.addMessage = async (message: BaseMessage): Promise<void> => {
const messages = [message].map((msg) => msg.toDict())
await collection.updateOne(
Expand All @@ -136,6 +138,7 @@ const initializeMongoDB = async (nodeData: INodeData, options: ICommonObject): P

return new BufferMemoryExtended({
memoryKey: memoryKey ?? 'chat_history',
// @ts-ignore
chatHistory: mongoDBChatMessageHistory,
sessionId,
collection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ class StructuredOutputParser implements INode {
const autoFix = nodeData.inputs?.autofixParser as boolean

try {
const structuredOutputParser = LangchainStructuredOutputParser.fromZodSchema(z.object(convertSchemaToZod(jsonStructure)))
const zodSchema = z.object(convertSchemaToZod(jsonStructure)) as any
const structuredOutputParser = LangchainStructuredOutputParser.fromZodSchema(zodSchema)

// NOTE: When we change Flowise to return a json response, the following has to be changed to: JsonStructuredOutputParser
Object.defineProperty(structuredOutputParser, 'autoFix', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ChatflowTool extends StructuredTool {

schema = z.object({
input: z.string().describe('input question')
})
}) as any

constructor({
name,
Expand Down
1 change: 1 addition & 0 deletions packages/components/nodes/tools/CustomTool/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class DynamicStructuredTool<

func: DynamicStructuredToolInput['func']

// @ts-ignore
schema: T
private variables: any[]
private flowObj: any
Expand Down
2 changes: 1 addition & 1 deletion packages/components/nodes/tools/ReadFile/ReadFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class ReadFileTool extends StructuredTool {

schema = z.object({
file_path: z.string().describe('name of file')
})
}) as any

name = 'read_file'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class Retriever_Tools implements INode {

const schema = z.object({
input: z.string().describe('input to look up in retriever')
})
}) as any

const tool = new DynamicStructuredTool({ ...input, func, schema })
return tool
Expand Down
2 changes: 1 addition & 1 deletion packages/components/nodes/tools/WriteFile/WriteFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class WriteFileTool extends StructuredTool {
schema = z.object({
file_path: z.string().describe('name of file'),
text: z.string().describe('text to write to file')
})
}) as any

name = 'write_file'

Expand Down
4 changes: 2 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
"@langchain/anthropic": "^0.2.1",
"@langchain/cohere": "^0.0.7",
"@langchain/community": "^0.2.17",
"@langchain/core": "^0.2.14",
"@langchain/exa": "^0.0.5",
"@langchain/google-genai": "^0.0.22",
"@langchain/google-vertexai": "^0.0.19",
"@langchain/groq": "^0.0.8",
"@langchain/langgraph": "^0.0.22",
"@langchain/mistralai": "^0.0.26",
"@langchain/mongodb": "^0.0.1",
"@langchain/ollama": "^0.0.2",
"@langchain/openai": "^0.0.30",
"@langchain/pinecone": "^0.0.3",
"@langchain/qdrant": "^0.0.5",
Expand Down Expand Up @@ -82,7 +82,7 @@
"ioredis": "^5.3.2",
"jsdom": "^22.1.0",
"jsonpointer": "^5.0.1",
"langchain": "^0.2.8",
"langchain": "^0.2.11",
"langfuse": "3.3.4",
"langfuse-langchain": "^3.3.4",
"langsmith": "0.1.6",
Expand Down
Loading