@asgard-js/react 0.2.34-canary.2 → 0.2.34-canary.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
CHANGED
|
@@ -592,7 +592,7 @@ Note: When `fullScreen` prop is set to `true`, the chatbot's width and height wi
|
|
|
592
592
|
|
|
593
593
|
### Tool Call Handler
|
|
594
594
|
|
|
595
|
-
The `onToolCall` callback allows you to handle tool call events from the bot. This handler is triggered when the bot starts or completes executing a tool call. See the [Tool Call Start documentation](https://
|
|
595
|
+
The `onToolCall` callback allows you to handle tool call events from the bot. This handler is triggered when the bot starts or completes executing a tool call. See the [Tool Call Start documentation](https://docs.asgard-ai.com/docs/developer-reference/api-doc/send-message/sse-response/asgard-tool-call-start) and [Tool Call Complete documentation](https://docs.asgard-ai.com/docs/developer-reference/api-doc/send-message/sse-response/asgard-tool-call-complete) for details.
|
|
596
596
|
|
|
597
597
|
The callback receives a `SseResponse` object with one of the following event types:
|
|
598
598
|
|
|
@@ -699,13 +699,13 @@ const handleToolCall = (response: SseResponse<EventType.TOOL_CALL_START | EventT
|
|
|
699
699
|
|
|
700
700
|
### EMIT Action
|
|
701
701
|
|
|
702
|
-
EMIT buttons allow you to handle custom actions in your application. Implement the `onTemplateBtnClick` callback to process these events. See the [EMIT Action documentation](https://
|
|
702
|
+
EMIT buttons allow you to handle custom actions in your application. Implement the `onTemplateBtnClick` callback to process these events. See the [EMIT Action documentation](https://docs.asgard-ai.com/docs/developer-reference/asgard-builtin/message-template-action-object-emit) for details.
|
|
703
703
|
|
|
704
704
|
The callback receives the following parameters:
|
|
705
705
|
|
|
706
706
|
1. `payload` (optional): Custom data from the button action
|
|
707
707
|
2. `eventName` (required): Event name specified in the button action
|
|
708
|
-
3. `raw` (required): Complete SSE response data as JSON string. Use this when you need information beyond `payload` and `eventName`. Parse it to access additional fields from the original SSE response. See [SSE Response documentation](https://
|
|
708
|
+
3. `raw` (required): Complete SSE response data as JSON string. Use this when you need information beyond `payload` and `eventName`. Parse it to access additional fields from the original SSE response. See [SSE Response documentation](https://docs.asgard-ai.com/docs/developer-reference/api-doc/send-message/sse-response/message-complete) for the complete response structure.
|
|
709
709
|
|
|
710
710
|
Configure EMIT buttons in your backend SSE response:
|
|
711
711
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatbot-body.d.ts","sourceRoot":"","sources":["../../../../src/components/chatbot/chatbot-body/chatbot-body.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,SAAS,EAA2C,MAAM,OAAO,CAAC;AAkErF,wBAAgB,WAAW,IAAI,SAAS,
|
|
1
|
+
{"version":3,"file":"chatbot-body.d.ts","sourceRoot":"","sources":["../../../../src/components/chatbot/chatbot-body/chatbot-body.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,SAAS,EAA2C,MAAM,OAAO,CAAC;AAkErF,wBAAgB,WAAW,IAAI,SAAS,CAwHvC"}
|
|
@@ -28,6 +28,19 @@ export interface MessageContentRendererProps {
|
|
|
28
28
|
/** Container component that wraps custom content with Avatar for bot messages */
|
|
29
29
|
MessageContainer: FC<MessageContainerProps>;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Props passed to the custom tool call group renderer function
|
|
33
|
+
*/
|
|
34
|
+
export interface ToolCallGroupRendererProps {
|
|
35
|
+
/** Tool call items in the group */
|
|
36
|
+
items: ToolCallItemData[];
|
|
37
|
+
/** Timestamp of the first tool call */
|
|
38
|
+
time?: Date;
|
|
39
|
+
/** Function to render the default tool call group UI. Accepts optional overrides. */
|
|
40
|
+
renderDefaultContent: (overrides?: {
|
|
41
|
+
title?: string;
|
|
42
|
+
}) => ReactNode;
|
|
43
|
+
}
|
|
31
44
|
export interface AsgardTemplateContextValue {
|
|
32
45
|
onErrorClick?: (message: ConversationErrorMessage) => void;
|
|
33
46
|
errorMessageRenderer?: (message: ConversationErrorMessage) => ReactNode;
|
|
@@ -40,10 +53,7 @@ export interface AsgardTemplateContextValue {
|
|
|
40
53
|
/** Custom renderer for message content. Allows customizing how messages are rendered based on message properties. */
|
|
41
54
|
renderMessageContent?: (props: MessageContentRendererProps) => ReactNode;
|
|
42
55
|
/** Custom renderer for tool call group. Return null to hide, or return custom JSX. */
|
|
43
|
-
renderToolCallGroup?: (
|
|
44
|
-
time?: Date;
|
|
45
|
-
defaultRender: () => ReactNode;
|
|
46
|
-
}) => ReactNode;
|
|
56
|
+
renderToolCallGroup?: (props: ToolCallGroupRendererProps) => ReactNode;
|
|
47
57
|
}
|
|
48
58
|
export declare const AsgardTemplateContext: import('react').Context<AsgardTemplateContextValue>;
|
|
49
59
|
interface AsgardTemplateContextProviderProps extends PropsWithChildren {
|
|
@@ -54,10 +64,7 @@ interface AsgardTemplateContextProviderProps extends PropsWithChildren {
|
|
|
54
64
|
messageActions?: (message: ConversationBotMessage) => MessageActionConfig[];
|
|
55
65
|
onMessageAction?: (actionId: string, message: ConversationBotMessage) => void;
|
|
56
66
|
renderMessageContent?: (props: MessageContentRendererProps) => ReactNode;
|
|
57
|
-
renderToolCallGroup?: (
|
|
58
|
-
time?: Date;
|
|
59
|
-
defaultRender: () => ReactNode;
|
|
60
|
-
}) => ReactNode;
|
|
67
|
+
renderToolCallGroup?: (props: ToolCallGroupRendererProps) => ReactNode;
|
|
61
68
|
}
|
|
62
69
|
export declare function AsgardTemplateContextProvider(props: AsgardTemplateContextProviderProps): ReactNode;
|
|
63
70
|
export declare function useAsgardTemplateContext(): AsgardTemplateContextValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asgard-template-context.d.ts","sourceRoot":"","sources":["../../src/context/asgard-template-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAC7F,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EAAE,gBAAgB,EAAE,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B,6BAA6B,CAAC,KAAK,EAAE,kCAAkC,GAAG,SAAS,CAqClG;AAED,wBAAgB,wBAAwB,IAAI,0BAA0B,CAErE"}
|
package/dist/index.js
CHANGED
|
@@ -41789,11 +41789,12 @@ function i_e() {
|
|
|
41789
41789
|
children: /* @__PURE__ */ V("div", { ref: f, className: t1.chatbot_body__content, style: h, children: [
|
|
41790
41790
|
t_e(Array.from(n?.values() ?? [])).map((p, g) => {
|
|
41791
41791
|
if (p.type === "tool-call-group") {
|
|
41792
|
-
const m = p.toolCalls.map(n_e), y = p.toolCalls[0], _ = `tool-call-group-${y?.processId || g}`, b = () => /* @__PURE__ */ k(Nye, { items: m, time: y?.time });
|
|
41792
|
+
const m = p.toolCalls.map(n_e), y = p.toolCalls[0], _ = `tool-call-group-${y?.processId || g}`, b = (v) => /* @__PURE__ */ k(Nye, { items: m, time: y?.time, title: v?.title });
|
|
41793
41793
|
if (t) {
|
|
41794
|
-
const v = t(
|
|
41794
|
+
const v = t({
|
|
41795
|
+
items: m,
|
|
41795
41796
|
time: y?.time,
|
|
41796
|
-
|
|
41797
|
+
renderDefaultContent: b
|
|
41797
41798
|
});
|
|
41798
41799
|
return v === null ? null : /* @__PURE__ */ k(qk, { children: v }, _);
|
|
41799
41800
|
}
|