diff --git a/web/components/shared/utils/utils.tsx b/web/components/shared/utils/utils.tsx index fddfd45931..0cf55d9154 100644 --- a/web/components/shared/utils/utils.tsx +++ b/web/components/shared/utils/utils.tsx @@ -67,7 +67,8 @@ const capitalizeWords = (str: string) => { return capitalizedWords.join(" "); }; -function removeLeadingWhitespace(str: string): string { +function removeLeadingWhitespace(str: string | null): string { + if (!str) return ""; return str.replace(/^\s+/, ""); // Replace one or more whitespace characters at the beginning of the string with an empty string } diff --git a/web/components/templates/requests/chat.tsx b/web/components/templates/requests/chat.tsx index fbd3901bdd..7a528477ff 100644 --- a/web/components/templates/requests/chat.tsx +++ b/web/components/templates/requests/chat.tsx @@ -197,7 +197,7 @@ export const Chat = (props: ChatProps) => { const completionRequestMessages: ChatCompletionRequestMessage[] = heliconeMessagesInput.slice(0, index + 1).map((message: Message) => { const formattedPrompt = formatPrompt2({ - prompt: message.content, + prompt: message.content ?? "", values: props.keys, }); const content = formattedPrompt.data; diff --git a/web/components/templates/requests/requestsPage.tsx b/web/components/templates/requests/requestsPage.tsx index d90a8a4d23..421f67cac7 100644 --- a/web/components/templates/requests/requestsPage.tsx +++ b/web/components/templates/requests/requestsPage.tsx @@ -40,7 +40,7 @@ import useRequestsPage, { export type Message = { role: string; - content: string; + content: string | null; }; export type ChatProperties = {