@smarter.sh/ui-chat 0.7.1 → 0.9.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/README.md +353 -106
- package/dist/embed/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/dist/embed/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/dist/embed/mermaid/abnfDiagram-VCTEODGH-1SbERmPs.js +89 -0
- package/dist/embed/mermaid/arc-VicTtbbz.js +82 -0
- package/dist/embed/mermaid/architecture-7GRP2DOG-D0nnNZ3B.js +2 -0
- package/dist/embed/mermaid/architectureDiagram-5GKGNRK7-CQABdiy9.js +4138 -0
- package/dist/embed/mermaid/array-CApNbSU9.js +6 -0
- package/dist/embed/mermaid/blockDiagram-I7D4REHJ-CtjOz0Jt.js +1911 -0
- package/dist/embed/mermaid/c4Diagram-7LVT6UL2-_qBudB6C.js +3010 -0
- package/dist/embed/mermaid/channel-BXMcYHk2.js +5 -0
- package/dist/embed/mermaid/chunk-2E4U76K2-CBll2dEU.js +346 -0
- package/dist/embed/mermaid/chunk-2Q5K7J3B-kzxEEeTu.js +15 -0
- package/dist/embed/mermaid/chunk-4HAMMTFA-Dhz0SVnN.js +4188 -0
- package/dist/embed/mermaid/chunk-5VM5RSS4-Cr17nBXp.js +5 -0
- package/dist/embed/mermaid/chunk-75Z2AOVW-BsWtLgfj.js +1330 -0
- package/dist/embed/mermaid/chunk-CLGD4ZFX-Bkjwlxy9.js +14 -0
- package/dist/embed/mermaid/chunk-DU6HZSFF-1zIarP1Q.js +3900 -0
- package/dist/embed/mermaid/chunk-F27PBJKO-CiOL12VY.js +61 -0
- package/dist/embed/mermaid/chunk-FOHPRMQF-DS9zEyR5.js +21447 -0
- package/dist/embed/mermaid/chunk-GMAD6QVW-Dc0gE_3Q.js +1804 -0
- package/dist/embed/mermaid/chunk-GVQU2GXP-CWFtOgtb.js +37 -0
- package/dist/embed/mermaid/chunk-IMKFNOWR-CLyTlLwx.js +2042 -0
- package/dist/embed/mermaid/chunk-JWPE2WC7-Ccb0QaC8.js +8 -0
- package/dist/embed/mermaid/chunk-L3NEJ4N5-DnkSrVO8.js +245 -0
- package/dist/embed/mermaid/chunk-LNGE3PJU-ByFTjlja.js +1517 -0
- package/dist/embed/mermaid/chunk-OSK3NFVY-B57tZZIG.js +672 -0
- package/dist/embed/mermaid/chunk-P2QGCYS3-BUVAOFF-.js +67 -0
- package/dist/embed/mermaid/chunk-POPQ4Y6H-BsUdeJ_J.js +26 -0
- package/dist/embed/mermaid/chunk-PWAF6VOD-Cb-w19aO.js +275 -0
- package/dist/embed/mermaid/chunk-SHT3W25Y-znBBpcIu.js +4183 -0
- package/dist/embed/mermaid/chunk-SVP7TREG-DrHUM-6R.js +490 -0
- package/dist/embed/mermaid/chunk-TICWLB2K-xlGqZZYJ.js +3357 -0
- package/dist/embed/mermaid/chunk-TLUHSLCS-COwDpXBa.js +59 -0
- package/dist/embed/mermaid/chunk-XXDRQBXY-pOp8MAr9.js +9 -0
- package/dist/embed/mermaid/chunk-Y2CYZVJY-i11wjrBe.js +12 -0
- package/dist/embed/mermaid/classDiagram-ZZMXUADV-C8BeuQnA.js +30 -0
- package/dist/embed/mermaid/classDiagram-v2-VYDZK3BY-B3jylZLr.js +30 -0
- package/dist/embed/mermaid/cose-bilkent-JH36ORCC-DFvJxZ7v.js +2240 -0
- package/dist/embed/mermaid/cynefin-OW5HDTMX-B6YJOAMM.js +2 -0
- package/dist/embed/mermaid/cynefinDiagram-5FMLGOSQ-CCm5IQBE.js +355 -0
- package/dist/embed/mermaid/cytoscape.esm-BstmGtAB.js +18047 -0
- package/dist/embed/mermaid/dagre-BwzzJJA_.js +1932 -0
- package/dist/embed/mermaid/dagre-GXQ25YYZ-B3d3iNF-.js +423 -0
- package/dist/embed/mermaid/defaultLocale-N-0uLSyg.js +198 -0
- package/dist/embed/mermaid/diagram-S7CK7UJ4-BeA5UJrt.js +293 -0
- package/dist/embed/mermaid/diagram-UQ7AKVKN-DK0uHb-2.js +214 -0
- package/dist/embed/mermaid/diagram-VSXAHHWV-D5JXip1B.js +432 -0
- package/dist/embed/mermaid/diagram-VX7I27RA-B1VysvG9.js +527 -0
- package/dist/embed/mermaid/diagram-Z3DM3KII-ZGUJaFq-.js +134 -0
- package/dist/embed/mermaid/dist-DRRwZ4Yi.js +59 -0
- package/dist/embed/mermaid/ebnfDiagram-PWID7BFC-BOahZhWx.js +100 -0
- package/dist/embed/mermaid/erDiagram-RLTQ6QDP-7cGpGRQo.js +1966 -0
- package/dist/embed/mermaid/eventmodeling-NTZA5JFV-C3kU50Cz.js +2 -0
- package/dist/embed/mermaid/flowDiagram-HODETNUW-D-eJN2AO.js +16 -0
- package/dist/embed/mermaid/ganttDiagram-EL5Y4UJY-s6Kx4KlU.js +3072 -0
- package/dist/embed/mermaid/gitGraph-4MIJSDKK-CqdlGRFk.js +2 -0
- package/dist/embed/mermaid/gitGraphDiagram-WWUBYQGX-Blwdy0b7.js +733 -0
- package/dist/embed/mermaid/graphlib-XW-Jr8pF.js +1267 -0
- package/dist/embed/mermaid/info-A6RAGUB7-2pwra5F3.js +2 -0
- package/dist/embed/mermaid/infoDiagram-27XIBGKW-CstzbQPb.js +20 -0
- package/dist/embed/mermaid/init-CsQUQz36.js +13 -0
- package/dist/embed/mermaid/ishikawaDiagram-5VMMS53U-C6y_w0kd.js +717 -0
- package/dist/embed/mermaid/journeyDiagram-3NMN7TZE-BHVux_z1.js +884 -0
- package/dist/embed/mermaid/kanban-definition-UXKFOSKX-Cgj-7IHi.js +976 -0
- package/dist/embed/mermaid/katex-DmPOayaq.js +21968 -0
- package/dist/embed/mermaid/line-brkWVSn0.js +34 -0
- package/dist/embed/mermaid/linear-CiZWLcTr.js +287 -0
- package/dist/embed/mermaid/mermaid-parser.core-BjLg_By9.js +632 -0
- package/dist/embed/mermaid/mermaid.js +1092 -0
- package/dist/embed/mermaid/mindmap-definition-YA3MSWOX-DRc-FzI_.js +1006 -0
- package/dist/embed/mermaid/ordinal-BubEveRk.js +65 -0
- package/dist/embed/mermaid/packet-AYTQ26CC-C3h9OoFk.js +2 -0
- package/dist/embed/mermaid/path-CnWkkRiY.js +84 -0
- package/dist/embed/mermaid/pegDiagram-XKGWAZYB-Cw-aYwaF.js +94 -0
- package/dist/embed/mermaid/pie-WAS4IAKB-CaECYpHT.js +2 -0
- package/dist/embed/mermaid/pieDiagram-E7YTZNPT-DoguGyzq.js +203 -0
- package/dist/embed/mermaid/quadrantDiagram-AXDQQJYC-Cu4dMFZL.js +2001 -0
- package/dist/embed/mermaid/radar-RG4KPBEZ-CoS7pnd_.js +2 -0
- package/dist/embed/mermaid/railroad-74A4TZTK-BjHa6MAk.js +2 -0
- package/dist/embed/mermaid/railroad-abnf-HS5TGJTU-Bm2YWqjG.js +2 -0
- package/dist/embed/mermaid/railroad-ebnf-LZEXJU2U-C7mPpgM3.js +2 -0
- package/dist/embed/mermaid/railroad-peg-WCYAUIDC-Cyp07M5x.js +2 -0
- package/dist/embed/mermaid/railroadDiagram-O6MQD6OU-DDX-9GRQ.js +76 -0
- package/dist/embed/mermaid/requirementDiagram-BXWQKSXE-z8PPo06M.js +2224 -0
- package/dist/embed/mermaid/rough.esm-DXYGHN3m.js +1361 -0
- package/dist/embed/mermaid/sankeyDiagram-P5KCCOFB-CeD0II3M.js +972 -0
- package/dist/embed/mermaid/sequenceDiagram-WJ2MYXX4-Cs-Wxyvw.js +4156 -0
- package/dist/embed/mermaid/sizeCapture-INFHLROL-DujrpAYz.js +46 -0
- package/dist/embed/mermaid/src-DbyMbLVK.js +2141 -0
- package/dist/embed/mermaid/stateDiagram-D77RDMKH-CqWtgHSc.js +220 -0
- package/dist/embed/mermaid/stateDiagram-v2-MP3YSRHH-CPideWIU.js +30 -0
- package/dist/embed/mermaid/swimlanes-42K2YHIH-MutR4uV4.js +4957 -0
- package/dist/embed/mermaid/swimlanesDiagram-VR7AAH4N-BC_o7pti.js +31 -0
- package/dist/embed/mermaid/timeline-definition-24CTP7MA-rZfNRFiT.js +1069 -0
- package/dist/embed/mermaid/treeView-Q6P3EWNA-C94eS7gV.js +2 -0
- package/dist/embed/mermaid/treemap-WGGIJYW6-DnrVJ1h3.js +2 -0
- package/dist/embed/mermaid/vennDiagram-4TSXK5OY-KwMHebDQ.js +1880 -0
- package/dist/embed/mermaid/wardley-WFR3VGLG-DRDACyIN.js +2 -0
- package/dist/embed/mermaid/wardleyDiagram-VM6X3IG4-C-Fm7GGB.js +645 -0
- package/dist/embed/mermaid/xychartDiagram-S5SC5T6Z-DZX43ay9.js +2210 -0
- package/dist/embed.js +903 -0
- package/dist/embed.js.map +1 -0
- package/dist/smarter-chat-library.es.js +3048 -2808
- package/dist/smarter-chat-library.es.js.map +1 -1
- package/dist/smarter-chat-library.umd.js +56 -56
- package/dist/smarter-chat-library.umd.js.map +1 -1
- package/dist/types/src/components/DocsDialog/Component.d.ts +8 -0
- package/dist/types/src/components/DocsDialog/data.d.ts +18 -0
- package/dist/types/src/components/DocsDialog/index.d.ts +2 -0
- package/dist/types/src/components/SmarterChat/Component.d.ts +7 -3
- package/dist/types/src/components/SmarterChat/icons.d.ts +2 -0
- package/dist/types/src/contract.gen.d.ts +56 -0
- package/dist/types/src/embed/EmbedApp.d.ts +10 -0
- package/dist/types/src/embed/assets.d.ts +7 -0
- package/dist/types/src/embed/autoMount.d.ts +18 -0
- package/dist/types/src/embed/css.d.ts +15 -0
- package/dist/types/src/embed/element.d.ts +19 -0
- package/dist/types/src/embed/index.d.ts +17 -0
- package/dist/types/src/embed/mermaid.d.ts +2 -0
- package/dist/types/src/embed/mermaidImport.d.ts +1 -0
- package/dist/types/src/embed/options.d.ts +69 -0
- package/dist/types/src/lib/cookie.d.ts +4 -3
- package/dist/types/src/lib/mermaidImport.d.ts +8 -0
- package/dist/types/src/lib/styles.d.ts +40 -0
- package/dist/types/src/types.d.ts +7 -0
- package/dist/ui-chat.css +1 -1
- package/package.json +10 -4
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type DocSection } from "@/components/DocsDialog/data";
|
|
2
|
+
import "@/components/DocsDialog/styles.css";
|
|
3
|
+
interface DocsDialogProps {
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
sections?: DocSection[];
|
|
6
|
+
}
|
|
7
|
+
declare function DocsDialog({ onClose, sections }: DocsDialogProps): import("react").JSX.Element;
|
|
8
|
+
export default DocsDialog;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** A technical reference that the Docs dialog links to. */
|
|
2
|
+
export interface DocLink {
|
|
3
|
+
title: string;
|
|
4
|
+
url: string;
|
|
5
|
+
description: string;
|
|
6
|
+
}
|
|
7
|
+
/** A tab of the Docs dialog: the technical references for one audience. */
|
|
8
|
+
export interface DocSection {
|
|
9
|
+
title: string;
|
|
10
|
+
description: string;
|
|
11
|
+
links: DocLink[];
|
|
12
|
+
}
|
|
13
|
+
/** The technical references for prompt engineers, who build LLMClients in the sandbox. */
|
|
14
|
+
export declare const PROMPT_ENGINEER_LINKS: DocLink[];
|
|
15
|
+
/** The technical references for software engineers, who build the applications that host them. */
|
|
16
|
+
export declare const SOFTWARE_ENGINEER_LINKS: DocLink[];
|
|
17
|
+
/** The tabs of the Docs dialog, from left to right. The first one is selected when it opens. */
|
|
18
|
+
export declare const DOC_SECTIONS: DocSection[];
|
|
@@ -12,9 +12,13 @@
|
|
|
12
12
|
* The user can resize the chat and the Console by dragging the separator between them, and can
|
|
13
13
|
* hide the Console, which slides out to the right. In sandbox mode, the thread also displays
|
|
14
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
|
|
15
|
+
* conversation, as the LLMClient's users see it, and the Console and its toggle button are hidden. The Console's server logs follow the mode: DEBUG
|
|
16
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.
|
|
17
|
+
* clears the Console's server logs. Sandbox mode also has a Docs button, which opens a dialog of
|
|
18
|
+
* links to the technical references for prompt engineers and software engineers.
|
|
19
|
+
*
|
|
20
|
+
* The LLMClient's styles (its manifest's spec.config.styles) set its logo, which is displayed in
|
|
21
|
+
* the header, its avatars, its background image, its fonts and its colors. See lib/styles.ts.
|
|
18
22
|
*
|
|
19
23
|
* This is the component that the @smarter.sh/ui-chat npm package exports, and that the Smarter web
|
|
20
24
|
* console's LLMClient prompt workbench renders. See main.tsx.
|
|
@@ -22,5 +26,5 @@
|
|
|
22
26
|
import "@chatscope/chat-ui-kit-styles/dist/default/styles.min.css";
|
|
23
27
|
import type { SmarterChatProps } from "@/types";
|
|
24
28
|
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;
|
|
29
|
+
declare function SmarterChat({ apiUrl, apiKey, toggleMetadata, csrfCookieName, csrftoken, debugCookieName, debugCookieExpiration, debugMode, sessionCookieName, sessionCookieExpiration, cookiePath, showConsole, cookieDomain, smarterRequestId, logStreamUrl, streamProgress, }: SmarterChatProps): import("react").JSX.Element;
|
|
26
30
|
export default SmarterChat;
|
|
@@ -15,3 +15,5 @@ export declare function ConsoleIcon({ visible }: {
|
|
|
15
15
|
export declare function SandboxIcon(): import("react").JSX.Element;
|
|
16
16
|
/** A shield: production mode, which displays the conversation only, as its users see it. (bi-shield-check) */
|
|
17
17
|
export declare function ProductionIcon(): import("react").JSX.Element;
|
|
18
|
+
/** An open book: the Docs dialog, which links to the technical references. (bi-book) */
|
|
19
|
+
export declare function DocsIcon(): import("react").JSX.Element;
|
|
@@ -59,6 +59,10 @@ export interface PromptChatApiChatbotV1 {
|
|
|
59
59
|
id: number;
|
|
60
60
|
name: string;
|
|
61
61
|
provider?: string | null;
|
|
62
|
+
/**
|
|
63
|
+
* The look of the chat: the manifest's spec.config.styles, with snake_case keys.
|
|
64
|
+
*/
|
|
65
|
+
styles?: PromptChatApiStyles | null;
|
|
62
66
|
/**
|
|
63
67
|
* The url of the LLMClient's prompt api.
|
|
64
68
|
*/
|
|
@@ -66,6 +70,54 @@ export interface PromptChatApiChatbotV1 {
|
|
|
66
70
|
version?: string | null;
|
|
67
71
|
[k: string]: unknown;
|
|
68
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* The look of the LLMClient's chat: its manifest's ``spec.config.styles``, with snake_case keys.
|
|
75
|
+
*
|
|
76
|
+
* Smarter Chat applies it as css custom properties. Every setting is optional, and one that is
|
|
77
|
+
* left out keeps the chat's default.
|
|
78
|
+
*
|
|
79
|
+
* This interface was referenced by `SmarterChatAPIContract`'s JSON-Schema
|
|
80
|
+
* via the `definition` "PromptChatApiStyles".
|
|
81
|
+
*/
|
|
82
|
+
export interface PromptChatApiStyles {
|
|
83
|
+
app_background_image_size?: ("cover" | "contain" | "auto") | null;
|
|
84
|
+
app_background_image_url?: string | null;
|
|
85
|
+
app_logo_url?: string | null;
|
|
86
|
+
assistant_avatar_url?: string | null;
|
|
87
|
+
border_radius?: string | null;
|
|
88
|
+
buttons?: PromptChatApiStyleSection | null;
|
|
89
|
+
conversation_header?: PromptChatApiStyleSection | null;
|
|
90
|
+
font_family?: string | null;
|
|
91
|
+
font_size?: string | null;
|
|
92
|
+
google_font?: string | null;
|
|
93
|
+
incoming_message?: PromptChatApiStyleSection | null;
|
|
94
|
+
main_container?: PromptChatApiStyleSection | null;
|
|
95
|
+
message_input?: PromptChatApiStyleSection | null;
|
|
96
|
+
message_list?: PromptChatApiStyleSection | null;
|
|
97
|
+
outgoing_message?: PromptChatApiStyleSection | null;
|
|
98
|
+
typing_indicator?: PromptChatApiStyleSection | null;
|
|
99
|
+
user_avatar_url?: string | null;
|
|
100
|
+
[k: string]: unknown;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A section of the LLMClient's styles: the colors of one of chatscope's components.
|
|
104
|
+
*
|
|
105
|
+
* A section has only the settings that its component has, in the manifest's
|
|
106
|
+
* ``spec.config.styles``. See :mod:`smarter.apps.llmclient.manifest.models.llmclient.styles`.
|
|
107
|
+
*
|
|
108
|
+
* This interface was referenced by `SmarterChatAPIContract`'s JSON-Schema
|
|
109
|
+
* via the `definition` "PromptChatApiStyleSection".
|
|
110
|
+
*/
|
|
111
|
+
export interface PromptChatApiStyleSection {
|
|
112
|
+
background_color?: string | null;
|
|
113
|
+
border_color?: string | null;
|
|
114
|
+
color?: string | null;
|
|
115
|
+
editor_background_color?: string | null;
|
|
116
|
+
info_color?: string | null;
|
|
117
|
+
link_color?: string | null;
|
|
118
|
+
placeholder_color?: string | null;
|
|
119
|
+
[k: string]: unknown;
|
|
120
|
+
}
|
|
69
121
|
/**
|
|
70
122
|
* A choice of a chat completion.
|
|
71
123
|
*
|
|
@@ -555,6 +607,10 @@ export interface PromptChatApiLLMClient {
|
|
|
555
607
|
id: number;
|
|
556
608
|
name: string;
|
|
557
609
|
provider?: string | null;
|
|
610
|
+
/**
|
|
611
|
+
* The look of the chat: the manifest's spec.config.styles, with snake_case keys.
|
|
612
|
+
*/
|
|
613
|
+
styles?: PromptChatApiStyles | null;
|
|
558
614
|
/**
|
|
559
615
|
* The url of the LLMClient's prompt api.
|
|
560
616
|
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { EmbedOptions } from "./options";
|
|
2
|
+
export declare const PANEL_ID = "smarter-chat-embed-panel";
|
|
3
|
+
export interface EmbedAppProps {
|
|
4
|
+
options: EmbedOptions;
|
|
5
|
+
/** Whether the launcher is open. The element owns this state, so that page scripts can open and close it. */
|
|
6
|
+
open: boolean;
|
|
7
|
+
onOpenChange: (open: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
declare function EmbedApp(props: EmbedAppProps): import("react").JSX.Element;
|
|
10
|
+
export default EmbedApp;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const CDN_BASE_URL: string;
|
|
2
|
+
/** The url of the directory of a script, or of jsDelivr's copy of the package, if it has no url. */
|
|
3
|
+
export declare function scriptBaseUrl(script: Element | null | undefined): string;
|
|
4
|
+
/** Remembers the directory of the running script. Called once, by index.ts, when the script first runs. */
|
|
5
|
+
export declare function captureBaseUrl(script?: Element | null | undefined): string;
|
|
6
|
+
/** The url of one of the embed script's files, e.g. assetUrl("mermaid/mermaid.js"). */
|
|
7
|
+
export declare function assetUrl(path: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The attribute that marks the elements that the script added, with their chatbot's url. */
|
|
2
|
+
export declare const AUTO_ATTRIBUTE = "data-smarter-chat-auto";
|
|
3
|
+
export type EmbedConfig = Record<string, unknown>;
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
SmarterChatConfig?: EmbedConfig | EmbedConfig[];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/** The configurations of the script tag's data- attributes and of window.SmarterChatConfig, as attributes. */
|
|
10
|
+
export declare function configurations(script: Element | null | undefined, globalConfig: EmbedConfig | EmbedConfig[] | null | undefined): Record<string, string>[];
|
|
11
|
+
/**
|
|
12
|
+
* Adds a <smarter-chat> element for a configuration, unless the page has one for its chatbot already.
|
|
13
|
+
*
|
|
14
|
+
* @returns The new element, or null if none was added.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mountChat(attributes: Record<string, string>, doc?: Document): HTMLElement | null;
|
|
17
|
+
/** Adds the configurations' elements once the page's body exists. */
|
|
18
|
+
export declare function autoMount(script: Element | null | undefined, globalConfig: EmbedConfig | EmbedConfig[] | null | undefined, doc?: Document): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const ASSETS_PLACEHOLDER = "__SMARTER_CHAT_ASSETS__/";
|
|
2
|
+
export declare const FONT_STYLE_ID = "smarter-chat-embed-fonts";
|
|
3
|
+
/** Adds css to the embed's stylesheet. Called by the modules that the embed build generates for css imports. */
|
|
4
|
+
export declare function addCss(css: string): void;
|
|
5
|
+
/** The embed's css, with the urls of its own files. */
|
|
6
|
+
export declare function embedCss(): string;
|
|
7
|
+
/** The @font-face rules of a stylesheet. */
|
|
8
|
+
export declare function fontFaceRules(css: string): string[];
|
|
9
|
+
/** Adds the @font-face rules of the css to the document's head, once. */
|
|
10
|
+
export declare function hoistFontFaces(css: string, doc?: Document): void;
|
|
11
|
+
/**
|
|
12
|
+
* Applies the css to a shadow root: as a constructable stylesheet, shared by every chat on the page, where the
|
|
13
|
+
* browser supports them, or else as a style element.
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyCss(root: ShadowRoot, css: string): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type EmbedOptionsResult } from "./options";
|
|
2
|
+
export declare const ELEMENT_NAME = "smarter-chat";
|
|
3
|
+
export declare const TOGGLE_EVENT = "smarter-chat-toggle";
|
|
4
|
+
export declare class SmarterChatElement extends HTMLElement {
|
|
5
|
+
#private;
|
|
6
|
+
static observedAttributes: ("chatbot" | "color" | "label" | "open" | "debug" | "width" | "height" | "position" | "api-key" | "mode" | "z-index" | "session-cookie-name" | "cookie-path" | "stream-progress")[];
|
|
7
|
+
/** The element's options, from its attributes. */
|
|
8
|
+
get options(): EmbedOptionsResult;
|
|
9
|
+
/** Whether the launcher is open. */
|
|
10
|
+
get isOpen(): boolean;
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
attributeChangedCallback(): void;
|
|
14
|
+
open(): void;
|
|
15
|
+
close(): void;
|
|
16
|
+
toggle(): void;
|
|
17
|
+
}
|
|
18
|
+
/** Defines <smarter-chat>, unless the page already has, e.g. with another copy of the embed script. */
|
|
19
|
+
export declare function defineElement(registry?: CustomElementRegistry): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type EmbedConfig } from "./autoMount";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
/** The api of window.SmarterChat. */
|
|
4
|
+
export interface SmarterChatEmbedApi {
|
|
5
|
+
version: string;
|
|
6
|
+
/** Opens the launchers, or the launcher of one chatbot, by its url. */
|
|
7
|
+
open: (chatbot?: string) => void;
|
|
8
|
+
close: (chatbot?: string) => void;
|
|
9
|
+
toggle: (chatbot?: string) => void;
|
|
10
|
+
/** Adds a chat to the page, as window.SmarterChatConfig does. */
|
|
11
|
+
mount: (config: EmbedConfig) => HTMLElement | null;
|
|
12
|
+
}
|
|
13
|
+
declare global {
|
|
14
|
+
interface Window {
|
|
15
|
+
SmarterChat?: SmarterChatEmbedApi;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const importMermaid: () => Promise<typeof import("mermaid")>;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export type EmbedMode = "launcher" | "inline";
|
|
2
|
+
export type EmbedPosition = "bottom-right" | "bottom-left";
|
|
3
|
+
export interface EmbedOptions {
|
|
4
|
+
/** The url of the deployed LLMClient, e.g. https://support.3141-5926-5359.api.example.com/ */
|
|
5
|
+
chatbot: string;
|
|
6
|
+
/** A Smarter api key, for LLMClients that require one. It is public, as is everything in a web page. */
|
|
7
|
+
apiKey: string | null;
|
|
8
|
+
/** "launcher": a button in a corner of the page that opens the chat. "inline": the chat, in the page. */
|
|
9
|
+
mode: EmbedMode;
|
|
10
|
+
/** The launcher's corner. */
|
|
11
|
+
position: EmbedPosition;
|
|
12
|
+
/** Whether the launcher starts open. */
|
|
13
|
+
open: boolean;
|
|
14
|
+
/** The launcher's accessible name, and the chat panel's. */
|
|
15
|
+
label: string;
|
|
16
|
+
/** The launcher button's background color. */
|
|
17
|
+
color: string;
|
|
18
|
+
/** The width of the inline chat, or of the launcher's panel. */
|
|
19
|
+
width: string;
|
|
20
|
+
/** The height of the inline chat, or of the launcher's panel. */
|
|
21
|
+
height: string;
|
|
22
|
+
/** The launcher's z-index. */
|
|
23
|
+
zIndex: number;
|
|
24
|
+
/** The cookie in which the chat saves its session's key. */
|
|
25
|
+
sessionCookieName: string;
|
|
26
|
+
/** The path of the chat's cookies. "/" keeps one chat session across the website. */
|
|
27
|
+
cookiePath: string;
|
|
28
|
+
/** Display a running prompt's progress. */
|
|
29
|
+
streamProgress: boolean;
|
|
30
|
+
/** Log to the browser console. */
|
|
31
|
+
debug: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** The result of reading the options: the options, or why they can't be used. */
|
|
34
|
+
export type EmbedOptionsResult = {
|
|
35
|
+
options: EmbedOptions;
|
|
36
|
+
error: null;
|
|
37
|
+
} | {
|
|
38
|
+
options: null;
|
|
39
|
+
error: string;
|
|
40
|
+
};
|
|
41
|
+
/** The attributes that a <smarter-chat> element reads, in kebab-case. */
|
|
42
|
+
export declare const OPTION_ATTRIBUTES: readonly ["chatbot", "api-key", "mode", "position", "open", "label", "color", "width", "height", "z-index", "session-cookie-name", "cookie-path", "stream-progress", "debug"];
|
|
43
|
+
export declare const DEFAULT_LABEL = "Chat";
|
|
44
|
+
export declare const DEFAULT_COLOR = "#ff5733";
|
|
45
|
+
export declare const DEFAULT_Z_INDEX = 2147483000;
|
|
46
|
+
/** A boolean attribute: present and empty, or "true", is true. "false" is false. Missing is the default. */
|
|
47
|
+
export declare function booleanOption(value: string | null | undefined, defaultValue: boolean): boolean;
|
|
48
|
+
/** The url, if it is an http(s) url, normalized to end with a slash, else null. */
|
|
49
|
+
export declare function chatbotUrl(value: string | null | undefined): string | null;
|
|
50
|
+
/**
|
|
51
|
+
* The default session cookie of a chatbot: one per chatbot host, so that two chatbots on one website keep separate
|
|
52
|
+
* chat sessions, e.g. smarter_chat_support_3141_5926_5359_api_example_com.
|
|
53
|
+
*/
|
|
54
|
+
export declare function defaultSessionCookieName(chatbot: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* The options of a <smarter-chat> element.
|
|
57
|
+
*
|
|
58
|
+
* @param get Returns the value of an attribute, by its kebab-case name, or null if it is missing.
|
|
59
|
+
* @param defaultMode The mode, if the attributes don't say: "inline" for an element in the page, and "launcher"
|
|
60
|
+
* for the element that the script tag adds.
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseOptions(get: (name: (typeof OPTION_ATTRIBUTES)[number]) => string | null, defaultMode?: EmbedMode): EmbedOptionsResult;
|
|
63
|
+
/** A camelCase name in kebab-case, e.g. apiKey to api-key. */
|
|
64
|
+
export declare function kebabCase(name: string): string;
|
|
65
|
+
/**
|
|
66
|
+
* The attributes of a configuration object, e.g. window.SmarterChatConfig's, or a script tag's dataset: kebab-case
|
|
67
|
+
* names, and string values. Values that are null, undefined, objects or functions are left out.
|
|
68
|
+
*/
|
|
69
|
+
export declare function configAttributes(config: Record<string, unknown>): Record<string, string>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Cookie management for Smarter Chat: the Django CSRF cookie, which it reads, and the chat
|
|
3
3
|
* session and debug cookies, which it sets for the page's path, so that each LLMClient's
|
|
4
|
-
* workbench has its own chat session.
|
|
4
|
+
* workbench has its own chat session, or for the path that the cookie names, e.g. "/" for a chat
|
|
5
|
+
* that follows the visitor across a website.
|
|
5
6
|
*/
|
|
6
7
|
import type { CookieMeta } from "../types";
|
|
7
8
|
/**
|
|
@@ -12,6 +13,6 @@ import type { CookieMeta } from "../types";
|
|
|
12
13
|
export declare function inCookieDomain(hostname: string, domain: string | null | undefined): boolean;
|
|
13
14
|
/** The cookie's value: its preset value, else the browser's cookie, else defaultValue. */
|
|
14
15
|
export declare function getCookie(cookie: CookieMeta, defaultValue?: string | null): string | null;
|
|
15
|
-
/** Sets the cookie for the page's
|
|
16
|
+
/** Sets the cookie for its path (by default, the page's), or deletes it when value is empty. */
|
|
16
17
|
export declare function setCookie(cookie: CookieMeta, value: string | boolean | null | undefined): void;
|
|
17
|
-
export declare function cookieMetaFactory(name: string, expiration: number | null, domain: string | undefined, value?: string | null): CookieMeta;
|
|
18
|
+
export declare function cookieMetaFactory(name: string, expiration: number | null, domain: string | undefined, value?: string | null, path?: string | null): CookieMeta;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Imports mermaid, which lib/mermaid.ts does the first time that a message has a diagram.
|
|
3
|
+
*
|
|
4
|
+
* In the npm package and the web console, the page's bundler splits mermaid into chunks, which are downloaded only
|
|
5
|
+
* then. The embed script, a single classic script, can't be split that way, so its build replaces this module with
|
|
6
|
+
* src/embed/mermaidImport.ts, which imports a separate build of mermaid from beside the script. See vite.config.ts.
|
|
7
|
+
*/
|
|
8
|
+
export declare const importMermaid: () => Promise<typeof import("mermaid")>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The LLMClient's styles: its manifest's spec.config.styles, which the config api returns, with
|
|
3
|
+
* snake_case keys, as llmclient.styles.
|
|
4
|
+
*
|
|
5
|
+
* chatscope's theme (@chatscope/chat-ui-kit-styles) is compiled from scss variables, so its colors
|
|
6
|
+
* can't be changed at run time. Instead, the styles become css custom properties (variables) on the
|
|
7
|
+
* chat's root element, e.g. --smarter-chat-header-bg, which styles.css applies to chatscope's
|
|
8
|
+
* components, with chatscope's (or Smarter's) own value as the fallback. A setting that is left out
|
|
9
|
+
* changes nothing.
|
|
10
|
+
*
|
|
11
|
+
* The backend validates every value. They are checked again here, because a page may embed a chat
|
|
12
|
+
* from any Smarter platform: a value that isn't a plain css value is ignored.
|
|
13
|
+
*/
|
|
14
|
+
import { type CSSProperties } from "react";
|
|
15
|
+
import type { Contract } from "@/types";
|
|
16
|
+
export type ChatStyles = Contract.PromptChatApiStyles;
|
|
17
|
+
export type ChatStyleSection = Contract.PromptChatApiStyleSection;
|
|
18
|
+
/** The id of the stylesheet link of the LLMClient's Google font. */
|
|
19
|
+
export declare const GOOGLE_FONT_LINK_ID = "smarter-chat-google-font";
|
|
20
|
+
/** The value, if it is a plain css value. */
|
|
21
|
+
export declare function safeCssValue(value: string | null | undefined): string | null;
|
|
22
|
+
/** The url, if it is an https url that can be used in css' url(). */
|
|
23
|
+
export declare function safeImageUrl(value: string | null | undefined): string | null;
|
|
24
|
+
/** The url of the Google Fonts stylesheet of a font, or null if the name isn't a font's. */
|
|
25
|
+
export declare function googleFontUrl(name: string | null | undefined): string | null;
|
|
26
|
+
/** The font stack: fontFamily, or the Google font, or null for chatscope's. */
|
|
27
|
+
export declare function fontFamily(styles: ChatStyles | null | undefined): string | null;
|
|
28
|
+
/**
|
|
29
|
+
* The css variables of the styles, for the chat's root element's style.
|
|
30
|
+
*
|
|
31
|
+
* @param styles The LLMClient's styles, or nothing.
|
|
32
|
+
* @returns The variables, without those of the settings that are not set, or not valid.
|
|
33
|
+
*/
|
|
34
|
+
export declare function styleVariables(styles: ChatStyles | null | undefined): CSSProperties;
|
|
35
|
+
/**
|
|
36
|
+
* Loads the Google font of the styles, once per page, with a stylesheet link in the page's head.
|
|
37
|
+
*
|
|
38
|
+
* @param name The font's name, from the Google Fonts catalog, or nothing.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useGoogleFont(name: string | null | undefined): void;
|
|
@@ -54,6 +54,8 @@ export interface CookieMeta {
|
|
|
54
54
|
domain: string;
|
|
55
55
|
/** A value to use instead of the cookie's. */
|
|
56
56
|
value: string | null;
|
|
57
|
+
/** The path that Smarter Chat sets the cookie for. Empty or missing means the page's path. */
|
|
58
|
+
path?: string | null;
|
|
57
59
|
}
|
|
58
60
|
export interface ChatCookies {
|
|
59
61
|
csrfCookie: CookieMeta;
|
|
@@ -87,6 +89,11 @@ export interface SmarterChatProps {
|
|
|
87
89
|
/** The name of the cookie in which Smarter Chat saves the chat session's key. */
|
|
88
90
|
sessionCookieName?: string;
|
|
89
91
|
sessionCookieExpiration?: number;
|
|
92
|
+
/**
|
|
93
|
+
* The path of the session and debug cookies. By default, the page's path, so that each page has its own chat
|
|
94
|
+
* session. "/" keeps one chat session as the visitor moves from page to page of a website.
|
|
95
|
+
*/
|
|
96
|
+
cookiePath?: string | null;
|
|
90
97
|
/** @deprecated Not used. Django's session cookie is sent with each request, as is. */
|
|
91
98
|
authSessionCookieName?: string;
|
|
92
99
|
/** Show the Console, which displays the chat's configuration and history. */
|