mirror of
https://github.com/run-llama/LlamaIndexTS.git
synced 2026-08-26 12:24:44 -04:00
fix: passing right llm setting from SimpleChatEngine to ChatMemoryBuffer (#1798)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@llamaindex/core": patch
|
||||
---
|
||||
|
||||
Fix passing right llm setting from SimpleChatEngine to ChatMemoryBuffer
|
||||
@@ -24,8 +24,12 @@ export class SimpleChatEngine implements BaseChatEngine {
|
||||
}
|
||||
|
||||
constructor(init?: Partial<SimpleChatEngine>) {
|
||||
this.memory = init?.memory ?? new ChatMemoryBuffer();
|
||||
this.llm = init?.llm ?? Settings.llm;
|
||||
this.memory =
|
||||
init?.memory ??
|
||||
new ChatMemoryBuffer({
|
||||
llm: this.llm,
|
||||
});
|
||||
}
|
||||
|
||||
chat(params: NonStreamingChatEngineParams): Promise<EngineResponse>;
|
||||
@@ -40,6 +44,7 @@ export class SimpleChatEngine implements BaseChatEngine {
|
||||
|
||||
const chatHistory = params.chatHistory
|
||||
? new ChatMemoryBuffer({
|
||||
llm: this.llm,
|
||||
chatHistory:
|
||||
params.chatHistory instanceof BaseMemory
|
||||
? await params.chatHistory.getMessages()
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { SimpleChatEngine } from "@llamaindex/core/chat-engine";
|
||||
import { ChatMemoryBuffer } from "@llamaindex/core/memory";
|
||||
import { MockLLM } from "@llamaindex/core/utils";
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
describe("SimpleChatEngine", () => {
|
||||
test("constructor initializes with provided LLM", () => {
|
||||
const llm = new MockLLM();
|
||||
const engine = new SimpleChatEngine({ llm });
|
||||
expect(engine.llm).toBe(llm);
|
||||
expect(engine.memory).toBeInstanceOf(ChatMemoryBuffer);
|
||||
expect((engine.memory as ChatMemoryBuffer).tokenLimit).toBe(768);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user