From cce3b792db017d550e10fdde1aa9e5e018505cbb Mon Sep 17 00:00:00 2001
From: Alex Yang <himself65@outlook.com>
Date: Mon, 22 Jan 2024 22:36:40 -0600
Subject: [PATCH] revert: missing files (#421)

---
 examples/chatHistory.ts    | 32 ++++++++++++++++++++++++++++++++
 packages/core/package.json |  5 -----
 2 files changed, 32 insertions(+), 5 deletions(-)
 create mode 100644 examples/chatHistory.ts

diff --git a/examples/chatHistory.ts b/examples/chatHistory.ts
new file mode 100644
index 000000000..7ed93471d
--- /dev/null
+++ b/examples/chatHistory.ts
@@ -0,0 +1,32 @@
+import { stdin as input, stdout as output } from "node:process";
+import readline from "node:readline/promises";
+
+import { OpenAI, SimpleChatEngine, SummaryChatHistory } from "llamaindex";
+
+async function main() {
+  // Set maxTokens to 75% of the context window size of 4096
+  // This will trigger the summarizer once the chat history reaches 25% of the context window size (1024 tokens)
+  const llm = new OpenAI({ model: "gpt-3.5-turbo", maxTokens: 4096 * 0.75 });
+  const chatHistory = new SummaryChatHistory({ llm });
+  const chatEngine = new SimpleChatEngine({ llm });
+  const rl = readline.createInterface({ input, output });
+
+  while (true) {
+    const query = await rl.question("Query: ");
+    const stream = await chatEngine.chat({
+      message: query,
+      chatHistory,
+      stream: true,
+    });
+    if (chatHistory.getLastSummary()) {
+      // Print the summary of the conversation so far that is produced by the SummaryChatHistory
+      console.log(`Summary: ${chatHistory.getLastSummary()?.content}`);
+    }
+    for await (const chunk of stream) {
+      process.stdout.write(chunk.response);
+    }
+    console.log();
+  }
+}
+
+main().catch(console.error);
diff --git a/packages/core/package.json b/packages/core/package.json
index cd99db443..66a9ec896 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -58,11 +58,6 @@
       "import": "./dist/storage/FileSystem.mjs",
       "require": "./dist/storage/FileSystem.js"
     },
-    "./ChatEngine": {
-      "types": "./dist/ChatEngine.d.mts",
-      "import": "./dist/ChatEngine.mjs",
-      "require": "./dist/ChatEngine.js"
-    },
     "./ChatHistory": {
       "types": "./dist/ChatHistory.d.mts",
       "import": "./dist/ChatHistory.mjs",
-- 
GitLab