Skip to content

Commit e0c74ba

Browse files
Merge pull request #19 from BeRecursive22/enh/chat-ui
Enh/chat UI
2 parents dac2f24 + 9546780 commit e0c74ba

File tree

8 files changed

+25
-21
lines changed

8 files changed

+25
-21
lines changed

src/api/chat-event-stream.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,14 @@ export function createStreamManager(options: StreamManagerOptions) {
2626
try {
2727
const parsedData = JSON.parse(event.data);
2828
console.log("Parsed Data: ", parsedData);
29-
if(parsedData.type === "presentation_content"){
30-
onStorymapMessage?.(parsedData.data);
31-
} else if(parsedData.type === "status" || parsedData.type === "complete"){
29+
if(parsedData.type === "placestory"){
30+
console.log("Placestory: ", parsedData.payload);
31+
onStorymapMessage?.(parsedData.payload);
32+
} else if(parsedData.type === "status"){
3233
console.log("Status: ", parsedData);
3334
onJobStatus?.(parsedData);
35+
} else if(parsedData.type === "message"){
36+
onStreaming?.(parsedData.payload);
3437
} else {
3538
onStreaming?.(parsedData);
3639
console.log("Streaming: ", parsedData);

src/api/create-chat-stream.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ export const createChatStream = async (props: ChatProps) => {
1212
try {
1313
const result = await ky.post(`${BASE_URL}/v1/storymap/chat/${sessionId}`,
1414
{
15+
timeout: 30000,
1516
json: {
1617
user_message: prompt
17-
}
18-
}
18+
},
19+
},
1920
).json<ChatStreamResponse>()
2021
console.log("Result:", result);
2122
return result

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ export const LOCAL_API_URL = "http://localhost:8000"
1616
// }
1717
// }
1818

19-
export const BASE_URL = API_URL
19+
export const BASE_URL = LOCAL_API_URL

src/features/chat.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ import remarkGfm from "remark-gfm";
2323
import { v4 as uuidv4 } from "uuid";
2424

2525
const queries = [
26-
"Build me an interactive presentation for 1 S Main St, Bel Air, MD 21014 for use as a Restaurant",
27-
"Build me an interactive presentation for 123 Market Street, San Francisco, CA 94105 for use as a Retail",
28-
"Build me an interactive presentation for 555 Madison Avenue, New York, NY 10022 for use as an Office",
26+
"Plan a placestory highlighting the redevelopment of 1 S Main St, Bel Air, MD 21014 into a farm-to-table dining destination.",
27+
"Design a placestory showcasing 123 Market Street, San Francisco, CA 94105 as an innovative retail hub for emerging brands.",
28+
"Craft a placestory that positions 555 Madison Avenue, New York, NY 10022 as a premium corporate headquarters for finance firms.",
2929
];
3030

3131
export const Chat = () => {
@@ -225,7 +225,7 @@ const ChatMessages = ({
225225
const messagesEndRef = useRef<HTMLDivElement>(null);
226226
const scrollContainerRef = useRef<HTMLDivElement>(null);
227227
const [showCopiedMessage, setShowCopiedMessage] = useState(false);
228-
const { streamId, jobStatus } = useUserStore();
228+
const { jobStatus, isProcessingMessage } = useUserStore();
229229

230230
console.log("Job status: ", jobStatus);
231231

@@ -307,7 +307,7 @@ const ChatMessages = ({
307307
<div className="flex items-center justify-start gap-2 mt-3">
308308
<span className="w-2 h-2 rounded-full bg-orange-600"></span>
309309
<span className="text-xs text-border font-light">
310-
IP Agent
310+
Placestory
311311
</span>
312312
</div>
313313
)}
@@ -483,7 +483,7 @@ const ChatMessages = ({
483483
</ReactMarkdown>
484484

485485
{/* Copy button for assistant messages only */}
486-
{message.type === "assistant" && !streamId && (
486+
{message.type === "assistant" && !isProcessingMessage && (
487487
<div className="flex items-center justify-end gap-2">
488488
<Tooltip>
489489
<TooltipTrigger>

src/features/storymap-preview.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ export const StorymapPreview = () => {
6363
return (
6464
<div className="w-full h-full">
6565
<div className="w-full h-12 bg-neutral-200 flex items-center justify-between p-2 px-6 shadow-md">
66-
<span className="text-sm font-medium">{storymapContent?.presentation_title || "Presentation Title here..."}</span>
66+
<span className="text-sm font-medium">{storymapContent?.placestory_title || "Presentation Title here..."}</span>
6767
<Button onClick={() => exportContentAsMarkdown()} variant="outline">Export</Button>
6868
</div>
6969
<div className="w-full h-[calc(100%-48px)] overflow-y-auto">
7070
{storymapContent && (
71-
<RenderBlocks blocks={storymapContent.presentation_blocks} />
71+
<RenderBlocks blocks={storymapContent.placestory_blocks} />
7272
)}
7373
</div>
7474
</div>

src/lib/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,13 @@ export const mdForBlock = (presentationBlock: StorymapBlocks, level = 2): string
9696
export const storymapToMarkdown = (t: StorymapTemplate): string => {
9797
const frontmatter = [
9898
"---",
99-
`Title: ${t.presentation_title}`,
99+
`Title: ${t.placestory_title}`,
100100
"Exported: true",
101101
"---",
102102
"",
103103
].join("\n");
104-
const title = `# ${t.presentation_title}\n\n`;
105-
const body = t.presentation_blocks.map(b => mdForBlock(b, 2)).join("\n");
104+
const title = `# ${t.placestory_title}\n\n`;
105+
const body = t.placestory_blocks.map(b => mdForBlock(b, 2)).join("\n");
106106
return frontmatter + title + body;
107107
}
108108

src/tests/dummy-templates.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import type { StorymapTemplate } from "@/types/storymap.types";
33
const dummyImageUrl = "https://res.cloudinary.com/truva-production/image/upload/t_large_image/t_invisible_watermark/f_auto/oykm1v47ofwvz737xz27"
44

55
export const DummyTemplate: StorymapTemplate = {
6-
presentation_title: "A Premier Culinary Destination: 555 Madison Avenue",
7-
presentation_blocks: [
6+
placestory_title: "A Premier Culinary Destination: 555 Madison Avenue",
7+
placestory_blocks: [
88
{
99
id: "cover_block_01",
1010
type: "cover" as const,

src/types/storymap.types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,6 @@ export type StorymapBlocks = CoverBlockType | TextBlockType | ImageBlockType | M
103103

104104

105105
export interface StorymapTemplate {
106-
presentation_title: string;
107-
presentation_blocks: StorymapBlocks[];
106+
placestory_title: string;
107+
placestory_blocks: StorymapBlocks[];
108108
}

0 commit comments

Comments
 (0)