@smarter.sh/ui-chat 0.3.0 → 0.7.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/LICENSE +2 -2
- package/README.md +235 -173
- package/dist/smarter-chat-library.es.js +44331 -12089
- package/dist/smarter-chat-library.es.js.map +1 -1
- package/dist/smarter-chat-library.umd.js +340 -121
- 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/contract.gen.d.ts +1146 -0
- package/dist/types/src/index.d.ts +13 -0
- package/dist/types/src/lib/ansi.d.ts +33 -0
- package/dist/types/src/lib/api.d.ts +96 -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 +108 -0
- package/dist/ui-chat.css +2 -1
- package/package.json +90 -59
- 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 -431
- 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 -152
- 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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chat's title: the LLMClient's app name and version, with icons for whether it is valid, and
|
|
3
|
+
* whether it is deployed or is still in the sandbox.
|
|
4
|
+
*/
|
|
5
|
+
import "@/components/AppTitle/styles.css";
|
|
6
|
+
interface AppTitleProps {
|
|
7
|
+
title: string;
|
|
8
|
+
isReady: boolean;
|
|
9
|
+
isValid: boolean;
|
|
10
|
+
isDeployed: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare function AppTitle({ title, isReady, isValid, isDeployed }: AppTitleProps): import("react").JSX.Element;
|
|
13
|
+
export default AppTitle;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ConsoleConfig } from "@/components/Console/data";
|
|
2
|
+
import "@/components/Console/styles.css";
|
|
3
|
+
interface ConsoleProps {
|
|
4
|
+
/** The LLMClient's configuration, from its config api. Empty until it loads. */
|
|
5
|
+
config: ConsoleConfig;
|
|
6
|
+
/** The url of the user's server log stream. Without it, there is no "Server Logs" tab. */
|
|
7
|
+
logStreamUrl?: string | null;
|
|
8
|
+
/**
|
|
9
|
+
* The minimum log level of the server logs, e.g. "DEBUG" in sandbox mode. Without it, the server's
|
|
10
|
+
* own log level. A change reconnects the stream, which replays the history at the new level.
|
|
11
|
+
*/
|
|
12
|
+
logLevel?: string | null;
|
|
13
|
+
/** Changes when a new chat session starts, which clears the server logs. */
|
|
14
|
+
resetKey?: number | string;
|
|
15
|
+
}
|
|
16
|
+
declare function Console({ config, logStreamUrl, logLevel, resetKey }: ConsoleProps): import("react").JSX.Element;
|
|
17
|
+
export default Console;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The data that the Console displays for each of its menu items. */
|
|
2
|
+
import type { ChatConfig } from "../../types";
|
|
3
|
+
import { type MenuItem } from "./enums";
|
|
4
|
+
/** The LLMClient's configuration, from its config api. Empty until it loads. */
|
|
5
|
+
export type ConsoleConfig = ChatConfig | Record<string, never> | null;
|
|
6
|
+
/** The JSON objects to display for a menu item. */
|
|
7
|
+
export declare function consoleData(config: ConsoleConfig, item: MenuItem): object[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** The Console's menu items: the configuration, the chat session's histories, and the server logs. */
|
|
2
|
+
export declare const MenuItems: {
|
|
3
|
+
readonly CHAT_CONFIG: "chat_config";
|
|
4
|
+
readonly LLMCLIENT_REQUEST_HISTORY: "llmclient_request_history";
|
|
5
|
+
readonly CHAT_TOOL_CALL_HISTORY: "chat_tool_call_history";
|
|
6
|
+
readonly CHAT_PLUGIN_USAGE_HISTORY: "chat_plugin_usage_history";
|
|
7
|
+
readonly SERVER_LOGS: "server_logs";
|
|
8
|
+
};
|
|
9
|
+
export type MenuItem = (typeof MenuItems)[keyof typeof MenuItems];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Catches a rendering error in its children, and displays a message instead of an empty page.
|
|
3
|
+
*/
|
|
4
|
+
import { Component, type ErrorInfo, type ReactNode } from "react";
|
|
5
|
+
interface ErrorBoundaryProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
interface ErrorBoundaryState {
|
|
9
|
+
error: Error | null;
|
|
10
|
+
}
|
|
11
|
+
declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
12
|
+
state: ErrorBoundaryState;
|
|
13
|
+
static getDerivedStateFromError(error: Error): ErrorBoundaryState;
|
|
14
|
+
componentDidCatch(error: Error, errorInfo: ErrorInfo): void;
|
|
15
|
+
render(): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | null | undefined;
|
|
16
|
+
}
|
|
17
|
+
export default ErrorBoundary;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SmarterChat: a chat with a Smarter LLMClient, with an optional Console beside it.
|
|
3
|
+
*
|
|
4
|
+
* It fetches the LLMClient's configuration, which includes the chat session's history, then sends
|
|
5
|
+
* the chat thread to the LLMClient's prompt api with each new message, and adds the response's
|
|
6
|
+
* messages to the thread. Failed prompts are displayed in the thread, as "smarter_error" messages.
|
|
7
|
+
* While a prompt runs, its progress (e.g. its tool calls and MCP server requests) is displayed in
|
|
8
|
+
* the thread, with a spinner beside its current step, and is replaced by the response's messages
|
|
9
|
+
* when it finishes. Code blocks in messages
|
|
10
|
+
* are syntax highlighted, and have a copy button.
|
|
11
|
+
*
|
|
12
|
+
* The user can resize the chat and the Console by dragging the separator between them, and can
|
|
13
|
+
* hide the Console, which slides out to the right. In sandbox mode, the thread also displays
|
|
14
|
+
* Smarter's system, tool and meta data messages. In production mode, it displays only the
|
|
15
|
+
* conversation, as the LLMClient's users see it. The Console's server logs follow the mode: DEBUG
|
|
16
|
+
* and above in sandbox mode, and the server's own log level in production mode. A new chat also
|
|
17
|
+
* clears the Console's server logs.
|
|
18
|
+
*
|
|
19
|
+
* This is the component that the @smarter.sh/ui-chat npm package exports, and that the Smarter web
|
|
20
|
+
* console's LLMClient prompt workbench renders. See main.tsx.
|
|
21
|
+
*/
|
|
22
|
+
import "@chatscope/chat-ui-kit-styles/dist/default/styles.min.css";
|
|
23
|
+
import type { SmarterChatProps } from "@/types";
|
|
24
|
+
import "@/components/SmarterChat/styles.css";
|
|
25
|
+
declare function SmarterChat({ apiUrl, apiKey, toggleMetadata, csrfCookieName, csrftoken, debugCookieName, debugCookieExpiration, debugMode, sessionCookieName, sessionCookieExpiration, showConsole, cookieDomain, smarterRequestId, logStreamUrl, streamProgress, }: SmarterChatProps): import("react").JSX.Element;
|
|
26
|
+
export default SmarterChat;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chat toolbar's icons, from Bootstrap Icons (MIT license, https://icons.getbootstrap.com),
|
|
3
|
+
* inline so that the package needs neither its font nor its css.
|
|
4
|
+
*/
|
|
5
|
+
/** A blank sheet of paper: a new chat. (bi-file-earmark) */
|
|
6
|
+
export declare function NewChatIcon(): import("react").JSX.Element;
|
|
7
|
+
/**
|
|
8
|
+
* A window with a panel on its right, as the Console is: filled while the Console is visible
|
|
9
|
+
* (bi-layout-sidebar-inset-reverse), and empty while it is hidden (bi-layout-sidebar-reverse).
|
|
10
|
+
*/
|
|
11
|
+
export declare function ConsoleIcon({ visible }: {
|
|
12
|
+
visible: boolean;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
14
|
+
/** Tools: sandbox mode, which displays Smarter's system, tool and meta data messages. (bi-tools) */
|
|
15
|
+
export declare function SandboxIcon(): import("react").JSX.Element;
|
|
16
|
+
/** A shield: production mode, which displays the conversation only, as its users see it. (bi-shield-check) */
|
|
17
|
+
export declare function ProductionIcon(): import("react").JSX.Element;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const projectName: string;
|
|
2
|
+
export declare const projectVersion: string;
|
|
3
|
+
export declare const loggerPrefix: string;
|
|
4
|
+
/** The default lifetime of the chat session and debug cookies: one day, in milliseconds. */
|
|
5
|
+
export declare const DEFAULT_COOKIE_EXPIRATION: number;
|