Skip to content

Commit 6f81bb3

Browse files
committed
add context after connected
1 parent 7bdc45e commit 6f81bb3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

app/components/realtime-chat/realtime-chat.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function RealtimeChat({
7676
? { type: "server_vad" }
7777
: null;
7878
clientRef.current.configure({
79-
instructions: "Hi",
79+
instructions: "",
8080
input_audio_transcription: { model: "whisper-1" },
8181
turn_detection: turnDetection,
8282
tools: [],
@@ -86,6 +86,19 @@ export function RealtimeChat({
8686
startResponseListener();
8787

8888
setIsConnected(true);
89+
try {
90+
const recentMessages = chatStore.getMessagesWithMemory();
91+
for (const message of recentMessages) {
92+
const { role, content } = message;
93+
await clientRef.current.sendItem({
94+
type: "message",
95+
role,
96+
content: [{ type: "input_text", text: content }],
97+
});
98+
}
99+
} catch (error) {
100+
console.error("Set message failed:", error);
101+
}
89102
} catch (error) {
90103
console.error("Connection failed:", error);
91104
} finally {

0 commit comments

Comments
 (0)