create-supyagent-app 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { use, useEffect, useState } from "react";
|
|
4
|
+
import type { UIMessage } from "ai";
|
|
4
5
|
import { Chat } from "@/components/chat";
|
|
5
6
|
|
|
6
|
-
interface ChatMessage {
|
|
7
|
-
id: string;
|
|
8
|
-
role: string;
|
|
9
|
-
parts: Array<{ type: string; [key: string]: unknown }>;
|
|
10
|
-
metadata?: Record<string, unknown>;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
7
|
export default function ChatPage({ params }: { params: Promise<{ id: string }> }) {
|
|
14
8
|
const { id } = use(params);
|
|
15
|
-
const [initialMessages, setInitialMessages] = useState<
|
|
9
|
+
const [initialMessages, setInitialMessages] = useState<UIMessage[] | null>(null);
|
|
16
10
|
|
|
17
11
|
useEffect(() => {
|
|
18
12
|
fetch(`/api/chats/${id}`)
|
|
@@ -31,8 +31,8 @@ export function ChatMessage({ message }: ChatMessageProps) {
|
|
|
31
31
|
if (part.type === "tool-invocation") {
|
|
32
32
|
return (
|
|
33
33
|
<div key={i} className="space-y-2">
|
|
34
|
-
<SupyagentToolCall part={part as
|
|
35
|
-
<SupyagentToolResult part={part as
|
|
34
|
+
<SupyagentToolCall part={part as any} />
|
|
35
|
+
<SupyagentToolResult part={part as any} />
|
|
36
36
|
</div>
|
|
37
37
|
);
|
|
38
38
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import { useChat } from "@ai-sdk/react";
|
|
4
|
+
import type { UIMessage } from "ai";
|
|
4
5
|
import { ChatMessage } from "./chat-message";
|
|
5
6
|
import { ChatInput } from "./chat-input";
|
|
6
7
|
import { ChatSidebar } from "./chat-sidebar";
|
|
@@ -8,7 +9,7 @@ import { useRef, useEffect } from "react";
|
|
|
8
9
|
|
|
9
10
|
interface ChatProps {
|
|
10
11
|
chatId: string;
|
|
11
|
-
initialMessages:
|
|
12
|
+
initialMessages: UIMessage[];
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export function Chat({ chatId, initialMessages }: ChatProps) {
|
|
@@ -16,7 +17,7 @@ export function Chat({ chatId, initialMessages }: ChatProps) {
|
|
|
16
17
|
useChat({
|
|
17
18
|
api: "/api/chat",
|
|
18
19
|
body: { chatId },
|
|
19
|
-
initialMessages
|
|
20
|
+
initialMessages,
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
const scrollRef = useRef<HTMLDivElement>(null);
|