@hef2024/llmasaservice-ui 0.16.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # Prebuilt UI chat panel for LLM as a Service
2
+
3
+ LLMAsAService.io is a platform to accelerate and securely develop LLM features in your applications and websites.
4
+
5
+ This library offers a pre-built panel for incorporating chat GPT style features in react/nextjs applications.
6
+
7
+ Features
8
+ - Multi-turn style chat interface
9
+ - Open with an initial prompt (for example, after a click on a Summarize button in your application, set the initialPrompt to "Summarize the following text ..." and the panel will automatically show the summary)
10
+ - New Conversation button to reset chat history while preserving customer information
11
+ - Light and dark theme
12
+ - Abort functionality
13
+ - Markdown response display
14
+ - Sizable vertically and horizontally to suit your app. use 100vh or 100vw for the height and width to full size the panel in that orientation.
15
+
16
+
17
+ What is LLM as a Service: https://llmasaservice.io
18
+
19
+ Register for a LLM as a Service account and get your unique project id from the integration page https://app.llmasaservice.io/integration
20
+
21
+ Dark mode example:
22
+
23
+ ![Dark Mode](images/darkmode.png)
24
+
25
+ Light mode example:
26
+
27
+ ![Light Mode](images/lightmode.png)
28
+
29
+ System instructios example:
30
+
31
+ ![Brand and personality](images/personalityandbrand.png)
32
+
33
+ see documentation more examples: https://predictabilityatscale.github.io/llmasaservice-ui/?path=/docs/chatpanel--docs
34
+
35
+ ## Installation
36
+
37
+ To install the library, use npm or yarn:
38
+
39
+ ```bash
40
+ # Using npm
41
+ npm install llmasaservice-ui
42
+
43
+ # Using yarn
44
+ yarn add llmasaservice-ui
45
+ ```
46
+
47
+ ## Usage
48
+
49
+ In a React application
50
+
51
+ 1. Import the ChatPanel component
52
+
53
+ ```typescript
54
+ import React from 'react';
55
+ import { ChatPanel } from 'llmasaservice-ui';
56
+ import "../node_modules/llmasaservice-ui/dist/index.css"; // default styles for light and dark, or replace with your own
57
+
58
+ const App = () => {
59
+ return (
60
+ <div>
61
+ <h1>My Chat Application</h1>
62
+ <ChatPanel
63
+ project_id="[[get this from the LLMAsAService control panel]]"
64
+ initialPrompt="Give a nice welcome message"
65
+ />
66
+ </div>
67
+ );
68
+ };
69
+
70
+ export default App;
71
+ ```
72
+ 2. Run your application
73
+
74
+ ```bash
75
+ npm start
76
+ ```
77
+
78
+ In a Next.js application
79
+
80
+ 1. Create a new page in pages/chat.js and add the following code
81
+
82
+ ```javascript
83
+ import React from 'react';
84
+ import { ChatPanel } from 'llmasaservice-ui';
85
+ import "../../node_modules/llmasaservice-ui/dist/index.css"; // default styles for light and dark, or replace with your own
86
+
87
+ const ChatPage = () => {
88
+ return (
89
+ <div>
90
+ <h1>Chat Page</h1>
91
+ <ChatPanel
92
+ project_id="[[your project_id from the llmasaservice control panel]]"
93
+ title="Chat with us"
94
+ initialPrompt="Write a short three sentence background on the city called: Seattle"
95
+ />
96
+ </div>
97
+ );
98
+ };
99
+
100
+ export default ChatPage;
101
+ ```
102
+
103
+
104
+ 2. Run Your Next.js Application:
105
+
106
+ ```bash
107
+ npm run dev
108
+ ```
109
+
110
+ ## Tailwind CSS support
111
+
112
+ If you use tailwind for CSS styling do these additional steps for proper markdown formatting -
113
+
114
+ a) install the Typography:
115
+
116
+ ```bash
117
+ npm install -D @tailwindcss/typography
118
+ ```
119
+
120
+ b) add the plugin to your tailwind.config.js file:
121
+
122
+ ```javascript
123
+ module.exports = {
124
+ theme: {
125
+ // ...
126
+ },
127
+ plugins: [
128
+ require('@tailwindcss/typography'),
129
+ // ...
130
+ ],
131
+ }
132
+ ```
133
+
134
+ c) use prose as the class for the markdownStyle. This example is for dark mode
135
+
136
+ ```javascript
137
+ <ChatPanel
138
+ project_id="[[your project_id from the llmasaservice control panel]]"
139
+ title="Chat with us"
140
+ initialPrompt="Write a short three sentence background on the city called: Seattle"
141
+ theme="dark"
142
+ markdownClass="prose prose-sm !max-w-none dark:prose-invert"
143
+ />
144
+ ```
145
+
146
+ ## Customization
147
+ You can customize the chat panel by passing props to the ChatPanel component. Refer to the library documentation for more details on available props and customization options.
148
+
149
+ ### Button Controls
150
+ - `showSaveButton`: Show/hide the save conversation button (default: true)
151
+ - `showEmailButton`: Show/hide the email conversation button (default: true)
152
+ - `showNewConversationButton`: Show/hide the new conversation button (default: true)
153
+
154
+ The New Conversation button resets the chat history and state while preserving customer email and identification information. It requires two clicks for confirmation to prevent accidental resets - the first click changes the button to "Click to Confirm" and the second click performs the reset.
155
+
156
+ See our storybook documentation showing how to theme, size and use the variaous features in this component:
157
+
158
+ https://predictabilityatscale.github.io/llmasaservice-ui/?path=/docs/chatpanel--docs
159
+
160
+
161
+ ## License
162
+ This project is licensed under the MIT License.