@aleph-alpha/chat-kit 1.17.3 → 1.18.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/dist/{CkInput.vue_vue_type_script_setup_true_lang-DYBCJPBn.js → CkInput.vue_vue_type_script_setup_true_lang-BGlztr2p.js} +210 -97
- package/dist/components/base/CkModelSelector/CkModelSelector.stories.d.ts +20 -0
- package/dist/components/base/CkModelSelector/CkModelSelector.stories.d.ts.map +1 -0
- package/dist/components/base/CkModelSelector/CkModelSelector.vue.d.ts +16 -0
- package/dist/components/base/CkModelSelector/CkModelSelector.vue.d.ts.map +1 -0
- package/dist/components/base/CkModelSelector/index.d.ts +3 -0
- package/dist/components/base/CkModelSelector/index.d.ts.map +1 -0
- package/dist/components/base/CkModelSelector/types.d.ts +54 -0
- package/dist/components/base/CkModelSelector/types.d.ts.map +1 -0
- package/dist/components/base/index.d.ts +2 -0
- package/dist/components/base/index.d.ts.map +1 -1
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +9 -8
- package/dist/handlers/index.js +1 -1
- package/dist/handlers/useChatKitLabels.d.ts +6 -0
- package/dist/handlers/useChatKitLabels.d.ts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -10
- package/dist/{useChatKitLabels-BC6ItJc6.js → useChatKitLabels-ZutacPad.js} +3 -0
- package/package.json +1 -1
- package/src/components/base/CkModelSelector/CkModelSelector.spec.ts +60 -0
- package/src/components/base/CkModelSelector/CkModelSelector.stories.ts +101 -0
- package/src/components/base/CkModelSelector/CkModelSelector.vue +109 -0
- package/src/components/base/CkModelSelector/index.ts +6 -0
- package/src/components/base/CkModelSelector/types.ts +55 -0
- package/src/components/base/index.ts +6 -0
- package/src/components/index.ts +4 -0
- package/src/handlers/useChatKitLabels.spec.ts +5 -28
- package/src/handlers/useChatKitLabels.ts +9 -0
- package/src/index.ts +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CkModelSelector.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkModelSelector/CkModelSelector.stories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,eAAe,MAAM,uBAAuB,CAAC;AASpD,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,eAAe,CAyBtC,CAAC;AAEF,eAAe,IAAI,CAAC;AAEpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,eAAe,CAAC,CAAC;AAoC9C;;;GAGG;AACH,eAAO,MAAM,OAAO,EAAE,KAGrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,KAGzB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,KAGtB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CkModelSelectorProps } from './types';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<CkModelSelectorProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
3
|
+
"update:selectedModelId": (id: string) => any;
|
|
4
|
+
}, string, import("vue").PublicProps, Readonly<CkModelSelectorProps> & Readonly<{
|
|
5
|
+
"onUpdate:selectedModelId"?: ((id: string) => any) | undefined;
|
|
6
|
+
}>, {
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
side: "top" | "right" | "bottom" | "left";
|
|
9
|
+
sideOffset: number;
|
|
10
|
+
align: "start" | "center" | "end";
|
|
11
|
+
models: readonly import("./types").CkModelOption[];
|
|
12
|
+
selectedModelId: string | null;
|
|
13
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
|
+
declare const _default: typeof __VLS_export;
|
|
15
|
+
export default _default;
|
|
16
|
+
//# sourceMappingURL=CkModelSelector.vue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CkModelSelector.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkModelSelector/CkModelSelector.vue"],"names":[],"mappings":"AA4HA,OAAO,KAAK,EAAwB,oBAAoB,EAAE,MAAM,SAAS,CAAC;AA6Q1E,QAAA,MAAM,YAAY;;;;;;;;;;;6EAIhB,CAAC;wBACkB,OAAO,YAAY;AAAxC,wBAAyC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkModelSelector/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACnE,YAAY,EACV,aAAa,EACb,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact dropdown for choosing the active model, sized to sit inline in a
|
|
3
|
+
* prompt field next to the send button. Controlled component: pass the
|
|
4
|
+
* available `models` and the `selectedModelId`, and react to
|
|
5
|
+
* `update:selectedModelId` (so it works with `v-model:selected-model-id`).
|
|
6
|
+
* Purely presentational — fetching the list and persisting the choice are the
|
|
7
|
+
* consumer's responsibility.
|
|
8
|
+
*
|
|
9
|
+
* @category Actions
|
|
10
|
+
* @useCases select model, choose LLM, model picker in prompt field, switch model mid-conversation
|
|
11
|
+
* @keywords model, selector, picker, dropdown, llm, prompt, choose, switch
|
|
12
|
+
* @related CkPromptInput, CkPromptActionButton
|
|
13
|
+
*/
|
|
14
|
+
export interface CkModelOption {
|
|
15
|
+
/**
|
|
16
|
+
* Stable identifier for the model. Emitted on selection and compared
|
|
17
|
+
* against `selectedModelId` to mark the active row.
|
|
18
|
+
*/
|
|
19
|
+
id: string;
|
|
20
|
+
/** Display name shown in the trigger and the option row. */
|
|
21
|
+
label: string;
|
|
22
|
+
}
|
|
23
|
+
export interface CkModelSelectorProps {
|
|
24
|
+
/** Models to choose from. The dropdown trigger is still rendered when empty. */
|
|
25
|
+
models?: readonly CkModelOption[];
|
|
26
|
+
/** Id of the currently selected model. */
|
|
27
|
+
selectedModelId?: string | null;
|
|
28
|
+
/** Disable the trigger (e.g. while a model list is loading). */
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Which side of the trigger the dropdown opens on.
|
|
32
|
+
* @default 'top'
|
|
33
|
+
*/
|
|
34
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
35
|
+
/**
|
|
36
|
+
* Alignment of the dropdown relative to the trigger.
|
|
37
|
+
* @default 'end'
|
|
38
|
+
*/
|
|
39
|
+
align?: 'start' | 'center' | 'end';
|
|
40
|
+
/**
|
|
41
|
+
* Gap in pixels between the trigger and the dropdown.
|
|
42
|
+
* @default 8
|
|
43
|
+
*/
|
|
44
|
+
sideOffset?: number;
|
|
45
|
+
}
|
|
46
|
+
/** Emitted events for `CkModelSelector`. */
|
|
47
|
+
export interface CkModelSelectorEmits {
|
|
48
|
+
/**
|
|
49
|
+
* Fired with the chosen model id when the selection changes. Pairs with
|
|
50
|
+
* `v-model:selected-model-id`.
|
|
51
|
+
*/
|
|
52
|
+
'update:selectedModelId': [id: string];
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/base/CkModelSelector/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAC;IACX,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,gFAAgF;IAChF,MAAM,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;IAClC,0CAA0C;IAC1C,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gEAAgE;IAChE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,IAAI,CAAC,EAAE,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC3C;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;IACnC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,wBAAwB,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;CACxC"}
|
|
@@ -16,6 +16,8 @@ export type { CkHistoryWrapperProps } from './CkHistoryWrapper';
|
|
|
16
16
|
export { CkMarkdownRenderer } from './CkMarkdownRenderer';
|
|
17
17
|
export type { CkMarkdownRendererProps, CkMarkdownElementClasses, } from './CkMarkdownRenderer';
|
|
18
18
|
export { CkMessageActionButton } from './CkMessageActionButton';
|
|
19
|
+
export { CkModelSelector } from './CkModelSelector';
|
|
20
|
+
export type { CkModelOption, CkModelSelectorProps, CkModelSelectorEmits, } from './CkModelSelector';
|
|
19
21
|
export { CkPromptActionButton } from './CkPromptActionButton';
|
|
20
22
|
export { CkPromptStopButton } from './CkPromptStopButton';
|
|
21
23
|
export { CkPromptInput } from './CkPromptInput';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/base/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,YAAY,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO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9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { CkAgentMessage, CkConversationLayout, CkCopyMessageActionButton, CkFeedbackButton, CkFeedbackDialog, CkFileItemsList, CkHistoryItem, CkHistoryWrapper, CkMarkdownRenderer, CkMessageActionButton, CkPromptActionButton, CkPromptStopButton, CkPromptInput, CkPromptInputDisclaimer, CkSendIcon, CkStopIcon, CkUserMessage, } from './base';
|
|
2
|
-
export type { CkConversationLayoutProps, CkFeedbackButtonProps, CkFeedbackDialogEmits, CkFeedbackDialogProps, CkFeedbackDialogSubmitPayload, CkFeedbackReason, CkFeedbackSentiment, CkFeedbackValue, CkFileEntry, CkFileItemsListEmits, CkFileItemsListProps, CkHistoryItemEmits, CkHistoryItemProps, CkHistoryWrapperProps, CkMarkdownElementClasses, CkMarkdownRendererProps, CkUserMessageProps, } from './base';
|
|
1
|
+
export { CkAgentMessage, CkConversationLayout, CkCopyMessageActionButton, CkFeedbackButton, CkFeedbackDialog, CkFileItemsList, CkHistoryItem, CkHistoryWrapper, CkMarkdownRenderer, CkMessageActionButton, CkModelSelector, CkPromptActionButton, CkPromptStopButton, CkPromptInput, CkPromptInputDisclaimer, CkSendIcon, CkStopIcon, CkUserMessage, } from './base';
|
|
2
|
+
export type { CkConversationLayoutProps, CkFeedbackButtonProps, CkFeedbackDialogEmits, CkFeedbackDialogProps, CkFeedbackDialogSubmitPayload, CkFeedbackReason, CkFeedbackSentiment, CkFeedbackValue, CkFileEntry, CkFileItemsListEmits, CkFileItemsListProps, CkHistoryItemEmits, CkHistoryItemProps, CkHistoryWrapperProps, CkMarkdownElementClasses, CkMarkdownRendererProps, CkModelOption, CkModelSelectorProps, CkModelSelectorEmits, CkUserMessageProps, } from './base';
|
|
3
3
|
export { CkConversation, CkHistory, CkInput } from './composed';
|
|
4
4
|
export type { CkConversationProps, CkHistoryEmits, CkHistoryProps, } from './composed';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACvB,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,QAAQ,CAAC;AAChB,YAAY,EACV,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAChE,YAAY,EACV,mBAAmB,EACnB,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACvB,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,QAAQ,CAAC;AAChB,YAAY,EACV,yBAAyB,EACzB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAChE,YAAY,EACV,mBAAmB,EACnB,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _, a, b, C, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r } from "../CkInput.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { _, a, b, C, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s } from "../CkInput.vue_vue_type_script_setup_true_lang-BGlztr2p.js";
|
|
2
2
|
export {
|
|
3
3
|
_ as CkAgentMessage,
|
|
4
4
|
a as CkConversation,
|
|
@@ -13,11 +13,12 @@ export {
|
|
|
13
13
|
i as CkInput,
|
|
14
14
|
j as CkMarkdownRenderer,
|
|
15
15
|
k as CkMessageActionButton,
|
|
16
|
-
l as
|
|
17
|
-
m as
|
|
18
|
-
n as
|
|
19
|
-
o as
|
|
20
|
-
p as
|
|
21
|
-
q as
|
|
22
|
-
r as
|
|
16
|
+
l as CkModelSelector,
|
|
17
|
+
m as CkPromptActionButton,
|
|
18
|
+
n as CkPromptInput,
|
|
19
|
+
o as CkPromptInputDisclaimer,
|
|
20
|
+
p as CkPromptStopButton,
|
|
21
|
+
q as CkSendIcon,
|
|
22
|
+
r as CkStopIcon,
|
|
23
|
+
s as CkUserMessage
|
|
23
24
|
};
|
package/dist/handlers/index.js
CHANGED
|
@@ -67,6 +67,12 @@ export type ChatKitLabels = {
|
|
|
67
67
|
userMessageShowMore?: string;
|
|
68
68
|
/** Label for the `CkUserMessage` toggle when the message is expanded. */
|
|
69
69
|
userMessageShowLess?: string;
|
|
70
|
+
/** Accessible label for the `CkModelSelector` trigger button. */
|
|
71
|
+
modelSelectorAriaLabel?: string;
|
|
72
|
+
/** Accessible label for the `CkModelSelector` options list. */
|
|
73
|
+
modelSelectorListAriaLabel?: string;
|
|
74
|
+
/** Trigger text shown by `CkModelSelector` when no model is selected. */
|
|
75
|
+
modelSelectorPlaceholder?: string;
|
|
70
76
|
/** Fallback title used by `CkHistory` when a conversation has no `title`. */
|
|
71
77
|
historyItemUntitled: string;
|
|
72
78
|
/** Accessible name for the trailing kebab trigger on each `CkHistory` row. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChatKitLabels.d.ts","sourceRoot":"","sources":["../../src/handlers/useChatKitLabels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAG1D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,0CAA0C;IAC1C,cAAc,EAAE,MAAM,CAAC;IACvB,4CAA4C;IAC5C,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gDAAgD;IAChD,gBAAgB,EAAE,MAAM,CAAC;IACzB,sFAAsF;IACtF,iBAAiB,EAAE,MAAM,CAAC;IAC1B,4FAA4F;IAC5F,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;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B,yEAAyE;IACzE,uBAAuB,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,yEAAyE;AACzE,eAAO,MAAM,oBAAoB,EAAE,aA8BlC,CAAC;AAEF,4CAA4C;AAC5C,eAAO,MAAM,eAAe,EAAE,YAAY,CAAC,WAAW,CAAC,aAAa,CAAC,CAC1C,CAAC;AAE5B,KAAK,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5C,yFAAyF;AACzF,KAAK,cAAc,GACf,GAAG,CAAC,aAAa,CAAC,GAClB,WAAW,CAAC,aAAa,CAAC,GAC1B,CAAC,MAAM,aAAa,CAAC,CAAC;AAE1B;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAKjE;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,IAAI,WAAW,CAAC,aAAa,CAAC,CAK7D"}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export { useChat, useConversationSessions, useConversations, } from './composabl
|
|
|
5
5
|
export type { ChatActions, ChatState, ConversationSession, CreateConversationInput, MessageHandler, MutationOptions, UseChatReturn, UseConversationSessionsReturn, UseConversationsOptions, UseConversationsReturn, } from './composables';
|
|
6
6
|
export { SdkError, createDocumentUploadProvider, defaultDocumentUploadConfig, defaultEndpoints, useDocumentUploadWithDefaultConfig, } from './composables/fileUpload';
|
|
7
7
|
export type { DocumentUploadConfig, DocumentUploadProvider, FileEntry, FileStatus, } from './composables/fileUpload';
|
|
8
|
-
export { CkAgentMessage, CkConversation, CkConversationLayout, CkCopyMessageActionButton, CkFeedbackButton, CkFeedbackDialog, CkFileItemsList, CkHistory, CkHistoryItem, CkHistoryWrapper, CkInput, CkMarkdownRenderer, CkMessageActionButton, CkPromptActionButton, CkPromptStopButton, CkPromptInput, CkPromptInputDisclaimer, CkSendIcon, CkStopIcon, CkUserMessage, } from './components';
|
|
9
|
-
export type { CkConversationLayoutProps, CkConversationProps, CkFeedbackButtonProps, CkFeedbackDialogEmits, CkFeedbackDialogProps, CkFeedbackDialogSubmitPayload, CkFeedbackReason, CkFeedbackSentiment, CkFeedbackValue, CkFileEntry, CkFileItemsListEmits, CkFileItemsListProps, CkHistoryEmits, CkHistoryItemEmits, CkHistoryItemProps, CkHistoryProps, CkHistoryWrapperProps, CkMarkdownElementClasses, CkMarkdownRendererProps, CkUserMessageProps, } from './components';
|
|
8
|
+
export { CkAgentMessage, CkConversation, CkConversationLayout, CkCopyMessageActionButton, CkFeedbackButton, CkFeedbackDialog, CkFileItemsList, CkHistory, CkHistoryItem, CkHistoryWrapper, CkInput, CkMarkdownRenderer, CkMessageActionButton, CkModelSelector, CkPromptActionButton, CkPromptStopButton, CkPromptInput, CkPromptInputDisclaimer, CkSendIcon, CkStopIcon, CkUserMessage, } from './components';
|
|
9
|
+
export type { CkConversationLayoutProps, CkConversationProps, CkFeedbackButtonProps, CkFeedbackDialogEmits, CkFeedbackDialogProps, CkFeedbackDialogSubmitPayload, CkFeedbackReason, CkFeedbackSentiment, CkFeedbackValue, CkFileEntry, CkFileItemsListEmits, CkFileItemsListProps, CkHistoryEmits, CkHistoryItemEmits, CkHistoryItemProps, CkHistoryProps, CkHistoryWrapperProps, CkMarkdownElementClasses, CkMarkdownRendererProps, CkModelOption, CkModelSelectorProps, CkModelSelectorEmits, CkUserMessageProps, } from './components';
|
|
10
10
|
export { formatRelativeTime } from './helpers';
|
|
11
11
|
export type { BaseMessage, Conversation, ConversationTree, MessageContent, MessageContentStatus, MessageMetadata, MessageReasoningContent, MessageRole, MessageStatus, MessageTextContent, MessageToolContent, TreeMessage, } from './types';
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,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pB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG/C,YAAY,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AASpB,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,OAAO,EACL,OAAO,EACP,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,eAAe,EACf,aAAa,EACb,6BAA6B,EAC7B,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,QAAQ,EACR,4BAA4B,EAC5B,2BAA2B,EAC3B,gBAAgB,EAChB,kCAAkC,GACnC,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,oBAAoB,EACpB,sBAAsB,EACtB,SAAS,EACT,UAAU,GACX,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,qBAAqB,EACrB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,uBAAuB,EACvB,UAAU,EACV,UAAU,EACV,aAAa,GACd,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,6BAA6B,EAC7B,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,aAAa,EACb,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAG/C,YAAY,EACV,WAAW,EACX,YAAY,EACZ,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,uBAAuB,EACvB,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,GACZ,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { u } from "./useMessageHandler-CMdy-lm0.js";
|
|
2
|
-
import { C, d, p, u as u2, a } from "./useChatKitLabels-
|
|
2
|
+
import { C, d, p, u as u2, a } from "./useChatKitLabels-ZutacPad.js";
|
|
3
3
|
import { S, c, d as d2, a as a2, u as u3, b, e, f } from "./index-Ct5hD214.js";
|
|
4
|
-
import { _, a as a3, b as b2, C as C2, c as c2, d as d3, e as e2, f as f2, g, h, i, j, k, l, m, n, o, p as p2, q, r, s } from "./CkInput.vue_vue_type_script_setup_true_lang-
|
|
4
|
+
import { _, a as a3, b as b2, C as C2, c as c2, d as d3, e as e2, f as f2, g, h, i, j, k, l, m, n, o, p as p2, q, r, s, t } from "./CkInput.vue_vue_type_script_setup_true_lang-BGlztr2p.js";
|
|
5
5
|
export {
|
|
6
6
|
C as CHAT_KIT_LABELS,
|
|
7
7
|
_ as CkAgentMessage,
|
|
@@ -17,19 +17,20 @@ export {
|
|
|
17
17
|
i as CkInput,
|
|
18
18
|
j as CkMarkdownRenderer,
|
|
19
19
|
k as CkMessageActionButton,
|
|
20
|
-
l as
|
|
21
|
-
m as
|
|
22
|
-
n as
|
|
23
|
-
o as
|
|
24
|
-
p2 as
|
|
25
|
-
q as
|
|
26
|
-
r as
|
|
20
|
+
l as CkModelSelector,
|
|
21
|
+
m as CkPromptActionButton,
|
|
22
|
+
n as CkPromptInput,
|
|
23
|
+
o as CkPromptInputDisclaimer,
|
|
24
|
+
p2 as CkPromptStopButton,
|
|
25
|
+
q as CkSendIcon,
|
|
26
|
+
r as CkStopIcon,
|
|
27
|
+
s as CkUserMessage,
|
|
27
28
|
S as SdkError,
|
|
28
29
|
c as createDocumentUploadProvider,
|
|
29
30
|
d as defaultChatKitLabels,
|
|
30
31
|
d2 as defaultDocumentUploadConfig,
|
|
31
32
|
a2 as defaultEndpoints,
|
|
32
|
-
|
|
33
|
+
t as formatRelativeTime,
|
|
33
34
|
p as provideChatKitLabels,
|
|
34
35
|
u3 as useChat,
|
|
35
36
|
u2 as useChatKitLabels,
|
|
@@ -12719,6 +12719,9 @@ const defaultChatKitLabels = {
|
|
|
12719
12719
|
feedbackDialogSubmitLabel: "Submit",
|
|
12720
12720
|
userMessageShowMore: "Show more",
|
|
12721
12721
|
userMessageShowLess: "Show less",
|
|
12722
|
+
modelSelectorAriaLabel: "Select model",
|
|
12723
|
+
modelSelectorListAriaLabel: "Models",
|
|
12724
|
+
modelSelectorPlaceholder: "Select model",
|
|
12722
12725
|
historyItemUntitled: "Untitled conversation",
|
|
12723
12726
|
historyItemActionAriaLabel: "Conversation options",
|
|
12724
12727
|
historyItemEditAction: "Edit",
|
package/package.json
CHANGED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { defaultChatKitLabels } from '../../../handlers/useChatKitLabels';
|
|
2
|
+
import CkModelSelector from './CkModelSelector.vue';
|
|
3
|
+
import type { CkModelOption } from './types';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import { render, screen } from '@testing-library/vue';
|
|
6
|
+
import { describe, expect, it } from 'vitest';
|
|
7
|
+
|
|
8
|
+
const PLACEHOLDER = defaultChatKitLabels.modelSelectorPlaceholder!;
|
|
9
|
+
const TRIGGER_LABEL = defaultChatKitLabels.modelSelectorAriaLabel!;
|
|
10
|
+
|
|
11
|
+
const MODELS: CkModelOption[] = [
|
|
12
|
+
{ id: 'kimi', label: 'Kimi' },
|
|
13
|
+
{ id: 'phoenix', label: 'Phoenix' },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
describe('CkModelSelector', () => {
|
|
17
|
+
it('shows the selected model label on the trigger', () => {
|
|
18
|
+
render(CkModelSelector, {
|
|
19
|
+
props: { models: MODELS, selectedModelId: 'phoenix' },
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(
|
|
23
|
+
screen.getByRole('button', { name: TRIGGER_LABEL }),
|
|
24
|
+
).toHaveTextContent('Phoenix');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('falls back to the placeholder when nothing is selected', () => {
|
|
28
|
+
render(CkModelSelector, {
|
|
29
|
+
props: { models: MODELS, selectedModelId: null },
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
expect(
|
|
33
|
+
screen.getByRole('button', { name: TRIGGER_LABEL }),
|
|
34
|
+
).toHaveTextContent(PLACEHOLDER);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('emits update:selectedModelId with the chosen id', async () => {
|
|
38
|
+
const user = userEvent.setup();
|
|
39
|
+
const { emitted } = render(CkModelSelector, {
|
|
40
|
+
props: { models: MODELS, selectedModelId: 'phoenix' },
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
await user.click(screen.getByRole('button', { name: TRIGGER_LABEL }));
|
|
44
|
+
await user.click(await screen.findByRole('option', { name: 'Kimi' }));
|
|
45
|
+
|
|
46
|
+
expect(emitted('update:selectedModelId')).toEqual([['kimi']]);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('does not re-emit when the already-selected model is clicked', async () => {
|
|
50
|
+
const user = userEvent.setup();
|
|
51
|
+
const { emitted } = render(CkModelSelector, {
|
|
52
|
+
props: { models: MODELS, selectedModelId: 'phoenix' },
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
await user.click(screen.getByRole('button', { name: TRIGGER_LABEL }));
|
|
56
|
+
await user.click(await screen.findByRole('option', { name: 'Phoenix' }));
|
|
57
|
+
|
|
58
|
+
expect(emitted('update:selectedModelId')).toBeUndefined();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite';
|
|
2
|
+
import { ref } from 'vue';
|
|
3
|
+
import CkModelSelector from './CkModelSelector.vue';
|
|
4
|
+
import type { CkModelOption } from './types';
|
|
5
|
+
|
|
6
|
+
const MODELS: CkModelOption[] = [
|
|
7
|
+
{ id: 'kimi', label: 'Kimi' },
|
|
8
|
+
{ id: 'phoenix', label: 'Phoenix' },
|
|
9
|
+
{ id: 'phoenix-no-think', label: 'Phoenix (no thinking)' },
|
|
10
|
+
];
|
|
11
|
+
|
|
12
|
+
const meta: Meta<typeof CkModelSelector> = {
|
|
13
|
+
title: 'Base/CkModelSelector',
|
|
14
|
+
component: CkModelSelector,
|
|
15
|
+
tags: ['autodocs'],
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: 'centered',
|
|
18
|
+
docs: {
|
|
19
|
+
description: {
|
|
20
|
+
component:
|
|
21
|
+
'Compact, controlled model picker for a prompt field. Pass `models` and `selectedModelId`; react to **`update:selectedModelId`** (works with `v-model:selected-model-id`). Presentational only — the consumer fetches the list and persists the choice.',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
args: {
|
|
26
|
+
models: MODELS,
|
|
27
|
+
selectedModelId: 'phoenix',
|
|
28
|
+
},
|
|
29
|
+
argTypes: {
|
|
30
|
+
disabled: { control: 'boolean' },
|
|
31
|
+
side: {
|
|
32
|
+
control: 'select',
|
|
33
|
+
options: ['top', 'right', 'bottom', 'left'],
|
|
34
|
+
},
|
|
35
|
+
align: { control: 'select', options: ['start', 'center', 'end'] },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default meta;
|
|
40
|
+
|
|
41
|
+
type Story = StoryObj<typeof CkModelSelector>;
|
|
42
|
+
|
|
43
|
+
const defaultTemplateSource = `<script setup lang="ts">
|
|
44
|
+
import { ref } from 'vue';
|
|
45
|
+
import { CkModelSelector, type CkModelOption } from '@aleph-alpha/chat-kit';
|
|
46
|
+
|
|
47
|
+
const models: CkModelOption[] = [
|
|
48
|
+
{ id: 'kimi', label: 'Kimi' },
|
|
49
|
+
{ id: 'phoenix', label: 'Phoenix' },
|
|
50
|
+
];
|
|
51
|
+
const selectedModelId = ref('phoenix');
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
<CkModelSelector
|
|
56
|
+
:models="models"
|
|
57
|
+
v-model:selected-model-id="selectedModelId"
|
|
58
|
+
/>
|
|
59
|
+
</template>`;
|
|
60
|
+
|
|
61
|
+
const renderStory = (args: Story['args']) => ({
|
|
62
|
+
components: { CkModelSelector },
|
|
63
|
+
setup() {
|
|
64
|
+
const selectedModelId = ref(args?.selectedModelId ?? null);
|
|
65
|
+
return { args, selectedModelId };
|
|
66
|
+
},
|
|
67
|
+
template: `
|
|
68
|
+
<div class="bg-background-surface-primary p-8">
|
|
69
|
+
<CkModelSelector
|
|
70
|
+
v-bind="args"
|
|
71
|
+
v-model:selected-model-id="selectedModelId"
|
|
72
|
+
/>
|
|
73
|
+
</div>
|
|
74
|
+
`,
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Default picker with a current selection. Opens upward and aligns to the
|
|
79
|
+
* end, matching its intended spot next to a send button.
|
|
80
|
+
*/
|
|
81
|
+
export const Default: Story = {
|
|
82
|
+
render: renderStory,
|
|
83
|
+
parameters: { docs: { source: { code: defaultTemplateSource } } },
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* No selection yet — the trigger shows the placeholder label until the user
|
|
88
|
+
* picks a model.
|
|
89
|
+
*/
|
|
90
|
+
export const Placeholder: Story = {
|
|
91
|
+
args: { selectedModelId: null },
|
|
92
|
+
render: renderStory,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Disabled trigger — e.g. while the model list is still loading.
|
|
97
|
+
*/
|
|
98
|
+
export const Disabled: Story = {
|
|
99
|
+
args: { disabled: true },
|
|
100
|
+
render: renderStory,
|
|
101
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref } from 'vue';
|
|
3
|
+
import {
|
|
4
|
+
UiIcon,
|
|
5
|
+
UiPopover,
|
|
6
|
+
UiPopoverContent,
|
|
7
|
+
UiPopoverTrigger,
|
|
8
|
+
} from '@aleph-alpha/ui-library';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
defaultChatKitLabels,
|
|
12
|
+
useChatKitLabels,
|
|
13
|
+
} from '../../../handlers/useChatKitLabels';
|
|
14
|
+
import type { CkModelSelectorEmits, CkModelSelectorProps } from './types';
|
|
15
|
+
|
|
16
|
+
defineOptions({ name: 'CkModelSelector' });
|
|
17
|
+
|
|
18
|
+
const props = withDefaults(defineProps<CkModelSelectorProps>(), {
|
|
19
|
+
models: () => [],
|
|
20
|
+
selectedModelId: null,
|
|
21
|
+
disabled: false,
|
|
22
|
+
side: 'top',
|
|
23
|
+
align: 'end',
|
|
24
|
+
sideOffset: 8,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits<CkModelSelectorEmits>();
|
|
28
|
+
|
|
29
|
+
const labels = useChatKitLabels();
|
|
30
|
+
|
|
31
|
+
// Resolution order: injected label, English default.
|
|
32
|
+
const triggerAriaLabel = computed(
|
|
33
|
+
() =>
|
|
34
|
+
labels.value.modelSelectorAriaLabel ??
|
|
35
|
+
defaultChatKitLabels.modelSelectorAriaLabel!,
|
|
36
|
+
);
|
|
37
|
+
const listAriaLabel = computed(
|
|
38
|
+
() =>
|
|
39
|
+
labels.value.modelSelectorListAriaLabel ??
|
|
40
|
+
defaultChatKitLabels.modelSelectorListAriaLabel!,
|
|
41
|
+
);
|
|
42
|
+
const placeholderLabel = computed(
|
|
43
|
+
() =>
|
|
44
|
+
labels.value.modelSelectorPlaceholder ??
|
|
45
|
+
defaultChatKitLabels.modelSelectorPlaceholder!,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
const open = ref(false);
|
|
49
|
+
|
|
50
|
+
const selectedLabel = computed(() => {
|
|
51
|
+
const match = props.models.find((m) => m.id === props.selectedModelId);
|
|
52
|
+
return match?.label ?? placeholderLabel.value;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
function select(id: string) {
|
|
56
|
+
open.value = false;
|
|
57
|
+
if (id !== props.selectedModelId) emit('update:selectedModelId', id);
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<template>
|
|
62
|
+
<UiPopover v-model:open="open">
|
|
63
|
+
<UiPopoverTrigger as-child>
|
|
64
|
+
<button
|
|
65
|
+
type="button"
|
|
66
|
+
class="ck-model-selector__trigger inline-flex h-9 shrink-0 items-center gap-1 rounded-3xl px-3 label-14-medium text-content-on-surface-primary outline-none transition-colors hover:bg-background-surface-muted focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"
|
|
67
|
+
:disabled="disabled"
|
|
68
|
+
aria-haspopup="listbox"
|
|
69
|
+
:aria-expanded="open"
|
|
70
|
+
:aria-label="triggerAriaLabel"
|
|
71
|
+
>
|
|
72
|
+
<span class="max-w-[10rem] truncate">{{ selectedLabel }}</span>
|
|
73
|
+
<UiIcon name="chevron-down" :size="16" aria-hidden="true" />
|
|
74
|
+
</button>
|
|
75
|
+
</UiPopoverTrigger>
|
|
76
|
+
<UiPopoverContent
|
|
77
|
+
:side="side"
|
|
78
|
+
:align="align"
|
|
79
|
+
:side-offset="sideOffset"
|
|
80
|
+
class="max-h-72 w-56 overflow-y-auto rounded-xl border border-border-surface-default bg-background-surface-floating p-2 text-content-on-surface-primary shadow-md"
|
|
81
|
+
@open-auto-focus.prevent
|
|
82
|
+
>
|
|
83
|
+
<ul
|
|
84
|
+
class="flex flex-col gap-1"
|
|
85
|
+
role="listbox"
|
|
86
|
+
:aria-label="listAriaLabel"
|
|
87
|
+
>
|
|
88
|
+
<li v-for="model in models" :key="model.id" role="presentation">
|
|
89
|
+
<button
|
|
90
|
+
type="button"
|
|
91
|
+
role="option"
|
|
92
|
+
:aria-selected="model.id === selectedModelId"
|
|
93
|
+
class="relative flex w-full items-center gap-2 rounded-sm py-2 pr-8 pl-3 text-left body-14-regular text-content-on-surface-primary outline-none hover:bg-background-surface-muted-subtle focus-visible:ring-2 focus-visible:ring-ring"
|
|
94
|
+
@click="select(model.id)"
|
|
95
|
+
>
|
|
96
|
+
<span class="min-w-0 flex-1 truncate">{{ model.label }}</span>
|
|
97
|
+
<UiIcon
|
|
98
|
+
v-if="model.id === selectedModelId"
|
|
99
|
+
name="check"
|
|
100
|
+
:size="16"
|
|
101
|
+
class="absolute right-2 text-content-on-surface-primary"
|
|
102
|
+
aria-hidden="true"
|
|
103
|
+
/>
|
|
104
|
+
</button>
|
|
105
|
+
</li>
|
|
106
|
+
</ul>
|
|
107
|
+
</UiPopoverContent>
|
|
108
|
+
</UiPopover>
|
|
109
|
+
</template>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compact dropdown for choosing the active model, sized to sit inline in a
|
|
3
|
+
* prompt field next to the send button. Controlled component: pass the
|
|
4
|
+
* available `models` and the `selectedModelId`, and react to
|
|
5
|
+
* `update:selectedModelId` (so it works with `v-model:selected-model-id`).
|
|
6
|
+
* Purely presentational — fetching the list and persisting the choice are the
|
|
7
|
+
* consumer's responsibility.
|
|
8
|
+
*
|
|
9
|
+
* @category Actions
|
|
10
|
+
* @useCases select model, choose LLM, model picker in prompt field, switch model mid-conversation
|
|
11
|
+
* @keywords model, selector, picker, dropdown, llm, prompt, choose, switch
|
|
12
|
+
* @related CkPromptInput, CkPromptActionButton
|
|
13
|
+
*/
|
|
14
|
+
export interface CkModelOption {
|
|
15
|
+
/**
|
|
16
|
+
* Stable identifier for the model. Emitted on selection and compared
|
|
17
|
+
* against `selectedModelId` to mark the active row.
|
|
18
|
+
*/
|
|
19
|
+
id: string;
|
|
20
|
+
/** Display name shown in the trigger and the option row. */
|
|
21
|
+
label: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface CkModelSelectorProps {
|
|
25
|
+
/** Models to choose from. The dropdown trigger is still rendered when empty. */
|
|
26
|
+
models?: readonly CkModelOption[];
|
|
27
|
+
/** Id of the currently selected model. */
|
|
28
|
+
selectedModelId?: string | null;
|
|
29
|
+
/** Disable the trigger (e.g. while a model list is loading). */
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Which side of the trigger the dropdown opens on.
|
|
33
|
+
* @default 'top'
|
|
34
|
+
*/
|
|
35
|
+
side?: 'top' | 'right' | 'bottom' | 'left';
|
|
36
|
+
/**
|
|
37
|
+
* Alignment of the dropdown relative to the trigger.
|
|
38
|
+
* @default 'end'
|
|
39
|
+
*/
|
|
40
|
+
align?: 'start' | 'center' | 'end';
|
|
41
|
+
/**
|
|
42
|
+
* Gap in pixels between the trigger and the dropdown.
|
|
43
|
+
* @default 8
|
|
44
|
+
*/
|
|
45
|
+
sideOffset?: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Emitted events for `CkModelSelector`. */
|
|
49
|
+
export interface CkModelSelectorEmits {
|
|
50
|
+
/**
|
|
51
|
+
* Fired with the chosen model id when the selection changes. Pairs with
|
|
52
|
+
* `v-model:selected-model-id`.
|
|
53
|
+
*/
|
|
54
|
+
'update:selectedModelId': [id: string];
|
|
55
|
+
}
|
|
@@ -32,6 +32,12 @@ export type {
|
|
|
32
32
|
CkMarkdownElementClasses,
|
|
33
33
|
} from './CkMarkdownRenderer';
|
|
34
34
|
export { CkMessageActionButton } from './CkMessageActionButton';
|
|
35
|
+
export { CkModelSelector } from './CkModelSelector';
|
|
36
|
+
export type {
|
|
37
|
+
CkModelOption,
|
|
38
|
+
CkModelSelectorProps,
|
|
39
|
+
CkModelSelectorEmits,
|
|
40
|
+
} from './CkModelSelector';
|
|
35
41
|
export { CkPromptActionButton } from './CkPromptActionButton';
|
|
36
42
|
export { CkPromptStopButton } from './CkPromptStopButton';
|
|
37
43
|
export { CkPromptInput } from './CkPromptInput';
|
package/src/components/index.ts
CHANGED
|
@@ -10,6 +10,7 @@ export {
|
|
|
10
10
|
CkHistoryWrapper,
|
|
11
11
|
CkMarkdownRenderer,
|
|
12
12
|
CkMessageActionButton,
|
|
13
|
+
CkModelSelector,
|
|
13
14
|
CkPromptActionButton,
|
|
14
15
|
CkPromptStopButton,
|
|
15
16
|
CkPromptInput,
|
|
@@ -35,6 +36,9 @@ export type {
|
|
|
35
36
|
CkHistoryWrapperProps,
|
|
36
37
|
CkMarkdownElementClasses,
|
|
37
38
|
CkMarkdownRendererProps,
|
|
39
|
+
CkModelOption,
|
|
40
|
+
CkModelSelectorProps,
|
|
41
|
+
CkModelSelectorEmits,
|
|
38
42
|
CkUserMessageProps,
|
|
39
43
|
} from './base';
|
|
40
44
|
|