@paymanai/payman-ask-sdk 2.0.5 → 4.0.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 +51 -0
- package/dist/index.d.mts +372 -219
- package/dist/index.d.ts +372 -219
- package/dist/index.js +3188 -4588
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3191 -4574
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.js +1800 -3953
- package/dist/index.native.js.map +1 -1
- package/dist/styles.css +132 -602
- package/dist/styles.css.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -93,6 +93,15 @@ type ChatConfig = {
|
|
|
93
93
|
text?: string;
|
|
94
94
|
icon?: boolean;
|
|
95
95
|
content?: React.ReactNode;
|
|
96
|
+
suggestions?: {
|
|
97
|
+
enabled?: boolean;
|
|
98
|
+
title?: string;
|
|
99
|
+
categories: Array<{
|
|
100
|
+
label: string;
|
|
101
|
+
icon?: React.ReactNode;
|
|
102
|
+
prompts: string[];
|
|
103
|
+
}>;
|
|
104
|
+
};
|
|
96
105
|
};
|
|
97
106
|
|
|
98
107
|
input?: {
|
|
@@ -154,6 +163,48 @@ Leaving the `ui` block out renders a usable ChatGPT-style surface:
|
|
|
154
163
|
|
|
155
164
|
Turn features on with booleans, and only reach for the full object form when you need custom labels, widths, or per-option toggles.
|
|
156
165
|
|
|
166
|
+
## Suggested prompts
|
|
167
|
+
|
|
168
|
+
Use `ui.emptyState.suggestions` when an app wants SDK-rendered prompt shortcuts on the first screen. Apps own the content; the SDK owns rendering, accessibility, click handling, responsive layout, and styling.
|
|
169
|
+
|
|
170
|
+
The SDK renders categories as compact bubbles first. Clicking a category reveals that category's prompts below it; clicking a prompt sends the prompt text verbatim. On narrow screens and React Native, categories become a horizontal touch scroller so the empty state stays compact.
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
const isProd = process.env.NEXT_PUBLIC_ENV === "production";
|
|
174
|
+
const suggestions = {
|
|
175
|
+
enabled: true,
|
|
176
|
+
title: "Good evening\nHow can I help you today?",
|
|
177
|
+
categories: [
|
|
178
|
+
{ label: "ACCOUNTS", prompts: ["Show my account balance"] },
|
|
179
|
+
{ label: "PAYMENTS", prompts: ["Pay Sarah $50", "Transfer money to my savings"] },
|
|
180
|
+
...(isProd
|
|
181
|
+
? []
|
|
182
|
+
: [{ label: "SIMULATION TOOLS", prompts: ["Simulate a mid-stream error"] }]),
|
|
183
|
+
],
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
<PaymanChat
|
|
187
|
+
config={{
|
|
188
|
+
...config,
|
|
189
|
+
ui: {
|
|
190
|
+
...config.ui,
|
|
191
|
+
emptyState: {
|
|
192
|
+
...config.ui?.emptyState,
|
|
193
|
+
suggestions,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
}}
|
|
197
|
+
/>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
`enabled: false` hides the bubbles without removing the data. Category and prompt arrays render in the order provided, and empty categories are ignored. Bubbles disappear after the first message because they are part of the empty state.
|
|
201
|
+
|
|
202
|
+
`title` is optional and falls back to `ui.emptyState.text`. Newlines are preserved, so pass `"Good evening\nHow can I help you today?"` when you want the original two-line empty-state layout. If a single-line greeting like `"Good evening How can I help..."` is provided, the SDK inserts a dash between the greeting and question.
|
|
203
|
+
|
|
204
|
+
`icon` is optional. When omitted, the SDK chooses a small built-in glyph from the category label for common labels like payments, accounts, insights, and products.
|
|
205
|
+
|
|
206
|
+
Suggested prompts use the same `--payman-v2-*` CSS variables as the rest of the chat surface, so app-level theme overrides automatically apply to bubble background, text, border, hover, radius, and focus states. The React Native renderer uses native `Pressable` and `ScrollView` controls with the same category-first behavior.
|
|
207
|
+
|
|
157
208
|
## Session history
|
|
158
209
|
|
|
159
210
|
Pass `ui.sessionHistory: true` and provide `workflow.id` + `session.owner.id`. `<PaymanChat/>` mounts a resizable, collapsible sidebar on desktop and a hamburger-triggered drawer on mobile. Clicking a row calls `loadSession(sessionId)` — which cancels any in-flight stream, clears the current chat, fetches the conversation history, and renders it with `isHistorical: true` (renderers skip the thinking/step UI for those rows).
|