@websolutespa/bom-llm 0.0.1
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/CHANGELOG.md +7 -0
- package/README.md +113 -0
- package/dist/umd/index.css +2796 -0
- package/dist/umd/index.js +26319 -0
- package/dist/umd/index.js.map +1 -0
- package/package.json +101 -0
- package/src/__tests/example.test.ts +8 -0
- package/src/app.scss +128 -0
- package/src/app.tsx +125 -0
- package/src/error-handler.tsx +20 -0
- package/src/index.ts +1 -0
- package/src/label.json +128 -0
- package/src/main.tsx +28 -0
- package/src/types.ts +13 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# @websolutespa/bom-llm
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/%40websolutespa%2Fbom-llm)
|
|
4
|
+
|
|
5
|
+
[](https://shields.io/)
|
|
6
|
+
|
|
7
|
+
LLM module of the [BOM Repository](https://github.com/websolutespa/bom) by [websolute](https://www.websolute.com/).
|
|
8
|
+
|
|
9
|
+
# Bom LLM Plugin
|
|
10
|
+
|
|
11
|
+
This plugin automatically adds UI components to manage LLM Chatbot by [websolute](https://www.websolute.com/).
|
|
12
|
+
|
|
13
|
+
### Requirements:
|
|
14
|
+
|
|
15
|
+
- You need a personal appKey and apiKey to use this plugin, for more info contact [websolute](https://www.websolute.com/contatti)
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
You can load the script directly via jsDelivr or installing via npm.
|
|
20
|
+
|
|
21
|
+
### Using jsDelivr
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@websolutespa/bom-llm/dist/umd/index.js"></script>
|
|
25
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@websolutespa/bom-llm/dist/umd/index.css">
|
|
26
|
+
<script>
|
|
27
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
28
|
+
if ('bomLlm' in window) {
|
|
29
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
30
|
+
const options = {
|
|
31
|
+
appKey: 'MY_APP_KEY',
|
|
32
|
+
apiKey: 'MY_API_KEY',
|
|
33
|
+
threadId: searchParams.get('llmThreadId'),
|
|
34
|
+
};
|
|
35
|
+
bomLlm(options);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Using npm
|
|
42
|
+
|
|
43
|
+
Install library using npm.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm i @websolutespa/bom-llm --save
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Import css from node_modules.
|
|
50
|
+
|
|
51
|
+
```html
|
|
52
|
+
<link rel="stylesheet" href="node_modules/@websolutespa/bom-llm/dist/umd/index.css">
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Import and consume plugin.
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import { bomLlm } from '@websolutespa/bom-llm';
|
|
59
|
+
|
|
60
|
+
document.addEventListener('DOMContentLoaded', () => {
|
|
61
|
+
if ('bomLlm' in window) {
|
|
62
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
63
|
+
const options = {
|
|
64
|
+
appKey: 'MY_APP_KEY',
|
|
65
|
+
apiKey: 'MY_API_KEY',
|
|
66
|
+
threadId: searchParams.get('llmThreadId'),
|
|
67
|
+
};
|
|
68
|
+
bomLlm(options);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Running test
|
|
74
|
+
|
|
75
|
+
Add parameter test = true.
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
79
|
+
const options = {
|
|
80
|
+
appKey: 'MY_APP_KEY',
|
|
81
|
+
apiKey: 'MY_API_KEY',
|
|
82
|
+
threadId: searchParams.get('llmThreadId'),
|
|
83
|
+
test: true,
|
|
84
|
+
};
|
|
85
|
+
bomLlm(options);
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Decorate external url
|
|
89
|
+
|
|
90
|
+
You can decorate every json item from the knowledgeBase customizing its external url.
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
94
|
+
const options = {
|
|
95
|
+
appKey: 'MY_APP_KEY',
|
|
96
|
+
apiKey: 'MY_API_KEY',
|
|
97
|
+
threadId: searchParams.get('llmThreadId'),
|
|
98
|
+
decorateUrl: (item) => {
|
|
99
|
+
switch (item.type) {
|
|
100
|
+
case 'event':
|
|
101
|
+
case 'eventItem':
|
|
102
|
+
return `https://acme.com/event?id=${item.id}`;
|
|
103
|
+
default:
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
bomLlm(options);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
##### *this library is for internal usage and not production ready*
|