Skip to content

Commit 64732f0

Browse files
authored
Fix: remove sandbox link from openai models (#145)
1 parent 588e0d6 commit 64732f0

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

.changeset/quick-socks-learn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"create-llama": patch
3+
---
4+
5+
Fix the issue of images not showing with the sandbox URL from OpenAI's models

templates/types/streaming/nextjs/app/components/ui/chat/chat-message/markdown.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,19 @@ const preprocessLaTeX = (content: string) => {
2828
return inlineProcessedContent;
2929
};
3030

31+
const preprocessMedia = (content: string) => {
32+
// Remove `sandbox:` from the beginning of the URL
33+
// to fix OpenAI's models issue appending `sandbox:` to the relative URL
34+
return content.replace(/(sandbox|attachment|snt):/g, "");
35+
};
36+
37+
const preprocessContent = (content: string) => {
38+
return preprocessMedia(preprocessLaTeX(content));
39+
};
40+
3141
export default function Markdown({ content }: { content: string }) {
32-
const processedContent = preprocessLaTeX(content);
42+
const processedContent = preprocessContent(content);
43+
3344
return (
3445
<MemoizedReactMarkdown
3546
className="prose dark:prose-invert prose-p:leading-relaxed prose-pre:p-0 break-words custom-markdown"

0 commit comments

Comments
 (0)