LLM-Konnect is a TypeScript-based project that provides a set of APIs for managing chatbots. It includes multiple functionalities that can be accessed using the provided APIs.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
- Node.js and npm installed on your machine.
- A basic understanding of TypeScript and JavaScript.
To use the LLM-Konnect SDK, you need to get the SDK key from the LLM platform. The SDK key is used to authenticate your requests to the LLM platform. Visit website LLM-KONNECT to get the SDK key.
To install the SDK, run the following command:
npm install llm-konnect
Set the SDK in your project. Here's how you can set the SDK key:
import { SDKConfig } from 'llm-konnect';
SDKConfig.setSDKKey('your_sdk_key');
Once you have installed the package and set the initial SDK configuration, you can import the functions into your file. Here's how you can do it:
import {
addUser,
initializeChatbot,
getUserChatbots,
addUIConfig,
getUIConfig,
updateData,
getData,
removeData,
getChatbot,
removeChatbot
} from 'llm-konnect';
The main functionalities provided by this project are:
- Initialize Chatbot: This function initializes a chatbot with the given input parameters.
- Chat with Chatbot: This function sends a message to a specific chatbot that has been initialized.
- Update Data: This function updates the data of a specific chatbot.
- Add Tool: This function adds a tool to a specific chatbot.
- Get User Chatbots: This function retrieves all chatbots associated with a specific user.
- Add UI Config: This function adds a UI configuration for a chatbot.
- Get UI Config: This function retrieves the UI configuration for a specific chatbot.
- Get Chatbot: This function retrieves the details of a specific chatbot.
- Remove Chatbot: This function removes a specific chatbot.
- Remove Tool: This function removes a tool from a specific chatbot.
- Remove UI Config: This function removes the UI configuration for a specific chatbot.
The initializeChatbot
function is used to initialize a new chatbot. Here's how you can use it:
const chatbotInput = {
userId: 1,
chatbot_name: 'testbot',
purpose: 'testing',
type: 'faq',
};
initializeChatbot(chatbotInput)
.then(response => console.log(response))
.catch(error => console.error(error));
To chat with a chatbot, you need to create an object with the required parameters and pass it to the chat function. Here's an example:
import { chat } from 'llm-konnect';
const chatInput = {
chatbot_id: 1,
session_id: 'session1',
question: 'Hello?',
};
chat(chatInput)
.then(response => console.log(response))
.catch(error => console.error(error));
The getUserChatbots
function is used to get all chatbots associated with a specific user. Here's how you can use it:
const userId = 1;
getUserChatbots(userId)
.then(chatbots => console.log(chatbots))
.catch(error => console.error(error));
The addUIConfig
function is used to add a UI configuration for a chatbot. Here's how you can use it:
const uiConfig = {
chatbot_id: 1,
font_color: '#000000',
font_size: '16px',
user_message_color: '#0000FF',
system_message_color: '#FF0000',
chatbot_icon: 'https://example.com/icon.png',
header_color: '#00FF00',
header_font_color: '#FFFFFF',
bot_name: 'Test Bot',
welcome_message: 'Welcome to the test bot!',
user_font_color: '#000000',
system_font_color: '#000000',
sample_question1: 'What is your name?',
sample_question2: 'What is your age?',
sample_question3: 'What is your favorite color?',
};
addUIConfig(uiConfig)
.then(response => console.log(response))
.catch(error => console.error(error));
The getUIConfig
function is used to get the UI configuration for a specific chatbot. Here's how you can use it:
const chatbotId = 1;
getUIConfig(chatbotId)
.then(response => console.log(response))
.catch(error => console.error(error));
The updateData
function is used to update the data of a specific chatbot. Here's how you can use it:
const updateDataRequest = {
chatbot_id: 4,
text: "Some new information to add",
document_name: "New Document",
website_urls: ["https://nu.edu.pk/"],
depth: 2,
};
updateData(updateDataRequest)
.then(response => console.log(response))
.catch(error => console.error(error));
The getData
function is used to get the data of a specific chatbot. Here's how you can use it:
const chatbotId = 4;
getData(chatbotId)
.then(response => console.log(response))
.catch(error => console.error(error));
The removeData
function is used to remove the data of a specific chatbot. Here's how you can use it:
const chatbotId = 4;
const documentName = 'New Document';
removeData(chatbotId, documentName)
.then(response => console.log(response))
.catch(error => console.error(error));
The getChatbot
function is used to get the details of a specific chatbot. Here's how you can use it:
const chatbotId = 1;
getChatbot(chatbotId)
.then(response => console.log(response))
.catch(error => console.error(error));
The removeChatbot
function is used to remove a specific chatbot. Here's how you can use it:
const chatbotId = 4;
removeChatbot(chatbotId)
.then(response => console.log(response))
.catch(error => console.error(error));
The addTool
function is used to add a tool to a specific chatbot. Here's how you can use it:
import { addTool } from 'llm-konnect';
const toolInput = {
chatbot_id: 1,
tool_name: 'Tool Name',
tool_description: 'Tool Description',
};
addTool(toolInput)
.then(response => console.log(response))
.catch(error => console.error(error));
The removeTool
function is used to remove a tool from a specific chatbot. Here's how you can use it:
import { removeTool } from 'llm-konnect';
const toolInput = {
chatbot_id: 1,
tool_name: 'Tool Name',
};
removeTool(toolInput)
.then(response => console.log(response))
.catch(error => console.error(error));
The getAllTools
function is used to get all tools associated with a specific chatbot. Here's how you can use it:
import { getAllTools } from 'llm-konnect';
getAllTools()
.then(response => console.log(response))
.catch(error => console.error(error));
Please replace the placeholders with the actual details of your project.