@sveda-ai/react 0.3.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 +557 -0
- package/README.md +18 -0
- package/dist/appearance.d.ts +12 -0
- package/dist/appearance.d.ts.map +1 -0
- package/dist/components/SvedaChat.d.ts +14 -0
- package/dist/components/SvedaChat.d.ts.map +1 -0
- package/dist/components/shell/ChatHistoryList.d.ts +10 -0
- package/dist/components/shell/ChatHistoryList.d.ts.map +1 -0
- package/dist/components/shell/ChatMessageList.d.ts +7 -0
- package/dist/components/shell/ChatMessageList.d.ts.map +1 -0
- package/dist/components/shell/SvedaComposer.d.ts +11 -0
- package/dist/components/shell/SvedaComposer.d.ts.map +1 -0
- package/dist/components/shell/SvedaFrameTicks.d.ts +2 -0
- package/dist/components/shell/SvedaFrameTicks.d.ts.map +1 -0
- package/dist/components/shell/SvedaMinimizedTrigger.d.ts +9 -0
- package/dist/components/shell/SvedaMinimizedTrigger.d.ts.map +1 -0
- package/dist/components/shell/SvedaResizeHandles.d.ts +9 -0
- package/dist/components/shell/SvedaResizeHandles.d.ts.map +1 -0
- package/dist/components/shell/SvedaTabs.d.ts +13 -0
- package/dist/components/shell/SvedaTabs.d.ts.map +1 -0
- package/dist/components/shell/SvedaToolbar.d.ts +21 -0
- package/dist/components/shell/SvedaToolbar.d.ts.map +1 -0
- package/dist/hooks/useSvedaChat.d.ts +33 -0
- package/dist/hooks/useSvedaChat.d.ts.map +1 -0
- package/dist/hooks/useSvedaChatLayout.d.ts +25 -0
- package/dist/hooks/useSvedaChatLayout.d.ts.map +1 -0
- package/dist/hooks/useSvedaStreaming.d.ts +43 -0
- package/dist/hooks/useSvedaStreaming.d.ts.map +1 -0
- package/dist/i18n.d.ts +14 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1238 -0
- package/dist/launcherIcons.d.ts +5 -0
- package/dist/launcherIcons.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/provider.d.ts +15 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/styles.css +3 -0
- package/dist/types.d.ts +58 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +74 -0
- package/src/appearance.ts +81 -0
- package/src/components/SvedaChat.tsx +428 -0
- package/src/components/shell/ChatHistoryList.tsx +151 -0
- package/src/components/shell/ChatMessageList.tsx +52 -0
- package/src/components/shell/SvedaComposer.tsx +100 -0
- package/src/components/shell/SvedaFrameTicks.tsx +22 -0
- package/src/components/shell/SvedaMinimizedTrigger.tsx +41 -0
- package/src/components/shell/SvedaResizeHandles.tsx +51 -0
- package/src/components/shell/SvedaTabs.tsx +106 -0
- package/src/components/shell/SvedaToolbar.tsx +132 -0
- package/src/hooks/useSvedaChat.ts +91 -0
- package/src/hooks/useSvedaChatLayout.ts +281 -0
- package/src/hooks/useSvedaStreaming.ts +139 -0
- package/src/i18n.ts +51 -0
- package/src/index.ts +116 -0
- package/src/launcherIcons.ts +43 -0
- package/src/lib/utils.ts +6 -0
- package/src/markdown.css +96 -0
- package/src/provider.tsx +179 -0
- package/src/styles.css +6 -0
- package/src/theme.css +137 -0
- package/src/types.ts +70 -0
package/src/markdown.css
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
.sveda-chat .prose {
|
|
2
|
+
line-height: 1.55;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.sveda-chat .prose h1,
|
|
6
|
+
.sveda-chat .prose h2,
|
|
7
|
+
.sveda-chat .prose h3,
|
|
8
|
+
.sveda-chat .prose h4 {
|
|
9
|
+
color: inherit;
|
|
10
|
+
line-height: 1.3;
|
|
11
|
+
letter-spacing: -0.01em;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.sveda-chat .prose h1 {
|
|
15
|
+
font-size: 1.2rem;
|
|
16
|
+
font-weight: 700;
|
|
17
|
+
margin: 0.9em 0 0.35em;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.sveda-chat .prose h2 {
|
|
21
|
+
font-size: 1.08rem;
|
|
22
|
+
font-weight: 650;
|
|
23
|
+
margin: 0.85em 0 0.3em;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.sveda-chat .prose h3,
|
|
27
|
+
.sveda-chat .prose h4 {
|
|
28
|
+
font-size: 1rem;
|
|
29
|
+
font-weight: 600;
|
|
30
|
+
margin: 0.75em 0 0.25em;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.sveda-chat .prose h1:first-child,
|
|
34
|
+
.sveda-chat .prose h2:first-child,
|
|
35
|
+
.sveda-chat .prose h3:first-child,
|
|
36
|
+
.sveda-chat .prose h4:first-child {
|
|
37
|
+
margin-top: 0;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.sveda-chat .prose p {
|
|
41
|
+
margin: 0.45em 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.sveda-chat .prose p:first-child {
|
|
45
|
+
margin-top: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.sveda-chat .prose p:last-child {
|
|
49
|
+
margin-bottom: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.sveda-chat .prose ul,
|
|
53
|
+
.sveda-chat .prose ol {
|
|
54
|
+
margin: 0.4em 0;
|
|
55
|
+
padding-left: 1.25rem;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.sveda-chat .prose ul {
|
|
59
|
+
list-style-type: disc;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.sveda-chat .prose ol {
|
|
63
|
+
list-style-type: decimal;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.sveda-chat .prose li {
|
|
67
|
+
display: list-item;
|
|
68
|
+
margin: 0.2em 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.sveda-chat .prose li > p {
|
|
72
|
+
margin: 0.15em 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.sveda-chat .prose hr {
|
|
76
|
+
border: 0;
|
|
77
|
+
border-top: 1px solid hsl(var(--sveda-border));
|
|
78
|
+
margin: 0.9em 0;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.sveda-chat .prose a {
|
|
82
|
+
color: hsl(var(--sveda-brand));
|
|
83
|
+
text-decoration: underline;
|
|
84
|
+
text-underline-offset: 2px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.sveda-chat .prose blockquote {
|
|
88
|
+
margin: 0.5em 0;
|
|
89
|
+
padding-left: 0.75rem;
|
|
90
|
+
border-left: 2px solid hsl(var(--sveda-border));
|
|
91
|
+
color: hsl(var(--sveda-muted-foreground));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.sveda-chat .prose strong {
|
|
95
|
+
font-weight: 650;
|
|
96
|
+
}
|
package/src/provider.tsx
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { SvedaClient } from '@sveda-ai/core';
|
|
2
|
+
import type { SvedaClient as SvedaClientInstance } from '@sveda-ai/core';
|
|
3
|
+
import {
|
|
4
|
+
applySvedaAppearance,
|
|
5
|
+
mergeSvedaAppearance,
|
|
6
|
+
type SvedaAppearance,
|
|
7
|
+
} from './appearance';
|
|
8
|
+
import { chatComponentI18nKeys, enMessages, ruMessages } from '@sveda-ai/chat';
|
|
9
|
+
import {
|
|
10
|
+
createContext,
|
|
11
|
+
createElement,
|
|
12
|
+
useContext,
|
|
13
|
+
useMemo,
|
|
14
|
+
type ReactNode,
|
|
15
|
+
} from 'react';
|
|
16
|
+
import { createSvedaI18n, type SvedaMessages } from './i18n';
|
|
17
|
+
import {
|
|
18
|
+
DEFAULT_CONFIG,
|
|
19
|
+
type SvedaConfig,
|
|
20
|
+
type SvedaContextValue,
|
|
21
|
+
type SvedaProviderOptions,
|
|
22
|
+
} from './types';
|
|
23
|
+
|
|
24
|
+
const SvedaContext = createContext<SvedaContextValue | null>(null);
|
|
25
|
+
|
|
26
|
+
const scheduleEmbedAppearance = (stream: string): void => {
|
|
27
|
+
if (typeof fetch === 'undefined') {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
let origin = '';
|
|
32
|
+
try {
|
|
33
|
+
const url = new URL(stream);
|
|
34
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
origin = url.origin;
|
|
38
|
+
} catch {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void fetch(`${origin}/sveda/embed/config`)
|
|
43
|
+
.then((response) => (response.ok ? response.json() : null))
|
|
44
|
+
.then((config) => {
|
|
45
|
+
if (!config || typeof config !== 'object') {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
applySvedaAppearance(
|
|
50
|
+
mergeSvedaAppearance((config as { appearance?: SvedaAppearance | null }).appearance, undefined),
|
|
51
|
+
);
|
|
52
|
+
})
|
|
53
|
+
.catch(() => {});
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export function createSvedaContextValue(options: SvedaProviderOptions): SvedaContextValue {
|
|
57
|
+
const client = new SvedaClient({
|
|
58
|
+
endpoints: options.endpoints,
|
|
59
|
+
protocolMode: options.protocolMode,
|
|
60
|
+
headers: options.headers,
|
|
61
|
+
credentials: options.credentials,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const messages: Record<string, SvedaMessages> = {};
|
|
65
|
+
const mergeMessages = (locale: string, localeMessages: SvedaMessages) => {
|
|
66
|
+
messages[locale] = { ...(messages[locale] ?? {}), ...localeMessages };
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
for (const [locale, localeMessages] of Object.entries({ en: enMessages, ru: ruMessages })) {
|
|
70
|
+
mergeMessages(locale, localeMessages);
|
|
71
|
+
}
|
|
72
|
+
for (const [locale, localeMessages] of Object.entries(chatComponentI18nKeys)) {
|
|
73
|
+
mergeMessages(locale, localeMessages);
|
|
74
|
+
}
|
|
75
|
+
for (const [locale, localeMessages] of Object.entries(options.messages ?? {})) {
|
|
76
|
+
mergeMessages(locale, localeMessages);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const i18n = createSvedaI18n({
|
|
80
|
+
locale: options.locale ?? 'en',
|
|
81
|
+
messages,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const config: SvedaConfig = {
|
|
85
|
+
brand: {
|
|
86
|
+
name: options.brand?.name ?? 'Sveda',
|
|
87
|
+
logoUrl: options.brand?.logoUrl ?? null,
|
|
88
|
+
},
|
|
89
|
+
models: options.models ?? [],
|
|
90
|
+
quickPrompts: options.quickPrompts ?? [],
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
if (options.appearance !== undefined || options.theme !== undefined) {
|
|
94
|
+
if (options.appearance === null && options.theme === undefined) {
|
|
95
|
+
applySvedaAppearance(null);
|
|
96
|
+
} else {
|
|
97
|
+
applySvedaAppearance({
|
|
98
|
+
...(options.appearance && typeof options.appearance === 'object' ? options.appearance : {}),
|
|
99
|
+
...(options.theme ? { theme: options.theme } : {}),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
scheduleEmbedAppearance(options.endpoints.stream);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
client,
|
|
108
|
+
i18n,
|
|
109
|
+
config,
|
|
110
|
+
hostEmbed: Boolean(options.hostEmbed),
|
|
111
|
+
fillHost: Boolean(options.fillHost ?? options.hostEmbed),
|
|
112
|
+
hideLauncher: Boolean(options.hideLauncher),
|
|
113
|
+
beforeSend: options.beforeSend ?? null,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface SvedaProviderProps extends SvedaProviderOptions {
|
|
118
|
+
children: ReactNode;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function SvedaProvider({ children, ...options }: SvedaProviderProps) {
|
|
122
|
+
const value = useMemo(() => createSvedaContextValue(options), [
|
|
123
|
+
options.endpoints.stream,
|
|
124
|
+
options.endpoints.message,
|
|
125
|
+
options.endpoints.histories,
|
|
126
|
+
options.endpoints.documentsExtract,
|
|
127
|
+
options.protocolMode,
|
|
128
|
+
options.credentials,
|
|
129
|
+
options.locale,
|
|
130
|
+
options.theme,
|
|
131
|
+
options.hostEmbed,
|
|
132
|
+
options.fillHost,
|
|
133
|
+
options.hideLauncher,
|
|
134
|
+
options.brand?.name,
|
|
135
|
+
options.brand?.logoUrl,
|
|
136
|
+
options.appearance,
|
|
137
|
+
options.headers,
|
|
138
|
+
options.messages,
|
|
139
|
+
options.models,
|
|
140
|
+
options.quickPrompts,
|
|
141
|
+
options.beforeSend,
|
|
142
|
+
]);
|
|
143
|
+
|
|
144
|
+
return createElement(SvedaContext.Provider, { value }, children);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function useSvedaClient(): SvedaClientInstance {
|
|
148
|
+
const ctx = useContext(SvedaContext);
|
|
149
|
+
if (!ctx) {
|
|
150
|
+
throw new Error('[sveda] SvedaProvider is missing. Wrap your tree in <SvedaProvider> first.');
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return ctx.client;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function useSvedaConfig(): SvedaConfig {
|
|
157
|
+
const ctx = useContext(SvedaContext);
|
|
158
|
+
return ctx?.config ?? DEFAULT_CONFIG;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export function useSvedaContext(): SvedaContextValue {
|
|
162
|
+
const ctx = useContext(SvedaContext);
|
|
163
|
+
if (!ctx) {
|
|
164
|
+
throw new Error('[sveda] SvedaProvider is missing. Wrap your tree in <SvedaProvider> first.');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return ctx;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export function useSvedaT(): (key: string, params?: Record<string, unknown>) => string {
|
|
171
|
+
const ctx = useContext(SvedaContext);
|
|
172
|
+
if (!ctx) {
|
|
173
|
+
return (key: string) => key;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return (key, params) => ctx.i18n.t(key, params);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export { SvedaContext };
|
package/src/styles.css
ADDED
package/src/theme.css
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
:where(.sveda-chat, sveda-chat) {
|
|
2
|
+
--sveda-background: 0 0% 100%;
|
|
3
|
+
--sveda-foreground: 0 0% 4%;
|
|
4
|
+
--sveda-card: 0 0% 100%;
|
|
5
|
+
--sveda-card-foreground: 0 0% 4%;
|
|
6
|
+
--sveda-popover: 0 0% 100%;
|
|
7
|
+
--sveda-popover-foreground: 0 0% 4%;
|
|
8
|
+
--sveda-primary: 0 0% 4%;
|
|
9
|
+
--sveda-primary-foreground: 0 0% 100%;
|
|
10
|
+
--sveda-secondary: 40 20% 90%;
|
|
11
|
+
--sveda-secondary-foreground: 0 0% 4%;
|
|
12
|
+
--sveda-muted: 40 22% 90%;
|
|
13
|
+
--sveda-muted-foreground: 40 6% 41%;
|
|
14
|
+
--sveda-accent: 40 22% 90%;
|
|
15
|
+
--sveda-accent-foreground: 0 0% 4%;
|
|
16
|
+
--sveda-destructive: 0 84.2% 60.2%;
|
|
17
|
+
--sveda-destructive-foreground: 0 0% 98%;
|
|
18
|
+
--sveda-border: 42 18% 82%;
|
|
19
|
+
--sveda-input: 40 22% 92%;
|
|
20
|
+
--sveda-ring: 0 0% 4%;
|
|
21
|
+
--sveda-radius: 0;
|
|
22
|
+
--sveda-brand: 0 0% 4%;
|
|
23
|
+
--sveda-brand-foreground: 0 0% 100%;
|
|
24
|
+
--sveda-surface: hsl(var(--sveda-background));
|
|
25
|
+
--font-sans: Geist, ui-sans-serif, system-ui, sans-serif;
|
|
26
|
+
--font-serif: Newsreader, ui-serif, Georgia, serif;
|
|
27
|
+
--font-mono: 'Geist Mono', ui-monospace, monospace;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.sveda-chat,
|
|
31
|
+
sveda-chat {
|
|
32
|
+
--color-background: hsl(var(--sveda-background));
|
|
33
|
+
--color-foreground: hsl(var(--sveda-foreground));
|
|
34
|
+
--color-card: hsl(var(--sveda-card));
|
|
35
|
+
--color-card-foreground: hsl(var(--sveda-card-foreground));
|
|
36
|
+
--color-popover: hsl(var(--sveda-popover));
|
|
37
|
+
--color-popover-foreground: hsl(var(--sveda-popover-foreground));
|
|
38
|
+
--color-primary: hsl(var(--sveda-primary));
|
|
39
|
+
--color-primary-foreground: hsl(var(--sveda-primary-foreground));
|
|
40
|
+
--color-secondary: hsl(var(--sveda-secondary));
|
|
41
|
+
--color-secondary-foreground: hsl(var(--sveda-secondary-foreground));
|
|
42
|
+
--color-muted: hsl(var(--sveda-muted));
|
|
43
|
+
--color-muted-foreground: hsl(var(--sveda-muted-foreground));
|
|
44
|
+
--color-accent: hsl(var(--sveda-accent));
|
|
45
|
+
--color-accent-foreground: hsl(var(--sveda-accent-foreground));
|
|
46
|
+
--color-destructive: hsl(var(--sveda-destructive));
|
|
47
|
+
--color-destructive-foreground: hsl(var(--sveda-destructive-foreground));
|
|
48
|
+
--color-border: hsl(var(--sveda-border));
|
|
49
|
+
--color-input: hsl(var(--sveda-input));
|
|
50
|
+
--color-ring: hsl(var(--sveda-ring));
|
|
51
|
+
--color-brand-primary-purple: hsl(var(--sveda-brand));
|
|
52
|
+
--color-brand-primary-purple-foreground: hsl(var(--sveda-brand-foreground));
|
|
53
|
+
--radius: var(--sveda-radius);
|
|
54
|
+
--radius-xs: var(--sveda-radius);
|
|
55
|
+
--radius-sm: var(--sveda-radius);
|
|
56
|
+
--radius-md: var(--sveda-radius);
|
|
57
|
+
--radius-lg: var(--sveda-radius);
|
|
58
|
+
--radius-xl: var(--sveda-radius);
|
|
59
|
+
--radius-2xl: var(--sveda-radius);
|
|
60
|
+
--radius-3xl: var(--sveda-radius);
|
|
61
|
+
--radius-4xl: var(--sveda-radius);
|
|
62
|
+
font-family: var(--font-sans, Geist, ui-sans-serif, system-ui, sans-serif);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:where(.sveda-chat.dark, sveda-chat.dark, .dark .sveda-chat, .dark sveda-chat) {
|
|
66
|
+
--sveda-background: 30 12% 9%;
|
|
67
|
+
--sveda-foreground: 40 24% 94%;
|
|
68
|
+
--sveda-card: 30 10% 12%;
|
|
69
|
+
--sveda-card-foreground: 40 24% 94%;
|
|
70
|
+
--sveda-popover: 30 10% 12%;
|
|
71
|
+
--sveda-popover-foreground: 40 24% 94%;
|
|
72
|
+
--sveda-primary: 40 24% 94%;
|
|
73
|
+
--sveda-primary-foreground: 30 12% 9%;
|
|
74
|
+
--sveda-secondary: 30 8% 16%;
|
|
75
|
+
--sveda-secondary-foreground: 40 24% 94%;
|
|
76
|
+
--sveda-muted: 30 8% 16%;
|
|
77
|
+
--sveda-muted-foreground: 36 10% 62%;
|
|
78
|
+
--sveda-accent: 30 8% 16%;
|
|
79
|
+
--sveda-accent-foreground: 40 24% 94%;
|
|
80
|
+
--sveda-destructive: 0 62.8% 30.6%;
|
|
81
|
+
--sveda-destructive-foreground: 40 24% 94%;
|
|
82
|
+
--sveda-border: 30 8% 22%;
|
|
83
|
+
--sveda-input: 30 8% 16%;
|
|
84
|
+
--sveda-ring: 40 24% 94%;
|
|
85
|
+
--sveda-brand: 40 24% 94%;
|
|
86
|
+
--sveda-brand-foreground: 30 12% 9%;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.sveda-chat-surface {
|
|
90
|
+
background-color: var(--sveda-surface, hsl(var(--sveda-background)));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* Host pages often style input/textarea unlayered, which beats Tailwind utilities. */
|
|
94
|
+
.sveda-chat input[type='text'],
|
|
95
|
+
.sveda-chat input[type='search'],
|
|
96
|
+
.sveda-chat input:not([type]),
|
|
97
|
+
.sveda-chat textarea {
|
|
98
|
+
box-sizing: border-box;
|
|
99
|
+
width: auto;
|
|
100
|
+
max-width: 100%;
|
|
101
|
+
margin: 0;
|
|
102
|
+
border: 0;
|
|
103
|
+
border-radius: var(--sveda-radius, 0);
|
|
104
|
+
background: transparent;
|
|
105
|
+
padding: 0;
|
|
106
|
+
min-height: 0;
|
|
107
|
+
box-shadow: none;
|
|
108
|
+
font: inherit;
|
|
109
|
+
color: inherit;
|
|
110
|
+
letter-spacing: inherit;
|
|
111
|
+
resize: none;
|
|
112
|
+
appearance: none;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.sveda-chat .sveda-chat-input-textarea {
|
|
116
|
+
width: 100%;
|
|
117
|
+
min-height: 60px;
|
|
118
|
+
max-height: 250px;
|
|
119
|
+
padding: 0.75rem;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.sveda-chat-frame,
|
|
123
|
+
.sveda-chat .sveda-chat-frame,
|
|
124
|
+
sveda-chat .sveda-chat-frame {
|
|
125
|
+
border: 1px dashed hsl(var(--sveda-foreground));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.sveda-chat ::selection,
|
|
129
|
+
sveda-chat ::selection {
|
|
130
|
+
background: hsl(var(--sveda-foreground));
|
|
131
|
+
color: hsl(var(--sveda-background));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
body.sveda-chat-immersive-mode {
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
overscroll-behavior: none;
|
|
137
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { SvedaClient } from '@sveda-ai/core';
|
|
2
|
+
import type { SvedaI18n } from './i18n';
|
|
3
|
+
|
|
4
|
+
export interface SvedaModelOption {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
supportsThinking?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface SvedaQuickPrompt {
|
|
11
|
+
label: string;
|
|
12
|
+
prompt: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SvedaBrand {
|
|
16
|
+
name?: string;
|
|
17
|
+
logoUrl?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type SvedaBeforeSend = () => void | Promise<void>;
|
|
21
|
+
|
|
22
|
+
export interface SvedaProviderOptions {
|
|
23
|
+
endpoints: {
|
|
24
|
+
stream: string;
|
|
25
|
+
message?: string;
|
|
26
|
+
histories?: string;
|
|
27
|
+
documentsExtract?: string;
|
|
28
|
+
};
|
|
29
|
+
protocolMode?: 'sveda' | 'vercel';
|
|
30
|
+
headers?: Record<string, string> | (() => Record<string, string>);
|
|
31
|
+
credentials?: RequestCredentials;
|
|
32
|
+
locale?: string;
|
|
33
|
+
messages?: Record<string, Record<string, string>>;
|
|
34
|
+
brand?: SvedaBrand;
|
|
35
|
+
models?: SvedaModelOption[];
|
|
36
|
+
quickPrompts?: SvedaQuickPrompt[];
|
|
37
|
+
appearance?: import('./appearance').SvedaAppearance | null;
|
|
38
|
+
theme?: 'light' | 'dark';
|
|
39
|
+
hostEmbed?: boolean;
|
|
40
|
+
fillHost?: boolean;
|
|
41
|
+
hideLauncher?: boolean;
|
|
42
|
+
beforeSend?: SvedaBeforeSend;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface SvedaConfig {
|
|
46
|
+
brand: {
|
|
47
|
+
name: string;
|
|
48
|
+
logoUrl: string | null;
|
|
49
|
+
};
|
|
50
|
+
models: SvedaModelOption[];
|
|
51
|
+
quickPrompts: SvedaQuickPrompt[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface SvedaContextValue {
|
|
55
|
+
client: SvedaClient;
|
|
56
|
+
i18n: SvedaI18n;
|
|
57
|
+
config: SvedaConfig;
|
|
58
|
+
hostEmbed: boolean;
|
|
59
|
+
fillHost: boolean;
|
|
60
|
+
hideLauncher: boolean;
|
|
61
|
+
beforeSend: SvedaBeforeSend | null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const SVEDA_EMBED_AUTH_EVENT = 'sveda-embed-auth';
|
|
65
|
+
|
|
66
|
+
export const DEFAULT_CONFIG: SvedaConfig = {
|
|
67
|
+
brand: { name: 'Sveda', logoUrl: null },
|
|
68
|
+
models: [],
|
|
69
|
+
quickPrompts: [],
|
|
70
|
+
};
|