@chatsdk-dev/elements 0.0.1 → 0.1.3
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 +3 -3
- package/dist/api-CIYPz72L.d.ts +10 -0
- package/dist/api-CIYPz72L.d.ts.map +1 -0
- package/dist/callbacks-PIvHXeEI.d.ts +24 -0
- package/dist/callbacks-PIvHXeEI.d.ts.map +1 -0
- package/dist/chat-element-CCsDDFif.js +441 -0
- package/dist/chat-element-CCsDDFif.js.map +1 -0
- package/dist/chat-element-CSpa62Te.d.ts +53 -0
- package/dist/chat-element-CSpa62Te.d.ts.map +1 -0
- package/dist/chatsdk-provider-BhlChLFd.d.ts +15 -0
- package/dist/chatsdk-provider-BhlChLFd.d.ts.map +1 -0
- package/dist/common/utils.d.ts +14 -0
- package/dist/common/utils.d.ts.map +1 -0
- package/dist/common/utils.js +26 -0
- package/dist/common/utils.js.map +1 -0
- package/dist/components/info-card.d.ts +20 -11
- package/dist/components/info-card.d.ts.map +1 -0
- package/dist/components/info-card.js +38 -1
- package/dist/components/info-card.js.map +1 -0
- package/dist/config-BigIL6TQ.js +29 -0
- package/dist/config-BigIL6TQ.js.map +1 -0
- package/dist/config-CqihvSgz.d.ts +150 -0
- package/dist/config-CqihvSgz.d.ts.map +1 -0
- package/dist/config-D_jVTH_D.d.ts +58 -0
- package/dist/config-D_jVTH_D.d.ts.map +1 -0
- package/dist/context-aSaHw-ac.d.ts +13 -0
- package/dist/context-aSaHw-ac.d.ts.map +1 -0
- package/dist/element-provider-C_nBsftD.d.ts +40 -0
- package/dist/element-provider-C_nBsftD.d.ts.map +1 -0
- package/dist/features/chat/chat-card.d.ts +5 -3
- package/dist/features/chat/chat-card.d.ts.map +1 -0
- package/dist/features/chat/chat-card.js +2 -14
- package/dist/features/chat/chat-element.d.ts +2 -0
- package/dist/features/chat/chat-element.js +2 -0
- package/dist/features/chat/chat-header/chat-header.d.ts +8 -4
- package/dist/features/chat/chat-header/chat-header.d.ts.map +1 -0
- package/dist/features/chat/chat-header/chat-header.js +2 -14
- package/dist/features/chat/chat-header/chat-menu.d.ts +5 -3
- package/dist/features/chat/chat-header/chat-menu.d.ts.map +1 -0
- package/dist/features/chat/chat-header/chat-menu.js +29 -2
- package/dist/features/chat/chat-header/chat-menu.js.map +1 -0
- package/dist/features/chat/chat-history/chat-history-empty.d.ts +5 -3
- package/dist/features/chat/chat-history/chat-history-empty.d.ts.map +1 -0
- package/dist/features/chat/chat-history/chat-history-empty.js +24 -1
- package/dist/features/chat/chat-history/chat-history-empty.js.map +1 -0
- package/dist/features/chat/chat-history/chat-history.d.ts +5 -3
- package/dist/features/chat/chat-history/chat-history.d.ts.map +1 -0
- package/dist/features/chat/chat-history/chat-history.js +2 -14
- package/dist/features/chat/chat-main/chat-main.d.ts +10 -0
- package/dist/features/chat/chat-main/chat-main.d.ts.map +1 -0
- package/dist/features/chat/chat-main/chat-main.js +3 -0
- package/dist/features/chat/chat-main/use-chat.d.ts +23 -0
- package/dist/features/chat/chat-main/use-chat.d.ts.map +1 -0
- package/dist/features/chat/chat-main/use-chat.js +3 -0
- package/dist/features/chat/chat-main/use-initial-messages.d.ts +22 -0
- package/dist/features/chat/chat-main/use-initial-messages.d.ts.map +1 -0
- package/dist/features/chat/chat-main/use-initial-messages.js +2 -0
- package/dist/features/chat/chat-prompt-input.d.ts +20 -12
- package/dist/features/chat/chat-prompt-input.d.ts.map +1 -0
- package/dist/features/chat/chat-prompt-input.js +3 -14
- package/dist/features/chat/chat.context.d.ts +17 -15
- package/dist/features/chat/chat.context.d.ts.map +1 -0
- package/dist/features/chat/chat.context.js +9 -12
- package/dist/features/chat/chat.context.js.map +1 -0
- package/dist/features/chat/index.d.ts +2 -14
- package/dist/features/chat/index.js +2 -14
- package/dist/features/chat/queries/query-keys.d.ts +7 -5
- package/dist/features/chat/queries/query-keys.d.ts.map +1 -0
- package/dist/features/chat/queries/query-keys.js +19 -1
- package/dist/features/chat/queries/query-keys.js.map +1 -0
- package/dist/features/chat/queries/use-create-conversation-mutation.d.ts +27 -23
- package/dist/features/chat/queries/use-create-conversation-mutation.d.ts.map +1 -0
- package/dist/features/chat/queries/use-create-conversation-mutation.js +17 -36
- package/dist/features/chat/queries/use-create-conversation-mutation.js.map +1 -0
- package/dist/features/chat/queries/use-get-chat-query.d.ts +9 -5
- package/dist/features/chat/queries/use-get-chat-query.d.ts.map +1 -0
- package/dist/features/chat/queries/use-get-chat-query.js +2 -14
- package/dist/features/chat/queries/use-get-conversation-query.d.ts +56 -46
- package/dist/features/chat/queries/use-get-conversation-query.d.ts.map +1 -0
- package/dist/features/chat/queries/use-get-conversation-query.js +2 -14
- package/dist/features/chat/queries/use-list-conversations-query.d.ts +27 -23
- package/dist/features/chat/queries/use-list-conversations-query.d.ts.map +1 -0
- package/dist/features/chat/queries/use-list-conversations-query.js +2 -14
- package/dist/features/chat/store.d.ts +10 -8
- package/dist/features/chat/store.d.ts.map +1 -0
- package/dist/features/chat/store.js +15 -1
- package/dist/features/chat/store.js.map +1 -0
- package/dist/features/chat/utils.d.ts +4 -2
- package/dist/features/chat/utils.d.ts.map +1 -0
- package/dist/features/chat/utils.js +15 -1
- package/dist/features/chat/utils.js.map +1 -0
- package/dist/features/data-fetching/use-api-client.d.ts +5 -3
- package/dist/features/data-fetching/use-api-client.d.ts.map +1 -0
- package/dist/features/data-fetching/use-api-client.js +2 -14
- package/dist/features/element/chatsdk-provider.d.ts +2 -0
- package/dist/features/element/chatsdk-provider.js +23 -0
- package/dist/features/element/chatsdk-provider.js.map +1 -0
- package/dist/features/element/constants.d.ts +5 -0
- package/dist/features/element/constants.d.ts.map +1 -0
- package/dist/features/element/constants.js +6 -0
- package/dist/features/element/constants.js.map +1 -0
- package/dist/features/element/element-provider.d.ts +2 -0
- package/dist/features/element/element-provider.js +83 -0
- package/dist/features/element/element-provider.js.map +1 -0
- package/dist/features/element/store.d.ts +2 -0
- package/dist/features/element/store.js +112 -0
- package/dist/features/element/store.js.map +1 -0
- package/dist/features/element/types/api.d.ts +2 -0
- package/dist/features/element/types/api.js +1 -0
- package/dist/features/element/types/callbacks.d.ts +2 -0
- package/dist/features/element/types/callbacks.js +1 -0
- package/dist/features/element/types/config.d.ts +2 -0
- package/dist/features/element/types/config.js +1 -0
- package/dist/features/element/types/context.d.ts +2 -0
- package/dist/features/element/types/context.js +1 -0
- package/dist/features/element/types/locale.d.ts +2 -0
- package/dist/features/element/types/locale.js +1 -0
- package/dist/features/element/types/theme.d.ts +2 -0
- package/dist/features/element/types/theme.js +1 -0
- package/dist/features/element/types/translations.d.ts +2 -0
- package/dist/features/element/types/translations.js +1 -0
- package/dist/features/element/use-element-config.d.ts +40 -0
- package/dist/features/element/use-element-config.d.ts.map +1 -0
- package/dist/features/element/use-element-config.js +39 -0
- package/dist/features/element/use-element-config.js.map +1 -0
- package/dist/features/element/use-merge-global-config.d.ts +20 -0
- package/dist/features/element/use-merge-global-config.d.ts.map +1 -0
- package/dist/features/element/use-merge-global-config.js +34 -0
- package/dist/features/element/use-merge-global-config.js.map +1 -0
- package/dist/features/element/utils.d.ts +2 -0
- package/dist/features/element/utils.js +86 -0
- package/dist/features/element/utils.js.map +1 -0
- package/dist/features/logger/logger.d.ts +2 -9
- package/dist/features/logger/logger.js +15 -1
- package/dist/features/logger/logger.js.map +1 -0
- package/dist/i18n/config.d.ts +2 -61
- package/dist/i18n/config.js +2 -1
- package/dist/i18n/i18next.d.ts +1382 -10
- package/dist/i18n/i18next.d.ts.map +1 -0
- package/dist/i18n/i18next.js +27 -2
- package/dist/i18n/i18next.js.map +1 -0
- package/dist/i18n/utils.d.ts +4 -3
- package/dist/i18n/utils.d.ts.map +1 -0
- package/dist/i18n/utils.js +10 -3
- package/dist/i18n/utils.js.map +1 -0
- package/dist/index.d.ts +5 -20
- package/dist/index.js +68 -20
- package/dist/index.js.map +1 -0
- package/dist/locale-W5Kyyi4X.d.ts +11 -0
- package/dist/locale-W5Kyyi4X.d.ts.map +1 -0
- package/dist/logger-BvmhODdq.d.ts +11 -0
- package/dist/logger-BvmhODdq.d.ts.map +1 -0
- package/dist/store-CGX9oRlE.d.ts +46 -0
- package/dist/store-CGX9oRlE.d.ts.map +1 -0
- package/dist/styles.css +1954 -1963
- package/dist/theme-Cb-RBWbR.d.ts +38 -0
- package/dist/theme-Cb-RBWbR.d.ts.map +1 -0
- package/package.json +18 -50
- package/dist/chunk-2LHKM7RD.js +0 -14
- package/dist/chunk-5UMYP6MD.js +0 -10
- package/dist/chunk-AP4MG32M.js +0 -36
- package/dist/chunk-CFM57HOS.js +0 -358
- package/dist/chunk-EGIUE7H2.js +0 -37
- package/dist/chunk-M5OONVIO.js +0 -90
- package/dist/chunk-MXTBCHYC.js +0 -31
- package/dist/chunk-NIC3MOMY.js +0 -55
- package/dist/chunk-QTRMNIG3.js +0 -83
- package/dist/chunk-R7G3RQLU.js +0 -36
- package/dist/chunk-RJG5D2TM.js +0 -113
- package/dist/chunk-SLJNKQ2G.js +0 -125
- package/dist/chunk-TDEFIW2L.js +0 -9
- package/dist/chunk-TDP6D7U7.js +0 -551
- package/dist/chunk-V2ITXC65.js +0 -24
- package/dist/chunk-VS55HRUS.js +0 -16
- package/dist/chunk-VYDYCGJL.js +0 -25
- package/dist/chunk-X5YUF2YM.js +0 -113
- package/dist/chunk-YX46JVQN.js +0 -78
- package/dist/chunk-YXAMLTTT.js +0 -16
- package/dist/chunk-YXFVHSY4.js +0 -51
- package/dist/chunk-ZCSZX3OI.js +0 -4
- package/dist/common/use-copy-to-clipboard.d.ts +0 -3
- package/dist/common/use-copy-to-clipboard.js +0 -33
- package/dist/common/utilts.d.ts +0 -8
- package/dist/common/utilts.js +0 -28
- package/dist/components/ai-elements/actions.d.ts +0 -13
- package/dist/components/ai-elements/actions.js +0 -42
- package/dist/components/ai-elements/agent.d.ts +0 -31
- package/dist/components/ai-elements/agent.js +0 -77
- package/dist/components/ai-elements/artifact.d.ts +0 -27
- package/dist/components/ai-elements/artifact.js +0 -108
- package/dist/components/ai-elements/attachments.d.ts +0 -57
- package/dist/components/ai-elements/attachments.js +0 -258
- package/dist/components/ai-elements/audio-player.d.ts +0 -33
- package/dist/components/ai-elements/audio-player.js +0 -199
- package/dist/components/ai-elements/canvas.d.ts +0 -10
- package/dist/components/ai-elements/canvas.js +0 -24
- package/dist/components/ai-elements/chain-of-thought.d.ts +0 -34
- package/dist/components/ai-elements/chain-of-thought.js +0 -159
- package/dist/components/ai-elements/checkpoint.d.ts +0 -16
- package/dist/components/ai-elements/checkpoint.js +0 -47
- package/dist/components/ai-elements/code-block.d.ts +0 -48
- package/dist/components/ai-elements/code-block.js +0 -1
- package/dist/components/ai-elements/commit.d.ts +0 -68
- package/dist/components/ai-elements/commit.js +0 -314
- package/dist/components/ai-elements/confirmation.d.ts +0 -52
- package/dist/components/ai-elements/confirmation.js +0 -76
- package/dist/components/ai-elements/connection.d.ts +0 -5
- package/dist/components/ai-elements/connection.js +0 -34
- package/dist/components/ai-elements/context.d.ts +0 -36
- package/dist/components/ai-elements/context.js +0 -320
- package/dist/components/ai-elements/controls.d.ts +0 -8
- package/dist/components/ai-elements/controls.js +0 -17
- package/dist/components/ai-elements/conversation.d.ts +0 -27
- package/dist/components/ai-elements/conversation.js +0 -119
- package/dist/components/ai-elements/edge.d.ts +0 -9
- package/dist/components/ai-elements/edge.js +0 -111
- package/dist/components/ai-elements/environment-variables.d.ts +0 -42
- package/dist/components/ai-elements/environment-variables.js +0 -208
- package/dist/components/ai-elements/file-tree.d.ts +0 -30
- package/dist/components/ai-elements/file-tree.js +0 -212
- package/dist/components/ai-elements/image.d.ts +0 -10
- package/dist/components/ai-elements/image.js +0 -23
- package/dist/components/ai-elements/inline-citation.d.ts +0 -42
- package/dist/components/ai-elements/inline-citation.js +0 -203
- package/dist/components/ai-elements/jsx-preview.d.ts +0 -33
- package/dist/components/ai-elements/jsx-preview.js +0 -206
- package/dist/components/ai-elements/loader.d.ts +0 -9
- package/dist/components/ai-elements/loader.js +0 -115
- package/dist/components/ai-elements/message.d.ts +0 -42
- package/dist/components/ai-elements/message.js +0 -259
- package/dist/components/ai-elements/mic-selector.d.ts +0 -49
- package/dist/components/ai-elements/mic-selector.js +0 -252
- package/dist/components/ai-elements/model-selector.d.ts +0 -39
- package/dist/components/ai-elements/model-selector.js +0 -73
- package/dist/components/ai-elements/node.d.ts +0 -25
- package/dist/components/ai-elements/node.js +0 -41
- package/dist/components/ai-elements/open-in-chat.d.ts +0 -32
- package/dist/components/ai-elements/open-in-chat.js +0 -366
- package/dist/components/ai-elements/package-info.d.ts +0 -32
- package/dist/components/ai-elements/package-info.js +0 -162
- package/dist/components/ai-elements/panel.d.ts +0 -8
- package/dist/components/ai-elements/panel.js +0 -17
- package/dist/components/ai-elements/persona.d.ts +0 -50
- package/dist/components/ai-elements/persona.js +0 -209
- package/dist/components/ai-elements/plan.d.ts +0 -29
- package/dist/components/ai-elements/plan.js +0 -95
- package/dist/components/ai-elements/prompt-input.d.ts +0 -153
- package/dist/components/ai-elements/prompt-input.js +0 -939
- package/dist/components/ai-elements/queue.d.ts +0 -65
- package/dist/components/ai-elements/queue.js +0 -179
- package/dist/components/ai-elements/reasoning.d.ts +0 -30
- package/dist/components/ai-elements/reasoning.js +0 -161
- package/dist/components/ai-elements/response.d.ts +0 -9
- package/dist/components/ai-elements/response.js +0 -33
- package/dist/components/ai-elements/sandbox.d.ts +0 -28
- package/dist/components/ai-elements/sandbox.js +0 -98
- package/dist/components/ai-elements/schema-display.d.ts +0 -58
- package/dist/components/ai-elements/schema-display.js +0 -313
- package/dist/components/ai-elements/shimmer.d.ts +0 -14
- package/dist/components/ai-elements/shimmer.js +0 -1
- package/dist/components/ai-elements/snippet.d.ts +0 -22
- package/dist/components/ai-elements/snippet.js +0 -90
- package/dist/components/ai-elements/sources.d.ts +0 -16
- package/dist/components/ai-elements/sources.js +0 -62
- package/dist/components/ai-elements/speech-input.d.ts +0 -57
- package/dist/components/ai-elements/speech-input.js +0 -206
- package/dist/components/ai-elements/stack-trace.d.ts +0 -42
- package/dist/components/ai-elements/stack-trace.js +0 -377
- package/dist/components/ai-elements/suggestion.d.ts +0 -14
- package/dist/components/ai-elements/suggestion.js +0 -41
- package/dist/components/ai-elements/task.d.ts +0 -18
- package/dist/components/ai-elements/task.js +0 -60
- package/dist/components/ai-elements/terminal.d.ts +0 -31
- package/dist/components/ai-elements/terminal.js +0 -203
- package/dist/components/ai-elements/test-results.d.ts +0 -61
- package/dist/components/ai-elements/test-results.js +0 -349
- package/dist/components/ai-elements/tool.d.ts +0 -35
- package/dist/components/ai-elements/tool.js +0 -2
- package/dist/components/ai-elements/toolbar.d.ts +0 -8
- package/dist/components/ai-elements/toolbar.js +0 -18
- package/dist/components/ai-elements/transcription.d.ts +0 -19
- package/dist/components/ai-elements/transcription.js +0 -90
- package/dist/components/ai-elements/voice-selector.d.ts +0 -66
- package/dist/components/ai-elements/voice-selector.js +0 -332
- package/dist/components/ai-elements/web-preview.d.ts +0 -38
- package/dist/components/ai-elements/web-preview.js +0 -214
- package/dist/components/responsive-alert-dialog.d.ts +0 -19
- package/dist/components/responsive-alert-dialog.js +0 -1
- package/dist/components/responsive-dialog.d.ts +0 -14
- package/dist/components/responsive-dialog.js +0 -1
- package/dist/config-IcWUmjwj.d.ts +0 -239
- package/dist/features/chat/chat-element/chat-element.d.ts +0 -8
- package/dist/features/chat/chat-element/chat-element.js +0 -14
- package/dist/features/chat/chat-element/use-chat.d.ts +0 -21
- package/dist/features/chat/chat-element/use-chat.js +0 -14
- package/dist/features/chat/chat-element/use-initial-messages.d.ts +0 -20
- package/dist/features/chat/chat-element/use-initial-messages.js +0 -14
- package/dist/features/chat/chat-message.d.ts +0 -10
- package/dist/features/chat/chat-message.js +0 -1
- package/dist/features/chat/chat-molecule.d.ts +0 -35
- package/dist/features/chat/chat-molecule.js +0 -14
- package/dist/features/molecule/chatsdk-provider.d.ts +0 -19
- package/dist/features/molecule/chatsdk-provider.js +0 -26
- package/dist/features/molecule/constants.d.ts +0 -3
- package/dist/features/molecule/constants.js +0 -1
- package/dist/features/molecule/molecule-provider.d.ts +0 -39
- package/dist/features/molecule/molecule-provider.js +0 -1
- package/dist/features/molecule/store.d.ts +0 -53
- package/dist/features/molecule/store.js +0 -3
- package/dist/features/molecule/types/api.d.ts +0 -8
- package/dist/features/molecule/types/api.js +0 -1
- package/dist/features/molecule/types/callbacks.d.ts +0 -22
- package/dist/features/molecule/types/callbacks.js +0 -1
- package/dist/features/molecule/types/config.d.ts +0 -10
- package/dist/features/molecule/types/config.js +0 -1
- package/dist/features/molecule/types/context.d.ts +0 -11
- package/dist/features/molecule/types/context.js +0 -1
- package/dist/features/molecule/types/locale.d.ts +0 -9
- package/dist/features/molecule/types/locale.js +0 -1
- package/dist/features/molecule/types/theme.d.ts +0 -38
- package/dist/features/molecule/types/theme.js +0 -1
- package/dist/features/molecule/types/translations.d.ts +0 -10
- package/dist/features/molecule/types/translations.js +0 -1
- package/dist/features/molecule/use-merge-global-config.d.ts +0 -22
- package/dist/features/molecule/use-merge-global-config.js +0 -5
- package/dist/features/molecule/use-molecule-config.d.ts +0 -41
- package/dist/features/molecule/use-molecule-config.js +0 -6
- package/dist/features/molecule/utils.d.ts +0 -10
- package/dist/features/molecule/utils.js +0 -1
package/dist/chunk-TDP6D7U7.js
DELETED
|
@@ -1,551 +0,0 @@
|
|
|
1
|
-
import { ChatMenu } from './chunk-AP4MG32M.js';
|
|
2
|
-
import { ChatHistoryEmpty } from './chunk-YXAMLTTT.js';
|
|
3
|
-
import { chatQueryKeys } from './chunk-TDEFIW2L.js';
|
|
4
|
-
import { createMoleculeContext } from './chunk-M5OONVIO.js';
|
|
5
|
-
import { useMergeMoleculeConfig } from './chunk-VYDYCGJL.js';
|
|
6
|
-
import { useChatStore } from './chunk-2LHKM7RD.js';
|
|
7
|
-
import { getInitialMessagesFromStrings } from './chunk-5UMYP6MD.js';
|
|
8
|
-
import { ChatMessage } from './chunk-SLJNKQ2G.js';
|
|
9
|
-
import { getClient } from '@chatsdk-dev/api-client';
|
|
10
|
-
import { useTranslation } from 'react-i18next';
|
|
11
|
-
import { CardHeader, CardTitle, Card } from '@chatsdk-dev/ui/components/card';
|
|
12
|
-
import { DotsLoader } from '@chatsdk-dev/ui/components/dots-loader';
|
|
13
|
-
import { Text } from '@chatsdk-dev/ui/components/typography/text';
|
|
14
|
-
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
15
|
-
import { useState, useMemo, useEffect, useRef, Fragment } from 'react';
|
|
16
|
-
import { Conversation, ConversationContent, ConversationScrollButton } from '@chatsdk-dev/elements/components/ai-elements/conversation';
|
|
17
|
-
import { GlobeIcon, CheckIcon, ArrowLeft, Plus } from 'lucide-react';
|
|
18
|
-
import { PromptInput, PromptInputTextarea, PromptInputSubmit, PromptInputTools, PromptInputButton } from '@chatsdk-dev/elements/components/ai-elements/prompt-input';
|
|
19
|
-
import { ModelSelector, ModelSelectorTrigger, ModelSelectorLogo, ModelSelectorName, ModelSelectorContent, ModelSelectorInput, ModelSelectorList, ModelSelectorEmpty, ModelSelectorGroup, ModelSelectorItem, ModelSelectorLogoGroup } from '@chatsdk-dev/elements/components/ai-elements/model-selector';
|
|
20
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
21
|
-
import { useChat as useChat$1 } from '@ai-sdk/react';
|
|
22
|
-
import { DefaultChatTransport } from 'ai';
|
|
23
|
-
import { Button } from '@chatsdk-dev/ui/components/button';
|
|
24
|
-
import { renderRelativeTime } from '@chatsdk-dev/elements/common/utilts';
|
|
25
|
-
|
|
26
|
-
function useGetChatQuery({ chatId }) {
|
|
27
|
-
const client = useApiClient();
|
|
28
|
-
return useQuery({
|
|
29
|
-
queryKey: chatQueryKeys.get(chatId),
|
|
30
|
-
queryFn: async () => {
|
|
31
|
-
const { data, error } = await client.chats.get({
|
|
32
|
-
path: { chatId }
|
|
33
|
-
});
|
|
34
|
-
if (error) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
"error" in error ? error.error : "Failed to fetch chat"
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
return data;
|
|
40
|
-
},
|
|
41
|
-
enabled: !!chatId
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
function ChatPromptInput({
|
|
45
|
-
chatId,
|
|
46
|
-
onSubmit,
|
|
47
|
-
onModelChange,
|
|
48
|
-
status,
|
|
49
|
-
ref
|
|
50
|
-
}) {
|
|
51
|
-
const { data } = useGetChatQuery({ chatId });
|
|
52
|
-
const defaultModel = data?.chatModelSettings?.defaultModel;
|
|
53
|
-
const allowedModels = data?.chatModelSettings?.allowedModels;
|
|
54
|
-
const [input, setInput] = useState("");
|
|
55
|
-
const [model, setModel] = useState(defaultModel?.name);
|
|
56
|
-
const [modelSelectorOpen, setModelSelectorOpen] = useState(false);
|
|
57
|
-
const [webSearch, setWebSearch] = useState(false);
|
|
58
|
-
const selectedModel = allowedModels?.find((m) => m.name === model);
|
|
59
|
-
const modelGroups = allowedModels?.map((m) => m.chef);
|
|
60
|
-
const hasMultipleModels = allowedModels && allowedModels.length > 1;
|
|
61
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
62
|
-
/* @__PURE__ */ jsxs(
|
|
63
|
-
PromptInput,
|
|
64
|
-
{
|
|
65
|
-
onSubmit: (message, event) => {
|
|
66
|
-
onSubmit(message, event);
|
|
67
|
-
setInput("");
|
|
68
|
-
},
|
|
69
|
-
children: [
|
|
70
|
-
/* @__PURE__ */ jsx(
|
|
71
|
-
PromptInputTextarea,
|
|
72
|
-
{
|
|
73
|
-
ref,
|
|
74
|
-
placeholder: data?.chatBaseSettings?.inputPlaceholder,
|
|
75
|
-
onChange: (e) => setInput(e.target.value),
|
|
76
|
-
value: input
|
|
77
|
-
}
|
|
78
|
-
),
|
|
79
|
-
/* @__PURE__ */ jsx(
|
|
80
|
-
PromptInputSubmit,
|
|
81
|
-
{
|
|
82
|
-
className: "m-1.5 self-end",
|
|
83
|
-
disabled: !input,
|
|
84
|
-
status
|
|
85
|
-
}
|
|
86
|
-
)
|
|
87
|
-
]
|
|
88
|
-
}
|
|
89
|
-
),
|
|
90
|
-
/* @__PURE__ */ jsxs(PromptInputTools, { children: [
|
|
91
|
-
/* @__PURE__ */ jsxs(
|
|
92
|
-
PromptInputButton,
|
|
93
|
-
{
|
|
94
|
-
variant: webSearch ? "primary" : "ghost",
|
|
95
|
-
onClick: () => setWebSearch(!webSearch),
|
|
96
|
-
children: [
|
|
97
|
-
/* @__PURE__ */ jsx(GlobeIcon, { size: 16 }),
|
|
98
|
-
/* @__PURE__ */ jsx("span", { children: "Search" })
|
|
99
|
-
]
|
|
100
|
-
}
|
|
101
|
-
),
|
|
102
|
-
hasMultipleModels && /* @__PURE__ */ jsxs(
|
|
103
|
-
ModelSelector,
|
|
104
|
-
{
|
|
105
|
-
onOpenChange: setModelSelectorOpen,
|
|
106
|
-
open: modelSelectorOpen,
|
|
107
|
-
children: [
|
|
108
|
-
/* @__PURE__ */ jsx(ModelSelectorTrigger, { children: /* @__PURE__ */ jsxs(PromptInputButton, { children: [
|
|
109
|
-
selectedModel?.chefSlug && /* @__PURE__ */ jsx(ModelSelectorLogo, { provider: selectedModel.chefSlug }),
|
|
110
|
-
/* @__PURE__ */ jsx(ModelSelectorName, { children: selectedModel?.name })
|
|
111
|
-
] }) }),
|
|
112
|
-
/* @__PURE__ */ jsxs(ModelSelectorContent, { children: [
|
|
113
|
-
/* @__PURE__ */ jsx(ModelSelectorInput, { placeholder: "Search models..." }),
|
|
114
|
-
/* @__PURE__ */ jsxs(ModelSelectorList, { children: [
|
|
115
|
-
/* @__PURE__ */ jsx(ModelSelectorEmpty, { children: "No models found." }),
|
|
116
|
-
modelGroups?.map((chef) => /* @__PURE__ */ jsx(ModelSelectorGroup, { heading: chef, children: allowedModels.filter((m) => m.chef === chef).map((m) => /* @__PURE__ */ jsxs(
|
|
117
|
-
ModelSelectorItem,
|
|
118
|
-
{
|
|
119
|
-
onSelect: () => {
|
|
120
|
-
setModel(m.name);
|
|
121
|
-
onModelChange?.(m);
|
|
122
|
-
setModelSelectorOpen(false);
|
|
123
|
-
},
|
|
124
|
-
value: m.name,
|
|
125
|
-
children: [
|
|
126
|
-
/* @__PURE__ */ jsx(ModelSelectorLogo, { provider: m.chefSlug }),
|
|
127
|
-
/* @__PURE__ */ jsx(ModelSelectorName, { children: m.name }),
|
|
128
|
-
/* @__PURE__ */ jsx(ModelSelectorLogoGroup, { children: m.providers.map((provider) => /* @__PURE__ */ jsx(
|
|
129
|
-
ModelSelectorLogo,
|
|
130
|
-
{
|
|
131
|
-
provider
|
|
132
|
-
},
|
|
133
|
-
provider
|
|
134
|
-
)) }),
|
|
135
|
-
selectedModel?.name === m.name ? /* @__PURE__ */ jsx(CheckIcon, { className: "ml-auto size-4" }) : /* @__PURE__ */ jsx("div", { className: "ml-auto size-4" })
|
|
136
|
-
]
|
|
137
|
-
},
|
|
138
|
-
m.name
|
|
139
|
-
)) }, chef))
|
|
140
|
-
] })
|
|
141
|
-
] })
|
|
142
|
-
]
|
|
143
|
-
}
|
|
144
|
-
)
|
|
145
|
-
] })
|
|
146
|
-
] });
|
|
147
|
-
}
|
|
148
|
-
async function getConversation({
|
|
149
|
-
client,
|
|
150
|
-
chatId,
|
|
151
|
-
actorId,
|
|
152
|
-
conversationId
|
|
153
|
-
}) {
|
|
154
|
-
if (!conversationId) {
|
|
155
|
-
const { data: newConversation, error: error2 } = await client.chats.conversations.create({
|
|
156
|
-
path: { chatId },
|
|
157
|
-
body: { actorId }
|
|
158
|
-
});
|
|
159
|
-
if (error2) {
|
|
160
|
-
throw new Error(
|
|
161
|
-
"error" in error2 ? error2.error : "Failed to create conversation"
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
useChatStore.setState({
|
|
165
|
-
...useChatStore.getState(),
|
|
166
|
-
selectedConversationId: newConversation._id
|
|
167
|
-
});
|
|
168
|
-
return newConversation;
|
|
169
|
-
}
|
|
170
|
-
const { data, error } = await client.chats.conversations.get({
|
|
171
|
-
path: { chatId, conversationId }
|
|
172
|
-
});
|
|
173
|
-
if (error) {
|
|
174
|
-
throw new Error(
|
|
175
|
-
"error" in error ? error.error : "Failed to fetch conversation"
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
return data;
|
|
179
|
-
}
|
|
180
|
-
function getConversationQueryConfig({
|
|
181
|
-
chatId,
|
|
182
|
-
conversationId,
|
|
183
|
-
client,
|
|
184
|
-
actorId
|
|
185
|
-
}) {
|
|
186
|
-
return {
|
|
187
|
-
queryKey: chatQueryKeys.conversation(chatId, conversationId),
|
|
188
|
-
queryFn: () => getConversation({ client, chatId, conversationId, actorId })
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
function useGetConversationQuery({
|
|
192
|
-
chatId,
|
|
193
|
-
conversationId
|
|
194
|
-
}) {
|
|
195
|
-
const client = useApiClient();
|
|
196
|
-
const { context } = useMoleculeConfig();
|
|
197
|
-
return useQuery({
|
|
198
|
-
...getConversationQueryConfig({
|
|
199
|
-
chatId,
|
|
200
|
-
conversationId,
|
|
201
|
-
client,
|
|
202
|
-
actorId: context?.actor?.id ?? ""
|
|
203
|
-
}),
|
|
204
|
-
enabled: !!chatId,
|
|
205
|
-
staleTime: 200
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
function useInitialMessages() {
|
|
209
|
-
const { selectedConversationId } = useChatStore();
|
|
210
|
-
const { chatId } = useMoleculeComponent();
|
|
211
|
-
const { data } = useGetChatQuery({ chatId });
|
|
212
|
-
const { data: conversation } = useGetConversationQuery({
|
|
213
|
-
chatId,
|
|
214
|
-
conversationId: selectedConversationId
|
|
215
|
-
});
|
|
216
|
-
const conversationMessages = useMemo(() => {
|
|
217
|
-
if (!selectedConversationId) return void 0;
|
|
218
|
-
return conversation?.messages?.map((msg) => {
|
|
219
|
-
return {
|
|
220
|
-
id: msg.id,
|
|
221
|
-
role: msg.role,
|
|
222
|
-
parts: msg.parts.map((p) => ({
|
|
223
|
-
type: "text",
|
|
224
|
-
text: p.text ?? ""
|
|
225
|
-
})),
|
|
226
|
-
metadata: msg
|
|
227
|
-
};
|
|
228
|
-
});
|
|
229
|
-
}, [conversation, selectedConversationId]);
|
|
230
|
-
const initialMessages = useMemo(() => {
|
|
231
|
-
const initialChatMessages = getInitialMessagesFromStrings(
|
|
232
|
-
data?.chatBaseSettings?.initialChatMessages ?? []
|
|
233
|
-
);
|
|
234
|
-
return [...initialChatMessages, ...conversationMessages ?? []];
|
|
235
|
-
}, [data?.chatBaseSettings?.initialChatMessages, conversationMessages]);
|
|
236
|
-
return initialMessages;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// src/features/chat/chat-element/use-chat.tsx
|
|
240
|
-
function useChat() {
|
|
241
|
-
const client = useApiClient();
|
|
242
|
-
const { config, component } = useMolecule();
|
|
243
|
-
const { selectedConversationId, conversationType } = useChatStore();
|
|
244
|
-
const initialMessages = useInitialMessages();
|
|
245
|
-
const useChatResult = useChat$1({
|
|
246
|
-
messages: initialMessages,
|
|
247
|
-
transport: new DefaultChatTransport({
|
|
248
|
-
prepareSendMessagesRequest: ({
|
|
249
|
-
body,
|
|
250
|
-
headers,
|
|
251
|
-
credentials,
|
|
252
|
-
id,
|
|
253
|
-
messages,
|
|
254
|
-
trigger,
|
|
255
|
-
messageId
|
|
256
|
-
}) => {
|
|
257
|
-
return {
|
|
258
|
-
api: client.getUrl("chats.conversations.completion", {
|
|
259
|
-
chatId: component.chatId,
|
|
260
|
-
conversationId: body?.conversationId || "new"
|
|
261
|
-
}),
|
|
262
|
-
body: {
|
|
263
|
-
...body,
|
|
264
|
-
id,
|
|
265
|
-
messages,
|
|
266
|
-
trigger,
|
|
267
|
-
messageId
|
|
268
|
-
},
|
|
269
|
-
headers,
|
|
270
|
-
credentials
|
|
271
|
-
};
|
|
272
|
-
},
|
|
273
|
-
headers: {
|
|
274
|
-
...config.api?.headers
|
|
275
|
-
}
|
|
276
|
-
})
|
|
277
|
-
});
|
|
278
|
-
useEffect(() => {
|
|
279
|
-
if (conversationType === "history" || !selectedConversationId) {
|
|
280
|
-
useChatResult.stop();
|
|
281
|
-
useChatResult.setMessages(initialMessages);
|
|
282
|
-
}
|
|
283
|
-
}, [conversationType, selectedConversationId, initialMessages]);
|
|
284
|
-
return useChatResult;
|
|
285
|
-
}
|
|
286
|
-
function ChatElement() {
|
|
287
|
-
const queryClient = useQueryClient();
|
|
288
|
-
const client = useApiClient();
|
|
289
|
-
const { chatId } = useMoleculeComponent();
|
|
290
|
-
const { context } = useMoleculeConfig();
|
|
291
|
-
const { selectedConversationId } = useChatStore();
|
|
292
|
-
const { data: conversation } = useGetConversationQuery({
|
|
293
|
-
chatId,
|
|
294
|
-
conversationId: selectedConversationId
|
|
295
|
-
});
|
|
296
|
-
const { messages, sendMessage, status } = useChat();
|
|
297
|
-
const promptInputRef = useRef(null);
|
|
298
|
-
useEffect(() => {
|
|
299
|
-
promptInputRef.current?.focus();
|
|
300
|
-
}, [selectedConversationId]);
|
|
301
|
-
const handleSubmit = async (message) => {
|
|
302
|
-
let conversationId = conversation?._id;
|
|
303
|
-
if (!conversation) {
|
|
304
|
-
const newConversation = await queryClient.fetchQuery({
|
|
305
|
-
...getConversationQueryConfig({
|
|
306
|
-
chatId,
|
|
307
|
-
conversationId: selectedConversationId,
|
|
308
|
-
client,
|
|
309
|
-
actorId: context?.actor?.id ?? ""
|
|
310
|
-
})
|
|
311
|
-
});
|
|
312
|
-
conversationId = newConversation._id;
|
|
313
|
-
}
|
|
314
|
-
sendMessage({ text: message.text }, { body: { conversationId } });
|
|
315
|
-
};
|
|
316
|
-
const lastMessage = messages[messages.length - 1];
|
|
317
|
-
const isWaitingForContent = status === "submitted" || status === "streaming" && lastMessage?.role === "assistant" && !lastMessage.parts.some(
|
|
318
|
-
(part) => part.type === "text" && part.text.length > 0
|
|
319
|
-
);
|
|
320
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
321
|
-
/* @__PURE__ */ jsxs(Conversation, { children: [
|
|
322
|
-
/* @__PURE__ */ jsxs(ConversationContent, { children: [
|
|
323
|
-
/* @__PURE__ */ jsx(ChatMessage, { messages }),
|
|
324
|
-
isWaitingForContent && /* @__PURE__ */ jsx(DotsLoader, {})
|
|
325
|
-
] }),
|
|
326
|
-
/* @__PURE__ */ jsx(ConversationScrollButton, {})
|
|
327
|
-
] }),
|
|
328
|
-
/* @__PURE__ */ jsx("div", { className: "m-4 my-2", children: /* @__PURE__ */ jsx(
|
|
329
|
-
ChatPromptInput,
|
|
330
|
-
{
|
|
331
|
-
ref: promptInputRef,
|
|
332
|
-
chatId,
|
|
333
|
-
onSubmit: handleSubmit,
|
|
334
|
-
status
|
|
335
|
-
}
|
|
336
|
-
) })
|
|
337
|
-
] });
|
|
338
|
-
}
|
|
339
|
-
ChatElement.displayName = "ChatElement";
|
|
340
|
-
function ChatHeader({ chatId }) {
|
|
341
|
-
const { t } = useTranslation();
|
|
342
|
-
const { tab, setTab } = useChatStore();
|
|
343
|
-
const { data } = useGetChatQuery({ chatId });
|
|
344
|
-
const [_, setImgLoaded] = useState(false);
|
|
345
|
-
const name = data?.chatAppearanceSettings?.displayName;
|
|
346
|
-
const iconUrl = data?.chatAppearanceSettings?.icon?.url;
|
|
347
|
-
return /* @__PURE__ */ jsxs(CardHeader, { className: "flex justify-between items-center h-14 bg-slate-900 dark:bg-zinc-400 rounded-t-lg px-4!", children: [
|
|
348
|
-
/* @__PURE__ */ jsxs(CardTitle, { children: [
|
|
349
|
-
tab === "chat" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
350
|
-
iconUrl && /* @__PURE__ */ jsx(
|
|
351
|
-
"img",
|
|
352
|
-
{
|
|
353
|
-
src: iconUrl,
|
|
354
|
-
alt: "Chat Icon",
|
|
355
|
-
className: "inline-block w-4 h-4",
|
|
356
|
-
onLoad: () => setImgLoaded(true)
|
|
357
|
-
}
|
|
358
|
-
),
|
|
359
|
-
/* @__PURE__ */ jsx(
|
|
360
|
-
Text,
|
|
361
|
-
{
|
|
362
|
-
variant: "h1",
|
|
363
|
-
className: "text-sm text-background flex items-center gap-2",
|
|
364
|
-
children: name
|
|
365
|
-
}
|
|
366
|
-
)
|
|
367
|
-
] }),
|
|
368
|
-
tab === "history" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
369
|
-
/* @__PURE__ */ jsx(
|
|
370
|
-
Button,
|
|
371
|
-
{
|
|
372
|
-
onClick: () => setTab("chat"),
|
|
373
|
-
variant: "transparent",
|
|
374
|
-
className: "p-0!",
|
|
375
|
-
children: /* @__PURE__ */ jsx(ArrowLeft, { className: "size-4" })
|
|
376
|
-
}
|
|
377
|
-
),
|
|
378
|
-
/* @__PURE__ */ jsx(
|
|
379
|
-
Text,
|
|
380
|
-
{
|
|
381
|
-
variant: "h1",
|
|
382
|
-
className: "text-sm text-background flex items-center gap-2",
|
|
383
|
-
children: t("header.history-tab-label")
|
|
384
|
-
}
|
|
385
|
-
)
|
|
386
|
-
] })
|
|
387
|
-
] }),
|
|
388
|
-
tab === "chat" && /* @__PURE__ */ jsx(ChatMenu, {})
|
|
389
|
-
] });
|
|
390
|
-
}
|
|
391
|
-
function useListConversationsQuery({
|
|
392
|
-
chatId
|
|
393
|
-
}) {
|
|
394
|
-
const client = useApiClient();
|
|
395
|
-
const { context } = useMoleculeConfig();
|
|
396
|
-
return useQuery({
|
|
397
|
-
queryKey: chatQueryKeys.listConversations(chatId),
|
|
398
|
-
queryFn: async () => {
|
|
399
|
-
const { data, error } = await client.chats.conversations.list({
|
|
400
|
-
path: { chatId },
|
|
401
|
-
query: { actorId: context?.actor?.id ?? "" }
|
|
402
|
-
});
|
|
403
|
-
if (error) {
|
|
404
|
-
throw new Error(
|
|
405
|
-
"error" in error ? error.error : "Failed to fetch conversations"
|
|
406
|
-
);
|
|
407
|
-
}
|
|
408
|
-
return data.conversations.reverse();
|
|
409
|
-
},
|
|
410
|
-
enabled: !!chatId
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
function ChatHistory() {
|
|
414
|
-
const { t, i18n } = useTranslation("chat", { keyPrefix: "history" });
|
|
415
|
-
const queryClient = useQueryClient();
|
|
416
|
-
const { chatId } = useMoleculeComponent();
|
|
417
|
-
const { data, isLoading } = useListConversationsQuery({ chatId });
|
|
418
|
-
const { setSelectedConversationId, setTab, setConversationType } = useChatStore();
|
|
419
|
-
if (isLoading) {
|
|
420
|
-
return /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center", children: /* @__PURE__ */ jsx(DotsLoader, {}) });
|
|
421
|
-
}
|
|
422
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex-1 min-h-0 flex flex-col gap-1 overflow-y-auto gap-2 p-2", children: [
|
|
423
|
-
data?.length === 0 ? /* @__PURE__ */ jsx(ChatHistoryEmpty, {}) : data?.map((conversation, index) => /* @__PURE__ */ jsxs(
|
|
424
|
-
Button,
|
|
425
|
-
{
|
|
426
|
-
variant: "ghost",
|
|
427
|
-
className: "flex flex-col items-start justify-center gap-2 px-3 py-2 h-auto text-left",
|
|
428
|
-
onClick: () => {
|
|
429
|
-
queryClient.invalidateQueries({
|
|
430
|
-
queryKey: chatQueryKeys.conversation(chatId, conversation._id)
|
|
431
|
-
});
|
|
432
|
-
setSelectedConversationId(conversation._id);
|
|
433
|
-
setTab("chat");
|
|
434
|
-
setConversationType("history");
|
|
435
|
-
},
|
|
436
|
-
children: [
|
|
437
|
-
/* @__PURE__ */ jsxs("div", { className: "self-stretch flex justify-between gap-1", children: [
|
|
438
|
-
/* @__PURE__ */ jsxs(Text, { className: "truncate text-sm", children: [
|
|
439
|
-
data.length - index,
|
|
440
|
-
":",
|
|
441
|
-
" ",
|
|
442
|
-
conversation.title ?? t("unitled-conversation")
|
|
443
|
-
] }),
|
|
444
|
-
/* @__PURE__ */ jsx(Text, { variant: "tiny", color: "muted", children: renderRelativeTime({
|
|
445
|
-
date: conversation._creationTime,
|
|
446
|
-
locale: i18n.language
|
|
447
|
-
}) })
|
|
448
|
-
] }),
|
|
449
|
-
/* @__PURE__ */ jsx(
|
|
450
|
-
Text,
|
|
451
|
-
{
|
|
452
|
-
className: "flex-1 min-w-0 max-w-full truncate",
|
|
453
|
-
variant: "paragraph2",
|
|
454
|
-
color: "muted",
|
|
455
|
-
children: conversation.summary
|
|
456
|
-
}
|
|
457
|
-
)
|
|
458
|
-
]
|
|
459
|
-
},
|
|
460
|
-
conversation._id
|
|
461
|
-
)),
|
|
462
|
-
/* @__PURE__ */ jsxs(
|
|
463
|
-
Button,
|
|
464
|
-
{
|
|
465
|
-
className: "absolute bottom-6 left-1/2 -translate-x-1/2",
|
|
466
|
-
onClick: () => {
|
|
467
|
-
setConversationType("new");
|
|
468
|
-
setSelectedConversationId();
|
|
469
|
-
setTab("chat");
|
|
470
|
-
},
|
|
471
|
-
children: [
|
|
472
|
-
/* @__PURE__ */ jsx(Plus, { className: "size-4" }),
|
|
473
|
-
t("new-conversation")
|
|
474
|
-
]
|
|
475
|
-
}
|
|
476
|
-
)
|
|
477
|
-
] });
|
|
478
|
-
}
|
|
479
|
-
function ChatCard() {
|
|
480
|
-
const { t } = useTranslation();
|
|
481
|
-
const { chatId } = useMoleculeComponent();
|
|
482
|
-
const { tab, selectedConversationId, conversationType } = useChatStore();
|
|
483
|
-
useListConversationsQuery({ chatId });
|
|
484
|
-
const { isLoading, data: chat } = useGetChatQuery({ chatId });
|
|
485
|
-
const { isLoading: isConversationLoading } = useGetConversationQuery({
|
|
486
|
-
chatId,
|
|
487
|
-
conversationId: selectedConversationId
|
|
488
|
-
});
|
|
489
|
-
const canCreateMessage = chat?.chatModelSettings?.allowedModels && chat?.chatModelSettings?.allowedModels.length > 0;
|
|
490
|
-
if (!canCreateMessage && chat?.chatBaseSettings?.hideChatWhenInsufficientCredits) {
|
|
491
|
-
return null;
|
|
492
|
-
}
|
|
493
|
-
return /* @__PURE__ */ jsxs(Card, { className: "min-w-[320px] h-[640px] w-[400px] flex flex-col relative p-0 rounded-lg gap-0", children: [
|
|
494
|
-
isLoading && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center z-10 bg-card rounded-lg", children: /* @__PURE__ */ jsx(DotsLoader, {}) }),
|
|
495
|
-
/* @__PURE__ */ jsx(ChatHeader, { chatId }),
|
|
496
|
-
conversationType === "history" && isConversationLoading && /* @__PURE__ */ jsx("div", { className: "flex-1 flex items-center justify-center z-10 bg-card rounded-lg", children: /* @__PURE__ */ jsx(DotsLoader, {}) }),
|
|
497
|
-
!isLoading && (conversationType === "new" || !isConversationLoading) && /* @__PURE__ */ jsxs(
|
|
498
|
-
"div",
|
|
499
|
-
{
|
|
500
|
-
className: tab !== "chat" ? "hidden" : "flex flex-col flex-1 min-h-0",
|
|
501
|
-
children: [
|
|
502
|
-
conversationType === "history" && isConversationLoading && /* @__PURE__ */ jsx("div", { className: "absolute inset-0 flex items-center justify-center z-10 bg-card rounded-lg", children: /* @__PURE__ */ jsx(DotsLoader, {}) }),
|
|
503
|
-
canCreateMessage ? /* @__PURE__ */ jsx(ChatElement, {}) : /* @__PURE__ */ jsx("div", { className: "m-4 h-full flex items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
504
|
-
Text,
|
|
505
|
-
{
|
|
506
|
-
variant: "paragraph1",
|
|
507
|
-
color: "muted",
|
|
508
|
-
className: "text-center font-light italic",
|
|
509
|
-
children: t("chat-card.insufficient-credits-error")
|
|
510
|
-
}
|
|
511
|
-
) })
|
|
512
|
-
]
|
|
513
|
-
}
|
|
514
|
-
),
|
|
515
|
-
!isLoading && tab === "history" && /* @__PURE__ */ jsx(ChatHistory, {})
|
|
516
|
-
] });
|
|
517
|
-
}
|
|
518
|
-
var {
|
|
519
|
-
MoleculeProvider,
|
|
520
|
-
useMolecule,
|
|
521
|
-
useMoleculeConfig,
|
|
522
|
-
useMoleculeComponent,
|
|
523
|
-
useMoleculeCallbacks
|
|
524
|
-
} = createMoleculeContext({ name: "ChatSDK.Chat" });
|
|
525
|
-
function ChatMolecule(props) {
|
|
526
|
-
const { config, callbacks, ...componentProps } = useMergeMoleculeConfig({
|
|
527
|
-
props,
|
|
528
|
-
name: "ChatSDK.Chat"
|
|
529
|
-
});
|
|
530
|
-
if (!componentProps.chatId) {
|
|
531
|
-
return null;
|
|
532
|
-
}
|
|
533
|
-
return /* @__PURE__ */ jsx(
|
|
534
|
-
MoleculeProvider,
|
|
535
|
-
{
|
|
536
|
-
config,
|
|
537
|
-
component: componentProps,
|
|
538
|
-
callbacks,
|
|
539
|
-
children: /* @__PURE__ */ jsx(ChatCard, {})
|
|
540
|
-
}
|
|
541
|
-
);
|
|
542
|
-
}
|
|
543
|
-
ChatMolecule.displayName = "ChatSDK.ChatMolecule";
|
|
544
|
-
|
|
545
|
-
// src/features/data-fetching/use-api-client.ts
|
|
546
|
-
function useApiClient() {
|
|
547
|
-
const { api } = useMoleculeConfig();
|
|
548
|
-
return getClient(api ?? {});
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
export { ChatCard, ChatElement, ChatHeader, ChatHistory, ChatMolecule, ChatPromptInput, MoleculeProvider, getConversationQueryConfig, useApiClient, useChat, useGetChatQuery, useGetConversationQuery, useInitialMessages, useListConversationsQuery, useMolecule, useMoleculeCallbacks, useMoleculeComponent, useMoleculeConfig };
|
package/dist/chunk-V2ITXC65.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { resources, languages, defaultNamespace, fallbackLng } from './chunk-R7G3RQLU.js';
|
|
2
|
-
import i18next from 'i18next';
|
|
3
|
-
import { initReactI18next } from 'react-i18next/initReactI18next';
|
|
4
|
-
|
|
5
|
-
var runsOnServerSide = typeof window === "undefined";
|
|
6
|
-
var elementsI18n = i18next.createInstance();
|
|
7
|
-
elementsI18n.use(initReactI18next).init({
|
|
8
|
-
// debug: true,
|
|
9
|
-
showSupportNotice: false,
|
|
10
|
-
supportedLngs: languages,
|
|
11
|
-
fallbackLng,
|
|
12
|
-
fallbackNS: defaultNamespace,
|
|
13
|
-
defaultNS: defaultNamespace,
|
|
14
|
-
lng: void 0,
|
|
15
|
-
// detect the language on client side
|
|
16
|
-
detection: {
|
|
17
|
-
order: ["path", "htmlTag", "cookie", "navigator"]
|
|
18
|
-
},
|
|
19
|
-
preload: runsOnServerSide ? languages : [],
|
|
20
|
-
resources
|
|
21
|
-
});
|
|
22
|
-
var i18n = elementsI18n;
|
|
23
|
-
|
|
24
|
-
export { i18n };
|
package/dist/chunk-VS55HRUS.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
// src/features/logger/logger.ts
|
|
2
|
-
function noOp() {
|
|
3
|
-
}
|
|
4
|
-
function getLogger(loggers) {
|
|
5
|
-
const _loggers = typeof loggers === "function" ? { info: loggers } : loggers;
|
|
6
|
-
const infoLogger = _loggers?.info || noOp;
|
|
7
|
-
const warnLogger = _loggers?.warn || infoLogger;
|
|
8
|
-
const errorLogger = _loggers?.error || infoLogger;
|
|
9
|
-
return {
|
|
10
|
-
info: infoLogger,
|
|
11
|
-
warn: warnLogger,
|
|
12
|
-
error: errorLogger
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export { getLogger };
|
package/dist/chunk-VYDYCGJL.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { useMergeGlobalConfig } from './chunk-MXTBCHYC.js';
|
|
2
|
-
|
|
3
|
-
// src/features/molecule/use-molecule-config.ts
|
|
4
|
-
function useMergeMoleculeConfig(moleculeConfig) {
|
|
5
|
-
const {
|
|
6
|
-
defaultProps: flatDefaultProps,
|
|
7
|
-
component,
|
|
8
|
-
...flatProps
|
|
9
|
-
} = moleculeConfig.props;
|
|
10
|
-
const { defaultProps: componentDefaultProps, ...componentProps } = component || {};
|
|
11
|
-
const _defaultProps = { ...flatDefaultProps, ...componentDefaultProps };
|
|
12
|
-
const _props = { ...componentProps, ...flatProps };
|
|
13
|
-
const { config, onloading, onsuccess, onerror, ...rest } = {
|
|
14
|
-
..._defaultProps,
|
|
15
|
-
..._props
|
|
16
|
-
};
|
|
17
|
-
const mergedConfig = useMergeGlobalConfig(config);
|
|
18
|
-
return {
|
|
19
|
-
...rest,
|
|
20
|
-
config: mergedConfig,
|
|
21
|
-
callbacks: { onloading, onsuccess, onerror }
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { useMergeMoleculeConfig };
|