import React, { useState } from "react"; import { Message, LLMContent } from "../types"; interface SystemPromptViewProps { message: Message; } function SystemPromptView({ message }: SystemPromptViewProps) { const [isExpanded, setIsExpanded] = useState(false); // Extract system prompt text from llm_data let systemPromptText = ""; if (message.llm_data) { try { const llmData = typeof message.llm_data === "string" ? JSON.parse(message.llm_data) : message.llm_data; if (llmData && llmData.Content && Array.isArray(llmData.Content)) { const textContent = llmData.Content.find((c: LLMContent) => c.Type === 2 && c.Text); if (textContent) { systemPromptText = textContent.Text; } } } catch (err) { console.error("Failed to parse system prompt:", err); } } if (!systemPromptText) { return null; } // Count lines and approximate size const lineCount = systemPromptText.split("\n").length; const charCount = systemPromptText.length; const sizeKb = (charCount / 1024).toFixed(1); return (
setIsExpanded(!isExpanded)}>
📋 System Prompt {lineCount} lines, {sizeKb} KB
{isExpanded && (
{systemPromptText}
)}
); } export default SystemPromptView;