diff --git a/examples/coding-agent/src/components/MessageList.tsx b/examples/coding-agent/src/components/MessageList.tsx new file mode 100644 index 0000000..74d05ff --- /dev/null +++ b/examples/coding-agent/src/components/MessageList.tsx @@ -0,0 +1,58 @@ +import { defineComponent, type PropType } from "vue"; +import { Box, Text } from "@vue-tui/runtime"; +import type { Message } from "../agent"; + +export default defineComponent({ + props: { + message: { type: Object as PropType, required: true }, + }, + setup(props) { + return () => { + const msg = props.message; + + if (msg.role === "user") { + return ( + + + {"You: "} + + {msg.content} + + ); + } + + if (msg.role === "assistant") { + if (msg.tool_calls) { + const parts: any[] = []; + if (msg.content) { + parts.push({msg.content}); + } + for (const tc of msg.tool_calls) { + const parsed = JSON.parse(tc.function.arguments); + parts.push( + + {parsed.command} + , + ); + } + return {parts}; + } + return ( + + {msg.content} + + ); + } + + if (msg.role === "tool") { + return ( + + {msg.content} + + ); + } + + return null; + }; + }, +});