From 53ce08bcfeec49a941759c2f1b55a85d195f4e93 Mon Sep 17 00:00:00 2001 From: Ahmad Barqawi Date: Sun, 10 Sep 2023 14:22:00 +0100 Subject: [PATCH 1/2] Upgrade npm release --- IntelliNode/README.md | 7 +++---- IntelliNode/package.json | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/IntelliNode/README.md b/IntelliNode/README.md index 824d62b..19bc0fa 100644 --- a/IntelliNode/README.md +++ b/IntelliNode/README.md @@ -19,14 +19,13 @@ IntelliNode is the ultimate tool to integrate with the latest language models and deep learning frameworks using **javascript**. The library provides intuitive functions for sending input to models like ChatGPT, WaveNet and Stable diffusion, and receiving generated text, speech, or images. With just a few lines of code, you can easily access the power of cutting-edge AI models to enhance your projects. # Latest Updates +- Add a chat context function to manage the relevant messages for chatbots. - Update the chatbot to support Llama v2 chat and code. 🦙 -- Add Gen function, the fastest way to generate text, speech, web pages or images. :bullettrain_side: -- Update stable diffusion to use XL model engine. +- Add Gen function, the fastest way to generate text, speech, code, or images. :bullettrain_side: +- Update stable diffusion to use the XL model engine. - Add support for hugging face inference. - Generate prompt using LLM. - Add support for huge data memory semantic search using `SemanticSearchPaging`. -- Update the chatbot with `stream` function. -- Update the module to support next integration. Join the [discord server](https://discord.gg/VYgCh2p3Ww) for the latest updates and community support. diff --git a/IntelliNode/package.json b/IntelliNode/package.json index 3ce81bb..eaed0d9 100644 --- a/IntelliNode/package.json +++ b/IntelliNode/package.json @@ -1,6 +1,6 @@ { "name": "intellinode", - "version": "1.4.0", + "version": "1.4.1", "description": "Access various AI models, such as ChatGPT, Llama, Diffusion, Cohere, Hugging face, and others", "main": "index.js", "keywords": [ From 9efc859633f44f5112f34fdd4eaa86420e61eba3 Mon Sep 17 00:00:00 2001 From: Ahmad Barqawi Date: Sun, 10 Sep 2023 19:35:48 +0100 Subject: [PATCH 2/2] update the sample --- samples/command_sample/package-lock.json | 8 ++-- samples/command_sample/package.json | 2 +- samples/command_sample/test_chat_context.js | 49 +++++++++++++++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 samples/command_sample/test_chat_context.js diff --git a/samples/command_sample/package-lock.json b/samples/command_sample/package-lock.json index 532287e..37e9dab 100644 --- a/samples/command_sample/package-lock.json +++ b/samples/command_sample/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@aws-sdk/client-s3": "^3.363.0", "dotenv": "^16.0.3", - "intellinode": "^1.4.0" + "intellinode": "^1.4.1" } }, "node_modules/@aws-crypto/crc32": { @@ -1431,9 +1431,9 @@ } }, "node_modules/intellinode": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/intellinode/-/intellinode-1.4.0.tgz", - "integrity": "sha512-/FSkV8+55wm6BYLJ88/fm03eK88gm506K17Iq2kCHPt1PdK1QM10a3shJXdzpsx3hujQaDEgWP6QQFyAOgGekw==", + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/intellinode/-/intellinode-1.4.1.tgz", + "integrity": "sha512-RTw8F4/7zwbaKUkBVWvV1q+4vPLDCJhVOxEXMeb+zqZtOrS9IfRTkPyV3Dqwazkmz+xBDYtTwqqTpb1LkgbKig==", "dependencies": { "axios": "^1.3.6", "dotenv": "^16.0.3", diff --git a/samples/command_sample/package.json b/samples/command_sample/package.json index b7cf0bb..1e56db8 100644 --- a/samples/command_sample/package.json +++ b/samples/command_sample/package.json @@ -22,6 +22,6 @@ "dependencies": { "@aws-sdk/client-s3": "^3.363.0", "dotenv": "^16.0.3", - "intellinode": "^1.4.0" + "intellinode": "^1.4.1" } } diff --git a/samples/command_sample/test_chat_context.js b/samples/command_sample/test_chat_context.js new file mode 100644 index 0000000..f68270e --- /dev/null +++ b/samples/command_sample/test_chat_context.js @@ -0,0 +1,49 @@ +const { ChatContext } = require('intellinode'); +require("dotenv").config(); +const assert = require('assert'); + +const apiKey = process.env.OPENAI_API_KEY; + +async function testGetSimpleContext() { + + const context = new ChatContext(apiKey); + const userMessage = "Hello"; + const historyMessages = ["Good morning", "Dinner time", "How can I help you?", "Hello"]; + const n = 3; + + const resultContext = await context.getStringContext(userMessage, historyMessages, n); + + console.log('result: ', resultContext) + + assert.strictEqual(resultContext.length, n); +} + +// Test for getRoleContext +async function testGetRoleContext() { + + const context = new ChatContext(apiKey); + const userMessage = "Hello"; + const historyMessages = [ + { role: 'user', content: 'Dinner time' }, + { role: 'user', content: 'Good Morning' }, + { role: 'assistant', content: 'How can I help you?' }, + { role: 'user', content: 'Hello' } + ]; + const n = 3; + + const resultContext = await context.getRoleContext(userMessage, historyMessages, n); + + console.log('resultContext: ', resultContext) + + assert.strictEqual(resultContext.length, n); + +} + + +(async () => { + console.log('### execute the string context history ###') + await testGetSimpleContext(); + + console.log('### execute the role dictionary context history ###') + await testGetRoleContext(); +})(); \ No newline at end of file