@asgard-js/react 0.2.34-canary.3 → 0.2.34
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 +70 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -317,6 +317,7 @@ config: {
|
|
|
317
317
|
- **renderHeader?**: `() => ReactNode` - Custom header renderer. When provided, completely replaces the default header. Use `useAsgardContext()` inside the render function to access `resetChannel`, `isResetting`, and other internal state.
|
|
318
318
|
- **renderMenu?**: `() => ReactNode` - Custom menu renderer. When provided, renders content between the chat body and footer. Useful for quick menus, suggested questions, or navigation panels. See [Custom Menu](#custom-menu) section for details.
|
|
319
319
|
- **renderMessageContent?**: `(props: MessageContentRendererProps) => ReactNode` - Custom renderer for message content. Allows customizing how messages are rendered based on message properties. See [Custom Message Renderer](#custom-message-renderer) section for details.
|
|
320
|
+
- **renderToolCallGroup?**: `(props: ToolCallGroupRendererProps) => ReactNode` - Custom renderer for tool call group. Return `null` to hide, return JSX to fully customize, or call `renderDefaultContent()` to use the default UI with optional overrides (e.g., `renderDefaultContent({ title: 'AI is thinking...' })`). See [Tool Call Group Renderer](#tool-call-group-renderer) section for details.
|
|
320
321
|
- **onBeforeSendMessage?**: `(params: SendMessageParams) => SendMessageParams` - Callback to modify message params before sending. Allows injecting contextual data (payload, metadata) from parent components. See [Before Send Message Hook](#before-send-message-hook) section for details.
|
|
321
322
|
- **onSseMessage**: `(response: SseResponse, ctx: AsgardServiceContextValue) => void` - Callback function when SSE message is received. It would be helpful if using with the ref to provide some context and conversation data and do some proactively actions like sending messages to the bot.
|
|
322
323
|
- **ref**: `ForwardedRef<ChatbotRef>` - Forwarded ref to access the chatbot instance. It can be used to access the chatbot instance and do some actions like sending messages to the bot. `ChatbotRef` provides `serviceContext` for interacting with the chatbot, and `setInputValue(value: string)` for programmatically setting the textarea text from outside the component.
|
|
@@ -834,6 +835,75 @@ messageActions={(message) => {
|
|
|
834
835
|
<a id="custom-message-renderer"></a>
|
|
835
836
|
<br/>
|
|
836
837
|
|
|
838
|
+
<a id="tool-call-group-renderer"></a>
|
|
839
|
+
<br/>
|
|
840
|
+
|
|
841
|
+
### Tool Call Group Renderer
|
|
842
|
+
|
|
843
|
+
The `renderToolCallGroup` prop allows you to customize or hide the "Answer preparation steps" UI that appears when the bot calls tools before responding.
|
|
844
|
+
|
|
845
|
+
#### ToolCallGroupRendererProps Interface
|
|
846
|
+
|
|
847
|
+
```typescript
|
|
848
|
+
interface ToolCallGroupRendererProps {
|
|
849
|
+
/** Tool call items in the group */
|
|
850
|
+
items: ToolCallItemData[];
|
|
851
|
+
/** Timestamp of the first tool call */
|
|
852
|
+
time?: Date;
|
|
853
|
+
/** Function to render the default tool call group UI. Accepts optional overrides. */
|
|
854
|
+
renderDefaultContent: (overrides?: { title?: string }) => ReactNode;
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
interface ToolCallItemData {
|
|
858
|
+
id: string;
|
|
859
|
+
label: string;
|
|
860
|
+
status: 'pending' | 'completed' | 'error';
|
|
861
|
+
initial?: Record<string, unknown>;
|
|
862
|
+
result?: Record<string, unknown>;
|
|
863
|
+
}
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
#### Hide completely
|
|
867
|
+
|
|
868
|
+
```typescript
|
|
869
|
+
<Chatbot
|
|
870
|
+
renderToolCallGroup={() => null}
|
|
871
|
+
...
|
|
872
|
+
/>
|
|
873
|
+
```
|
|
874
|
+
|
|
875
|
+
#### Custom title
|
|
876
|
+
|
|
877
|
+
```typescript
|
|
878
|
+
<Chatbot
|
|
879
|
+
renderToolCallGroup={({ renderDefaultContent }) =>
|
|
880
|
+
renderDefaultContent({ title: 'AI is thinking...' })
|
|
881
|
+
}
|
|
882
|
+
...
|
|
883
|
+
/>
|
|
884
|
+
```
|
|
885
|
+
|
|
886
|
+
#### Custom UI
|
|
887
|
+
|
|
888
|
+
```typescript
|
|
889
|
+
<Chatbot
|
|
890
|
+
renderToolCallGroup={({ items }) => {
|
|
891
|
+
const done = items.filter(i => i.status === 'completed').length;
|
|
892
|
+
return (
|
|
893
|
+
<div>
|
|
894
|
+
{done === items.length
|
|
895
|
+
? `✅ ${done} steps completed`
|
|
896
|
+
: `⏳ Processing...`}
|
|
897
|
+
</div>
|
|
898
|
+
);
|
|
899
|
+
}}
|
|
900
|
+
...
|
|
901
|
+
/>
|
|
902
|
+
```
|
|
903
|
+
|
|
904
|
+
<a id="custom-message-renderer"></a>
|
|
905
|
+
<br/>
|
|
906
|
+
|
|
837
907
|
### Custom Message Renderer
|
|
838
908
|
|
|
839
909
|
The `renderMessageContent` prop allows you to customize how messages are rendered based on message type, payload, or other conditions. This is useful for implementing custom message cards, special UI treatments, or integrating with your application's design system.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asgard-js/react",
|
|
3
|
-
"version": "0.2.34
|
|
3
|
+
"version": "0.2.34",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"vite-plugin-svgr": "^4.3.0"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"@asgard-js/core": "^0.2.
|
|
49
|
+
"@asgard-js/core": "^0.2.34",
|
|
50
50
|
"react": "^18.0.0 || ^19.0.0",
|
|
51
51
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
52
52
|
}
|