From 20009aed53d8864c9204d43a17895168a777d2cc Mon Sep 17 00:00:00 2001 From: Ilan Bigio Date: Mon, 16 Dec 2024 13:06:08 -0800 Subject: Initial commit --- webapp/components/transcript.tsx | 104 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 webapp/components/transcript.tsx (limited to 'webapp/components/transcript.tsx') diff --git a/webapp/components/transcript.tsx b/webapp/components/transcript.tsx new file mode 100644 index 0000000..bc2ecbd --- /dev/null +++ b/webapp/components/transcript.tsx @@ -0,0 +1,104 @@ +import React, { useEffect, useRef } from "react"; +import { Card, CardContent } from "@/components/ui/card"; +import { ScrollArea } from "@/components/ui/scroll-area"; +import { Bot, Phone, MessageSquare, Wrench } from "lucide-react"; +import { Item } from "@/components/types"; + +type TranscriptProps = { + items: Item[]; +}; + +const Transcript: React.FC = ({ items }) => { + const scrollRef = useRef(null); + + useEffect(() => { + scrollRef.current?.scrollIntoView({ behavior: "smooth" }); + }, [items]); + + // Show messages, function calls, and function call outputs in the transcript + const transcriptItems = items.filter( + (it) => + it.type === "message" || + it.type === "function_call" || + it.type === "function_call_output" + ); + + return ( + + + {transcriptItems.length === 0 && ( +
+
+
+ +
+
+

+ No messages yet +

+

+ Start a call to see the transcript +

+
+
+
+ )} + +
+ {transcriptItems.map((msg, i) => { + const isUser = msg.role === "user"; + const isTool = msg.role === "tool"; + // Default to assistant if not user or tool + const Icon = isUser ? Phone : isTool ? Wrench : Bot; + + // Combine all text parts into a single string for display + const displayText = msg.content + ? msg.content.map((c) => c.text).join("") + : ""; + + return ( +
+
+ +
+
+
+ + {isUser + ? "Caller" + : isTool + ? "Tool Response" + : "Assistant"} + + + {msg.timestamp} + +
+

+ {displayText} +

+
+
+ ); + })} +
+
+ + + + ); +}; + +export default Transcript; -- cgit v1.2.3