Package Exports
- @ai-on/ui
- @ai-on/ui/dist/widget.mjs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@ai-on/ui) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
AI-ON UI
A ChatGPT-like (Multi) Chatbot Snippet
This npm module allows you to add a chatGPT-like chatbot UI widget to your website or application. Built with Solid.js, this widget provides a seamless way to interact with multiple chatbots at once. Users can easily create integrations through simple props.
Build with JSX, Integrate with any framework
Built on top of solid.js and web components, this widget can be integrated with any framework, and yet it leverages the power of JSX to provide a seamless developer experience.
Features
- Multi-Chatbot: Easily integrate multiple chatbots into your UI, but you can also use it with a single chatbot
- Out-of-the-box Themes: Choose from a variety of built-in themes from DaisyUI or create your own by cutomizing this widget
- Responsive: This widget is responsive and mobile-friendly.
- Customizable: Customize the look and feel of the chatbot widget with a familiar toolkit for modern web developers: Tailwind CSS and JSX
- Easy to use: Simply add the widget to your project and pass in the props. You don't have to worry about managing the state, or even leaking css to the rest of your application. It's all encapsulated in the widget.
- Built with Solid.js: Built with Solid.js, this widget can be integrated with any framework. Plus, you get JSX with no version conflicts with other frameworks.
- Bateries Included: This widget comes with OpenAI Integration provider. If you want to enhance your chatbot capabilities even further with user management, automatic memory management and interacting with your custom knowledge base, there's the AION Provider. You can also easily integrate your own chatbot provider. More built-in providers coming soon.
- Open Source: Under GNU GPL v3.0 license, this widget is open source and free to use. You can also contribute to the project by submitting a pull request.
Installation
NPM
npm install @ai-on/uiYarn
yarn add @ai-on/uiCDN
<script src="https://unpkg.com/@ai-on/ui" type="module"></script>Usage
If you imported the module using NPM or Yarn, you can import the module like so:
import renderer from '@ai-on/ui';
// {... rest of your code here ...}If you imported the module using CDN, you can import the module like so, in your <script>tag:
<script src="https://unpkg.com/@ai-on/ui" type="module"></script>
<script type="module">
const renderer = window.renderer // renderer is the global variable that contains the module
// {... rest of your code here ...}
</script>Then, you can pass in the props to the widget like so:
const initialProps = {
onSendMessage: async ({ message, conversation }, stream) => {
// Implement your logic when user sends a message here
},
onCreateConversation: () => {
// Implement your logic for when user creates a new conversation here
},
onDeleteConversation: () => {
// Implement your logic for when user deletes a conversation here
},
placeholder: "Type your message here...",
regenerateLimitText: "It looks like I were unable to answer you message. Please try again with a different question.",
botTypingCaption: "Typing...",
allowConversations: true,
bots: [ // List your available chatbots here
{
name: "Bot 1",
description: "Bot 1 description",
id: 1,
introMessage: "Hello, my name is bot 1. How can I help you today?",
suggestions: ["What's franch for 'bread'?", 'How are you doing? (answer as joey from friends)', 'What is the meaning of life?']
},
{
name: "Bot 2",
description: "Bot 2 description",
id: 2,
introMessage: "Hello, my name is bot 2. How can I help you today?",
suggestions: ["What's english for 'pão'?", 'How are you doing? (answer as chewbaca from star wars)', 'Why does the universe exists?']
}
],
conversations: [ // List your conversations here
{
title: "Thread 1",
description: "Description from thread 1",
id: 1,
messages: messages,
bot: bots[0],
updatedAt: new Date("2023-06-20")
},
{
title: "Thread 2",
description: "Descrição longa da conversa 2, adicionando mais contexto e informações",
id: 2,
messages: messages,
bot: bots[1],
updatedAt: new Date("2023-06-20")
},
]
};
renderer(initialProps);And, finally, you can render the widget like so in your html file:
<body>
<!-- ... Rest of your html code here ... -->
<!-- This is where the widget will be rendered. Please, note that the it's id should be 'aion-ui' -->
<div id="aion-ui" width="100%" height="100%" ></div>
</body>Props
| Prop | Type | Description | Required | Default | Example |
|---|---|---|---|---|---|
| onSendMessage | Function | Callback function that is called when the user sends a message. | Yes | N/A | async ({ message, conversation }, stream) => { // Implement your logic when user sends a message here } |
| onCreateConversation | Function | Callback function that is called when the user creates a new conversation. | Yes | N/A | async () => { // Implement your logic for when user creates a new conversation here } |
| onDeleteConversation | Function | Callback function that is called when the user deletes a conversation. | Yes | N/A | async () => { // Implement your logic for when user deletes a conversation here } |
| placeholder | String | Placeholder text for the input field. | No | "Type your message here..." | "Type your message here..." |
| regenerateLimitText | String | Text that is shown when the user reaches the limit of message regenerations. | No | "It looks like I were unable to answer you message. Please try again with a different question." | "It looks like I were unable to answer you message. Please try again with a different question." |
| botTypingCaption | String | Text that is shown when the bot is typing. | No | "Typing..." | "Typing..." |
| allowConversations | Boolean | Whether or not the user can create and delete conversations. | No | true | true |
| bots | Array | List of bots that are available to the user. | Yes | N/A | [ bot ] |
| bot.name | String | Name of the bot. | Yes | N/A | "Bot 1" |
| bot.description | String | Description of the bot. | Yes | N/A | "Bot 1 description" |
| bot.id | Number | Id of the bot. | Yes | N/A | 1 |
| bot.introMessage | String | Intro message of the bot. | Yes | N/A | "Hello, my name is bot 1. How can I help you today?" |
| bot.suggestions | Array | List of suggestions that are shown to the user when the bot is typing. | Yes | N/A | ["What's franch for 'bread'?", 'How are you doing? (answer as joey from friends)', 'What is the meaning of life?'] |
| conversations | Array | List of conversations that are available to the user. | Yes | N/A | [ conversation ] |
| conversation.title | String | Title of the conversation. | Yes | N/A | "Thread 1" |
| conversation.description | String | Description of the conversation. | Yes | N/A | "Description from thread 1" |
| conversation.id | Number | Id of the conversation. | Yes | N/A | 1 |
| conversation.bot | Object | Bot that is associated with the conversation. | Yes | N/A | bot |
| conversation.updatedAt | Date | Date of the last message in the conversation. | Yes | N/A | updatedAt: new Date("2023-06-20") |
| conversation.messages | Array | List of messages that are available in the conversation. | Yes | N/A | [ message ] |
| message.id | Number | Id of the message. | Yes | N/A | 1 |
| message.text | String | Text of the message. | Yes | N/A | "Hello, my name is bot 1. How can I help you today?" |
| message.createdAt | Date | Date of the message. | Yes | N/A | new Date("2023-06-20") |
| message.author | String | Author of the message. | Yes | N/A | Enum: ["user", "chatbot"] |
License
GNU GPLv3 ©
Author
Made with ❤️ by AI-ON Team 👋🏽 Get in touch!