@smarter.sh/ui-chat 0.2.14 → 0.7.0
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/LICENSE +2 -2
- package/README.md +130 -128
- package/dist/smarter-chat-library.es.js +44274 -10767
- package/dist/smarter-chat-library.es.js.map +1 -1
- package/dist/smarter-chat-library.umd.js +657 -362
- package/dist/smarter-chat-library.umd.js.map +1 -1
- package/dist/types/src/components/AppTitle/Component.d.ts +13 -0
- package/dist/types/src/components/AppTitle/index.d.ts +2 -0
- package/dist/types/src/components/Console/Component.d.ts +17 -0
- package/dist/types/src/components/Console/ServerLogs.d.ts +8 -0
- package/dist/types/src/components/Console/data.d.ts +7 -0
- package/dist/types/src/components/Console/enums.d.ts +9 -0
- package/dist/types/src/components/Console/index.d.ts +2 -0
- package/dist/types/src/components/ErrorBoundary/Component.d.ts +17 -0
- package/dist/types/src/components/ErrorBoundary/index.d.ts +2 -0
- package/dist/types/src/components/SmarterChat/Component.d.ts +26 -0
- package/dist/types/src/components/SmarterChat/icons.d.ts +17 -0
- package/dist/types/src/components/SmarterChat/index.d.ts +2 -0
- package/dist/types/src/const.d.ts +5 -0
- package/dist/types/src/index.d.ts +12 -0
- package/dist/types/src/lib/ansi.d.ts +33 -0
- package/dist/types/src/lib/api.d.ts +73 -0
- package/dist/types/src/lib/code.d.ts +32 -0
- package/dist/types/src/lib/cookie.d.ts +17 -0
- package/dist/types/src/lib/enums.d.ts +26 -0
- package/dist/types/src/lib/layout.d.ts +42 -0
- package/dist/types/src/lib/logStream.d.ts +30 -0
- package/dist/types/src/lib/math.d.ts +18 -0
- package/dist/types/src/lib/mermaid.d.ts +27 -0
- package/dist/types/src/lib/messages.d.ts +52 -0
- package/dist/types/src/types.d.ts +143 -0
- package/dist/ui-chat.css +2 -1
- package/package.json +89 -57
- package/src/components/Console/Component.css +0 -47
- package/src/components/Console/Component.jsx +0 -186
- package/src/components/Console/HeadStyles.jsx +0 -20
- package/src/components/Console/enums.js +0 -7
- package/src/components/Console/index.js +0 -2
- package/src/components/ErrorModal/ErrorModal.css +0 -35
- package/src/components/ErrorModal/ErrorModal.jsx +0 -56
- package/src/components/ErrorModal/index.js +0 -3
- package/src/components/SmarterChat/Component.jsx +0 -427
- package/src/components/SmarterChat/ErrorBoundary.jsx +0 -32
- package/src/components/SmarterChat/Layout.js +0 -47
- package/src/components/SmarterChat/api.js +0 -200
- package/src/components/SmarterChat/enums.js +0 -17
- package/src/components/SmarterChat/index.js +0 -3
- package/src/components/SmarterChat/styles.css +0 -149
- package/src/components/SmarterChat/utils.jsx +0 -148
- package/src/components/enums.js +0 -1
- package/src/components/index.js +0 -3
- package/src/components/shared/cookie.js +0 -51
- package/src/constants.js +0 -2
- package/src/index.js +0 -4
- package/src/types/index.js +0 -2
- package/src/types/propTypes.js +0 -154
- package/src/version.js +0 -2
- package/types/index.d.ts +0 -17
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
//---------------------------------------------------------------------------------
|
|
2
|
-
// written by: Lawrence McDaniel
|
|
3
|
-
// https://lawrencemcdaniel.com
|
|
4
|
-
//
|
|
5
|
-
// date: Mar-2024
|
|
6
|
-
//---------------------------------------------------------------------------------
|
|
7
|
-
|
|
8
|
-
// React stuff
|
|
9
|
-
import React, { useState, useEffect } from "react";
|
|
10
|
-
import ReactJson from "react-json-view";
|
|
11
|
-
import PropTypes from "prop-types";
|
|
12
|
-
|
|
13
|
-
// This component
|
|
14
|
-
import ConfigPropTypes from "../../types/propTypes";
|
|
15
|
-
import HelmetHeadStyles from "./HeadStyles";
|
|
16
|
-
import "./Component.css";
|
|
17
|
-
import { MenuItems } from "./enums";
|
|
18
|
-
|
|
19
|
-
function Console({ config }) {
|
|
20
|
-
const [consoleText, setConsoleText] = useState();
|
|
21
|
-
const [chatToolCallHistory, setChatToolCallHistory] = useState();
|
|
22
|
-
const [chatPluginUsageHistory, setChatPluginUsageHistory] = useState();
|
|
23
|
-
const [chatbotRequestHistory, setChatbotRequestHistory] = useState();
|
|
24
|
-
|
|
25
|
-
const [selectedMenuItem, setSelectedMenuItem] = useState(MenuItems.CHAT_CONFIG);
|
|
26
|
-
|
|
27
|
-
// simulated bash shell environment
|
|
28
|
-
const [podHash, setPodHash] = useState(Math.floor(Math.random() * 0xffffffff).toString(16));
|
|
29
|
-
const [lastLogin, setLastLogin] = useState(new Date().toString());
|
|
30
|
-
const [randomIpAddress, setRandomIpAddress] = useState(
|
|
31
|
-
`192.168.${Math.floor(Math.random() * 256)}.${Math.floor(Math.random() * 256)}`,
|
|
32
|
-
);
|
|
33
|
-
const [systemPrompt, setSystemPrompt] = useState(`smarter_user@smarter-${podHash}:~/smarter$`);
|
|
34
|
-
|
|
35
|
-
// Lifecycle hooks
|
|
36
|
-
useEffect(() => {
|
|
37
|
-
if (config) {
|
|
38
|
-
if (config?.debug_mode) {
|
|
39
|
-
console.log("Console() component mounted");
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
setChatToolCallHistory(config.history?.chat_tool_call_history || []);
|
|
43
|
-
setChatPluginUsageHistory(config.history?.chat_plugin_usage_history || []);
|
|
44
|
-
setChatbotRequestHistory(config.history?.chatbot_request_history || []);
|
|
45
|
-
|
|
46
|
-
const newConsoleText = Array.isArray(config) ? config : [config] || [{}];
|
|
47
|
-
setConsoleText(newConsoleText);
|
|
48
|
-
setSelectedMenuItem(MenuItems.CHAT_CONFIG);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return () => {
|
|
52
|
-
if (config?.debug_mode) {
|
|
53
|
-
console.log("Console() component unmounted");
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
}, [config]);
|
|
57
|
-
|
|
58
|
-
const ConsoleNavItem = (props) => {
|
|
59
|
-
// set the console output text based on the selected menu item
|
|
60
|
-
function consoleNavItemClicked(event, id) {
|
|
61
|
-
let newData = [{}];
|
|
62
|
-
switch (id) {
|
|
63
|
-
case MenuItems.CHAT_CONFIG:
|
|
64
|
-
newData = Array.isArray(config) ? config : [config] || newData;
|
|
65
|
-
break;
|
|
66
|
-
case MenuItems.CHAT_TOOL_CALL_HISTORY:
|
|
67
|
-
newData = chatToolCallHistory || newData;
|
|
68
|
-
break;
|
|
69
|
-
case MenuItems.CHAT_PLUGIN_USAGE_HISTORY:
|
|
70
|
-
newData = chatPluginUsageHistory || newData;
|
|
71
|
-
break;
|
|
72
|
-
case MenuItems.CHATBOT_REQUEST_HISTORY:
|
|
73
|
-
newData = chatbotRequestHistory || newData;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
setSelectedMenuItem(id);
|
|
77
|
-
setConsoleText(newData);
|
|
78
|
-
|
|
79
|
-
// set the 'active' menu item
|
|
80
|
-
requestAnimationFrame(() => {
|
|
81
|
-
if (id != selectedMenuItem) {
|
|
82
|
-
document.querySelectorAll(".nav-link").forEach((el) => el.classList.remove("active"));
|
|
83
|
-
} else {
|
|
84
|
-
event.target.classList.add("active");
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<li className="nav-item my-1">
|
|
91
|
-
<a
|
|
92
|
-
id={props.id}
|
|
93
|
-
className={`btn btn-sm btn-color-gray-600 bg-state-body btn-active-color-gray-800 fw-bolder fw-bold fs-6 fs-lg-base nav-link px-3 px-lg-4 mx-1 ${
|
|
94
|
-
props.id === selectedMenuItem ? "active" : ""
|
|
95
|
-
}`}
|
|
96
|
-
onClick={(event) => consoleNavItemClicked(event, props.id)}
|
|
97
|
-
>
|
|
98
|
-
{props.label}
|
|
99
|
-
</a>
|
|
100
|
-
</li>
|
|
101
|
-
);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
const ConsoleMenu = () => {
|
|
105
|
-
return (
|
|
106
|
-
<div
|
|
107
|
-
id="chatapp_console"
|
|
108
|
-
className="bg-gray-200 d-flex flex-stack flex-wrap mb-2 p-2 console-nav-items"
|
|
109
|
-
data-kt-sticky="true"
|
|
110
|
-
data-kt-sticky-name="sticky-profile-navs"
|
|
111
|
-
data-kt-sticky-offset="{default: false, lg: '200px'}"
|
|
112
|
-
data-kt-sticky-width="{target: '#kt_app_content_container'}"
|
|
113
|
-
data-kt-sticky-left="auto"
|
|
114
|
-
data-kt-sticky-top="70px"
|
|
115
|
-
data-kt-sticky-animation="false"
|
|
116
|
-
data-kt-sticky-zindex={95}
|
|
117
|
-
>
|
|
118
|
-
<ul className="nav flex-wrap border-transparent">
|
|
119
|
-
<ConsoleNavItem label="Config" id={MenuItems.CHAT_CONFIG} />
|
|
120
|
-
<ConsoleNavItem label="Api Calls" id={MenuItems.CHATBOT_REQUEST_HISTORY} />
|
|
121
|
-
<ConsoleNavItem label="Tool Calls" id={MenuItems.CHAT_TOOL_CALL_HISTORY} />
|
|
122
|
-
<ConsoleNavItem label="Plugin Usage" id={MenuItems.CHAT_PLUGIN_USAGE_HISTORY} />
|
|
123
|
-
</ul>
|
|
124
|
-
</div>
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const ConsoleOutputInitializing = () => {
|
|
129
|
-
return (
|
|
130
|
-
<div>
|
|
131
|
-
<p className="mb-0">
|
|
132
|
-
Last login: {lastLogin} from {randomIpAddress}
|
|
133
|
-
</p>
|
|
134
|
-
<p className="mb-0">{systemPrompt}</p>
|
|
135
|
-
</div>
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const ConsoleScreen = () => {
|
|
140
|
-
return (
|
|
141
|
-
<div className="console-output rounded">
|
|
142
|
-
<div className="console-output-content">
|
|
143
|
-
<ConsoleOutputInitializing />
|
|
144
|
-
{Array.isArray(consoleText) && consoleText.length === 1 && JSON.stringify(consoleText[0]) === "{}" ? null : (
|
|
145
|
-
<>
|
|
146
|
-
{Array.isArray(consoleText)
|
|
147
|
-
? consoleText.map((item, index) => <ReactJson key={index} src={item} theme="monokai" />)
|
|
148
|
-
: null}
|
|
149
|
-
<p className="mb-0">{systemPrompt}</p>
|
|
150
|
-
</>
|
|
151
|
-
)}
|
|
152
|
-
</div>
|
|
153
|
-
</div>
|
|
154
|
-
);
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<div className="console">
|
|
159
|
-
<HelmetHeadStyles />
|
|
160
|
-
{/*begin::Main*/}
|
|
161
|
-
<div className="app-main flex-column flex-row-fluid" id="chatapp_console_app_main">
|
|
162
|
-
{/*begin::Content wrapper*/}
|
|
163
|
-
<div className="d-flex flex-column flex-column-fluid">
|
|
164
|
-
{/*begin::Content*/}
|
|
165
|
-
<div id="chatapp_console_app_content" className="app-content flex-column-fluid p-0 pb-5">
|
|
166
|
-
{/*begin::Content container*/}
|
|
167
|
-
<div id="chatapp_console_app_content_container" className="app-container container-lg">
|
|
168
|
-
<ConsoleMenu />
|
|
169
|
-
<ConsoleScreen />
|
|
170
|
-
</div>
|
|
171
|
-
{/*end::Content container*/}
|
|
172
|
-
</div>
|
|
173
|
-
{/*end::Content*/}
|
|
174
|
-
</div>
|
|
175
|
-
{/*end::Content wrapper*/}
|
|
176
|
-
</div>
|
|
177
|
-
{/*end:::Main*/}
|
|
178
|
-
</div>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
Console.propTypes = {
|
|
183
|
-
config: ConfigPropTypes,
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
export default Console;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Helmet } from 'react-helmet';
|
|
3
|
-
import { REACT_LOCAL_DEV_MODE } from '../../constants';
|
|
4
|
-
|
|
5
|
-
// add Keen menu styles when we're in REACT_LOCAL_DEV_MODE
|
|
6
|
-
const HelmetHeadStyles = () => (
|
|
7
|
-
<>
|
|
8
|
-
<Helmet>
|
|
9
|
-
{REACT_LOCAL_DEV_MODE && (
|
|
10
|
-
<link
|
|
11
|
-
href="/style.bundle.css"
|
|
12
|
-
rel="stylesheet"
|
|
13
|
-
type="text/css"
|
|
14
|
-
/>
|
|
15
|
-
)}
|
|
16
|
-
</Helmet>
|
|
17
|
-
</>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export default HelmetHeadStyles;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
.modal {
|
|
2
|
-
text-align: center;
|
|
3
|
-
padding: 0;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.modal h2 {
|
|
7
|
-
margin-top: 0;
|
|
8
|
-
padding-top: 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.modal-button {
|
|
12
|
-
border: none;
|
|
13
|
-
padding: 10px 20px;
|
|
14
|
-
text-align: center;
|
|
15
|
-
text-decoration: none;
|
|
16
|
-
display: inline-block;
|
|
17
|
-
font-size: 16px;
|
|
18
|
-
margin: 4px 2px;
|
|
19
|
-
cursor: pointer;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.modal-container {
|
|
23
|
-
position: relative;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.modal-icon {
|
|
27
|
-
position: absolute;
|
|
28
|
-
top: 0;
|
|
29
|
-
left: 0;
|
|
30
|
-
|
|
31
|
-
color: red;
|
|
32
|
-
border: 4px solid red;
|
|
33
|
-
border-radius: 50%;
|
|
34
|
-
padding: 10px;
|
|
35
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import ReactModal from "react-modal";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
|
|
5
|
-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
6
|
-
import { faExclamation } from "@fortawesome/free-solid-svg-icons";
|
|
7
|
-
|
|
8
|
-
import "./ErrorModal.css";
|
|
9
|
-
|
|
10
|
-
export function ErrorModal(props) {
|
|
11
|
-
const ModalStyle = {
|
|
12
|
-
overlay: {
|
|
13
|
-
backgroundColor: "rgba(0, 0, 0, 0.5)",
|
|
14
|
-
display: "flex",
|
|
15
|
-
justifyContent: "center",
|
|
16
|
-
alignItems: "center",
|
|
17
|
-
zIndex: 9999, // set a high z-index value
|
|
18
|
-
},
|
|
19
|
-
content: {
|
|
20
|
-
margin: "auto",
|
|
21
|
-
width: "50%",
|
|
22
|
-
height: "25%",
|
|
23
|
-
backgroundColor: "white",
|
|
24
|
-
zIndex: 10000, // set an even higher z-index value
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
return (
|
|
28
|
-
<ReactModal
|
|
29
|
-
isOpen={props.isModalOpen}
|
|
30
|
-
onRequestClose={props.onCloseClick}
|
|
31
|
-
appElement={document.getElementById("root")}
|
|
32
|
-
style={ModalStyle}
|
|
33
|
-
>
|
|
34
|
-
<div className="modal-container">
|
|
35
|
-
<div className="modal">
|
|
36
|
-
<div className="modal-header">
|
|
37
|
-
<FontAwesomeIcon icon={faExclamation} className="modal-icon" />
|
|
38
|
-
<h2>{props.title}</h2>
|
|
39
|
-
<hr />
|
|
40
|
-
</div>
|
|
41
|
-
<p>{String(props.message)}</p>
|
|
42
|
-
<button className="modal-button" onClick={props.onCloseClick}>
|
|
43
|
-
Close
|
|
44
|
-
</button>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
</ReactModal>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
ErrorModal.propTypes = {
|
|
52
|
-
isModalOpen: PropTypes.bool.isRequired,
|
|
53
|
-
onCloseClick: PropTypes.func.isRequired,
|
|
54
|
-
title: PropTypes.string.isRequired,
|
|
55
|
-
message: PropTypes.string.isRequired,
|
|
56
|
-
};
|