Skip to content

Commit de39058

Browse files
i-subham23vishxrad
andauthored
refactor: update system prompts to ensure consistent data generation guidelines (#707)
* refactor: update system prompts to ensure consistent data generation guidelines - Reintroduced the rule to generate realistic/plausible data across various system prompts in chat and playground examples. - Adjusted the structure of prompt options in the playground library to include additional rules. - Enhanced documentation for forms and charts to clarify component usage and data handling. This update aims to standardize the approach to data generation in the system prompts, ensuring a more coherent user experience across different examples. * refactor: standardize data generation guidelines across system prompts - Reintroduced the guideline to generate realistic/plausible data in various system prompts, ensuring consistency across chat and playground examples. - Updated the structure of prompt options in the playground library to remove redundant rules. - Enhanced documentation for forms and charts to clarify component usage and data handling. This update aims to improve the coherence of data generation practices in the system prompts, enhancing the overall user experience. * refactor: enhance system prompt documentation for forms and charts - Updated the system prompt files across multiple examples to improve clarity and consistency in the documentation of form and chart components. - Added optional parameters to various components, including `Col`, `PieChart`, `Form`, `Select`, `DatePicker`, `CheckBoxGroup`, and `SwitchGroup`, to enhance flexibility in usage. - Ensured that all changes align with the recent standardization efforts in data generation guidelines, contributing to a more coherent user experience across examples. * fix(lang-core): remove hardcoded Stack prompt example * fix(lang-core): remove remaining hardcoded Stack prompts * fix(lang-core): use generic components in prompt examples * fix(lang-core): use generic list in prompt example --------- Co-authored-by: Visharad Kashyap <154831195+vishxrad@users.noreply.github.com>
1 parent 469750a commit de39058

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

packages/lang-core/src/parser/prompt.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function syntaxRules(
124124
'3. Expressions are: strings ("..."), numbers, booleans (true/false), null, arrays ([...]), objects ({...}), or component calls TypeName(arg1, arg2, ...)',
125125
"4. Use references for readability: define `name = ...` on one line, then use `name` later",
126126
"5. EVERY variable (except root) MUST be referenced by at least one other variable. Unreferenced variables are silently dropped and will NOT render. Always include defined variables in their parent's children/items array.",
127-
'6. Arguments are POSITIONAL (order matters, not names). Write `Stack([children], "row", "l")` NOT `Stack([children], direction: "row", gap: "l")` — colon syntax is NOT supported and silently breaks',
127+
'6. Arguments are POSITIONAL (order matters, not names). Write `SomeComp([children], "row", "l")` NOT `SomeComp([children], direction: "row", gap: "l")` — colon syntax is NOT supported and silently breaks',
128128
"7. Optional arguments can be omitted from the end",
129129
];
130130

@@ -321,8 +321,7 @@ The runtime merges by statement name: same name = replace, new name = append.
321321
Output ONLY statements that changed or are new. Everything else is kept automatically.
322322
323323
### Delete
324-
To remove a component, update the parent to exclude it from its children array. Orphaned statements are automatically garbage-collected.
325-
Example — remove chart: \`root = Stack([header, kpiRow, table])\` — chart is no longer in the children list, so it and any statements only it referenced are auto-deleted.
324+
To remove a component, re-declare its parent without that component in the parent's children array. The removed component and any statements only it referenced are automatically garbage-collected.
326325
327326
### Patch size guide
328327
- Changing a title or label: 1 statement
@@ -407,7 +406,7 @@ WRONG — you called a tool and got data back, but you inlined the results:
407406
openCount = 2
408407
item1 = SomeComp("first item title")
409408
item2 = SomeComp("second item title")
410-
list = Stack([item1, item2])
409+
list = SomeList([item1, item2])
411410
chart = SomeChart(["A", "B"], [12, 8])
412411
\`\`\`
413412
This is static — it shows stale data and won't update. Creating item1, item2, item3... manually is ALWAYS wrong when a tool exists.
@@ -444,7 +443,6 @@ function importantRules(
444443
}
445444

446445
return `## Important Rules
447-
- When asked about data, generate realistic/plausible data
448446
- Choose components that best represent the content (tables for comparisons, charts for trends, forms for input, etc.)
449447
450448
## Final Verification

packages/react-email/src/library.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ si2 = EmailSocialIcon("https://react.email/static/instagram-logo.png", "Instagra
392392
// ── Additional rules (email only) ──
393393

394394
export const emailAdditionalRules: string[] = [
395+
"When asked about data, generate realistic/plausible data",
395396
"You are an expert email designer using react-email components.",
396397
"The 10 supported email types are: Welcome/Onboarding, Newsletter, Order Confirmation, Password Reset, Promotional/Sale, Event Invitation, Feedback Request, Shipping/Delivery Update, Account Verification, Onboarding Tutorial.",
397398
"Use realistic, professional placeholder text — never use lorem ipsum.",

packages/react-ui/src/genui-lib/prompt-options/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ vueContent = [TextContent("Vue is a progressive framework by Evan You."), Callou
4747
];
4848

4949
export const openuiAdditionalRules: string[] = [
50+
"When asked about data, generate realistic/plausible data",
5051
'For grid-like layouts, use Stack with direction "row" and wrap=true. Avoid justify="between" unless you specifically want large gutters.',
5152
"For forms, define one FormControl reference per field so controls can stream progressively.",
5253
"For forms, always provide the second Form argument with Buttons(...) actions: Form(name, buttons, fields).",
@@ -119,6 +120,7 @@ btns = Buttons([Button("Submit", Action([@ToAssistant("Submit")]), "primary")])`
119120
];
120121

121122
export const openuiChatAdditionalRules: string[] = [
123+
"When asked about data, generate realistic/plausible data",
122124
"Every response is a single Card(children) — children stack vertically automatically. No layout params are needed on Card.",
123125
"Card is the only layout container. Do NOT use Stack. Use Tabs to switch between sections, Carousel for horizontal scroll.",
124126
"Use FollowUpBlock at the END of a Card to suggest what the user can do or ask next.",

0 commit comments

Comments
 (0)