Skip to content

Commit a387b11

Browse files
authored
Merge pull request #265 from FlowiseAI/bugfix/Starter-Prompts
Bugfix/Starter prompts not appearing
2 parents 4c57e7e + 04cf0ba commit a387b11

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

dist/components/Bot.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ export type BotProps = {
9292
footer?: FooterTheme;
9393
sourceDocsTitle?: string;
9494
observersConfig?: observersConfigType;
95-
starterPrompts?: string[];
95+
starterPrompts?: string[] | Record<string, {
96+
prompt: string;
97+
}>;
9698
starterPromptFontSize?: number;
9799
clearChatOnReload?: boolean;
98100
disclaimer?: DisclaimerPopUpTheme;

dist/components/Bot.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/web.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Bot.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export type BotProps = {
139139
footer?: FooterTheme;
140140
sourceDocsTitle?: string;
141141
observersConfig?: observersConfigType;
142-
starterPrompts?: string[];
142+
starterPrompts?: string[] | Record<string, { prompt: string }>;
143143
starterPromptFontSize?: number;
144144
clearChatOnReload?: boolean;
145145
disclaimer?: DisclaimerPopUpTheme;
@@ -540,7 +540,7 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
540540
if (response.ok && response.headers.get('content-type') === EventStreamContentType) {
541541
return; // everything's good
542542
} else if (response.status === 429) {
543-
const errMessage = await response.text() ?? 'Too many requests. Please try again later.';
543+
const errMessage = (await response.text()) ?? 'Too many requests. Please try again later.';
544544
handleError(errMessage);
545545
throw new Error(errMessage);
546546
} else {
@@ -825,9 +825,18 @@ export const Bot = (botProps: BotProps & { class?: string }) => {
825825
});
826826

827827
createEffect(() => {
828-
if (props.starterPrompts && props.starterPrompts.length > 0) {
829-
const prompts = Object.values(props.starterPrompts).map((prompt) => prompt);
828+
if (props.starterPrompts) {
829+
let prompts: string[];
830830

831+
if (Array.isArray(props.starterPrompts)) {
832+
// If starterPrompts is an array
833+
prompts = props.starterPrompts;
834+
} else {
835+
// If starterPrompts is a JSON object
836+
prompts = Object.values(props.starterPrompts).map((promptObj: { prompt: string }) => promptObj.prompt);
837+
}
838+
839+
// Filter out any empty prompts
831840
return setStarterPrompts(prompts.filter((prompt) => prompt !== ''));
832841
}
833842
});

0 commit comments

Comments
 (0)