@deepagents/react-genai 7.49.0 → 7.50.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/README.md +55 -0
- package/dist/index.js +2127 -1962
- package/dist/index.js.map +1 -1
- package/dist/lib/chat/chat.d.ts.map +1 -1
- package/dist/lib/chat/message-parts.d.ts.map +1 -1
- package/dist/lib/chat/trajectory/IndexProgressSegment.d.ts.map +1 -1
- package/dist/lib/chat/trajectory/segments/index.d.ts.map +1 -1
- package/dist/lib/chat/trajectory/trajectories/messages-error.d.ts.map +1 -1
- package/dist/lib/chat/trajectory/trajectories/messages.d.ts.map +1 -1
- package/dist/lib/chat/trajectory/trajectories/thinking-hint.d.ts +2 -1
- package/dist/lib/chat/trajectory/trajectories/thinking-hint.d.ts.map +1 -1
- package/dist/lib/chat/trajectory/trajectories/timelined-messages.d.ts.map +1 -1
- package/dist/lib/chat/trajectory/trajectories/trajectory-thinking.d.ts.map +1 -1
- package/dist/lib/chat/trajectory/trajectories/user-message.d.ts.map +1 -1
- package/dist/lib/chat/usage.d.ts +7 -1
- package/dist/lib/chat/usage.d.ts.map +1 -1
- package/dist/lib/components/ChatComposer.d.ts.map +1 -1
- package/dist/lib/components/SubmitButton.d.ts.map +1 -1
- package/dist/lib/components/queue.d.ts.map +1 -1
- package/dist/lib/components/tool-debug.d.ts.map +1 -1
- package/dist/lib/components/tool-error.d.ts +2 -0
- package/dist/lib/components/tool-error.d.ts.map +1 -1
- package/dist/lib/copy/assistant-snapshot.d.ts.map +1 -1
- package/dist/lib/copy/use-copy-element-as-image.d.ts +1 -1
- package/dist/lib/copy/use-copy-element-as-image.d.ts.map +1 -1
- package/dist/lib/elements/Response.d.ts.map +1 -1
- package/dist/lib/elements/Tool.d.ts.map +1 -1
- package/dist/lib/elements/table-panel-extension.d.ts +1 -1
- package/dist/lib/elements/table-panel-extension.d.ts.map +1 -1
- package/dist/lib/i18n/messages.d.ts +80 -0
- package/dist/lib/i18n/messages.d.ts.map +1 -1
- package/dist/lib/i18n/provider.d.ts +6 -2
- package/dist/lib/i18n/provider.d.ts.map +1 -1
- package/dist/lib/renderers/render-part.d.ts.map +1 -1
- package/dist/lib/ui/UnicodeSpinner.d.ts.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -57,6 +57,61 @@ render(
|
|
|
57
57
|
);
|
|
58
58
|
```
|
|
59
59
|
|
|
60
|
+
## Words and languages
|
|
61
|
+
|
|
62
|
+
Every word the chat draws comes from one typed catalog, `GenaiMessages`. The package ships English (`en`). A host gives its own words on `GenaiMessagesProvider`, above the chat:
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import {
|
|
66
|
+
type GenaiMessages,
|
|
67
|
+
GenaiMessagesProvider,
|
|
68
|
+
} from '@deepagents/react-genai';
|
|
69
|
+
|
|
70
|
+
const ar: Partial<GenaiMessages> = {
|
|
71
|
+
'message.copy': 'انسخ الرسالة',
|
|
72
|
+
'composer.send': 'أرسل الطلب',
|
|
73
|
+
'steps.tools': ({ count, status }, { plural }) =>
|
|
74
|
+
status === 'complete'
|
|
75
|
+
? plural(count, {
|
|
76
|
+
zero: 'لم تعمل أي أداة',
|
|
77
|
+
one: 'عملت أداة واحدة',
|
|
78
|
+
two: 'عملت أداتان',
|
|
79
|
+
few: 'عملت # أدوات',
|
|
80
|
+
many: 'عملت # أداة',
|
|
81
|
+
other: 'عملت # أداة',
|
|
82
|
+
})
|
|
83
|
+
: plural(count, {
|
|
84
|
+
one: 'عملت أداة واحدة وتوقفت',
|
|
85
|
+
two: 'عملت أداتان وتوقفتا',
|
|
86
|
+
few: 'عملت # أدوات وتوقفت',
|
|
87
|
+
other: 'عملت # أداة وتوقفت',
|
|
88
|
+
}),
|
|
89
|
+
markdown: { copyTable: 'انسخ الجدول', downloadTable: 'نزّل الجدول' },
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
<GenaiMessagesProvider locale="ar" messages={ar}>
|
|
93
|
+
<App />
|
|
94
|
+
</GenaiMessagesProvider>;
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
- A message is a string, or a function of its typed arguments and `{ plural, format }`. `plural(count, forms)` picks the form that `Intl.PluralRules` of the locale gives, needs `other`, and writes the count, formatted by `Intl.NumberFormat` of the locale, in place of `#`. A count sentence is one message, never pieces joined in code.
|
|
98
|
+
- A key the catalog leaves out keeps the English word.
|
|
99
|
+
- `markdown` holds streamdown's words (`StreamdownTranslations` of `streamdown`) for every `Response`. A `translations` prop on a `Response` wins over it, key by key.
|
|
100
|
+
- `dir` is the text direction of the locale (`Intl.Locale`) unless the host gives it. The provider hands it to Base UI's `DirectionProvider`, so popups and menus follow it. Text blocks keep `dir="auto"`, so an English answer in an Arabic chat still reads left to right.
|
|
101
|
+
- A message can call the host's own i18n library.
|
|
102
|
+
|
|
103
|
+
Providers nest. An inner provider changes only the keys it gives, the `markdown` keys too:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
<GenaiMessagesProvider locale="ar" messages={ar}>
|
|
107
|
+
<GenaiMessagesProvider locale="ar" messages={{ 'chat.greeting': 'مرحبًا' }}>
|
|
108
|
+
<Chat />
|
|
109
|
+
</GenaiMessagesProvider>
|
|
110
|
+
</GenaiMessagesProvider>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The parts of `@deepagents/react-input` that `ChatComposer` renders, such as the editor and the attachment strip, keep their own English words.
|
|
114
|
+
|
|
60
115
|
## One copy of @zukhruf/ui
|
|
61
116
|
|
|
62
117
|
The host and this package must use the same copy of `@zukhruf/ui`. Each copy has its own React context. A `ClockProvider` of one copy does not reach a `TheButton` of the other copy, and the button throws `No clock set, use ClockProvider to set one`. For this reason `@zukhruf/ui` is a peer dependency. npm refuses an install when the version of the host is out of the range.
|