chore: comment context history

This commit is contained in:
Dogtiti 2024-11-09 16:22:01 +08:00
parent d33e772fa5
commit 4629b39c29

View File

@ -85,27 +85,28 @@ export function RealtimeChat({
startResponseListener();
setIsConnected(true);
try {
const recentMessages = chatStore.getMessagesWithMemory();
for (const message of recentMessages) {
const { role, content } = message;
if (typeof content === "string") {
await clientRef.current.sendItem({
type: "message",
role: role as any,
content: [
{
type: (role === "assistant" ? "text" : "input_text") as any,
text: content as string,
},
],
});
}
}
// await clientRef.current.generateResponse();
} catch (error) {
console.error("Set message failed:", error);
}
// TODO
// try {
// const recentMessages = chatStore.getMessagesWithMemory();
// for (const message of recentMessages) {
// const { role, content } = message;
// if (typeof content === "string") {
// await clientRef.current.sendItem({
// type: "message",
// role: role as any,
// content: [
// {
// type: (role === "assistant" ? "text" : "input_text") as any,
// text: content as string,
// },
// ],
// });
// }
// }
// // await clientRef.current.generateResponse();
// } catch (error) {
// console.error("Set message failed:", error);
// }
} catch (error) {
console.error("Connection failed:", error);
setStatus("Connection failed");