Skip to content

Commit

Permalink
add context after connected
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydzhou committed Nov 7, 2024
1 parent 7bdc45e commit 6f81bb3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/components/realtime-chat/realtime-chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function RealtimeChat({
? { type: "server_vad" }
: null;
clientRef.current.configure({
instructions: "Hi",
instructions: "",
input_audio_transcription: { model: "whisper-1" },
turn_detection: turnDetection,
tools: [],
Expand All @@ -86,6 +86,19 @@ export function RealtimeChat({
startResponseListener();

setIsConnected(true);
try {
const recentMessages = chatStore.getMessagesWithMemory();
for (const message of recentMessages) {
const { role, content } = message;
await clientRef.current.sendItem({
type: "message",
role,
content: [{ type: "input_text", text: content }],
});
}
} catch (error) {
console.error("Set message failed:", error);
}
} catch (error) {
console.error("Connection failed:", error);
} finally {
Expand Down

0 comments on commit 6f81bb3

Please sign in to comment.