import { Badge, Button, Divider, Group, Paper, Select, Stack, Text, TextInput, Textarea, Title, } from "@mantine/core"; import type { SamplingMessage } from "@modelcontextprotocol/sdk/types.js"; import { MessageBubble } from "../../elements/MessageBubble/MessageBubble"; export interface SamplingTool { name: string; description?: string; inputSchema: Record; } export interface SamplingRequestPanelProps { messages: SamplingMessage[]; modelHints?: string[]; costPriority?: number; speedPriority?: number; intelligencePriority?: number; maxTokens?: number; stopSequences?: string[]; temperature?: number; includeContext?: string; tools?: SamplingTool[]; toolChoice?: string; responseText: string; modelUsed: string; stopReason: string; onResponseChange: (text: string) => void; onModelChange: (model: string) => void; onStopReasonChange: (reason: string) => void; onAutoRespond: () => void; onSend: () => void; onReject: () => void; } function formatPriority(value: number): string { if (value < 0.4) return `low (${value})`; if (value <= 0.7) return `medium (${value})`; return `high (${value})`; } function formatOptional(value: unknown, fallback: string): string { return value !== undefined ? String(value) : fallback; } function serializeJson(value: unknown): string { return JSON.stringify(value); } const HintText = Text.withProps({ size: "sm", c: "dimmed", }); const PreferencesContainer = Paper.withProps({ p: "sm", withBorder: true, }); const ToolCard = Paper.withProps({ p: "xs", withBorder: true, }); const ToolName = Text.withProps({ size: "sm", fw: 600, }); const RejectButton = Button.withProps({ variant: "light", color: "red", }); export function SamplingRequestPanel({ messages, modelHints, costPriority, speedPriority, intelligencePriority, maxTokens, stopSequences, temperature, includeContext, tools, toolChoice, responseText, modelUsed, stopReason, onResponseChange, onModelChange, onStopReasonChange, onAutoRespond, onSend, onReject, }: SamplingRequestPanelProps) { return ( The server is requesting an LLM completion. Messages: {messages.map((message, index) => ( ))} {modelHints && modelHints.length > 0 && ( Model Preferences: Hints: {modelHints.map((hint) => ( {hint} ))} {costPriority !== undefined && ( Cost Priority: {formatPriority(costPriority)} )} {speedPriority !== undefined && ( Speed Priority: {formatPriority(speedPriority)} )} {intelligencePriority !== undefined && ( Intelligence Priority: {formatPriority(intelligencePriority)} )} )} Parameters: Max Tokens: {formatOptional(maxTokens, "not specified")} Stop Sequences:{" "} {stopSequences ? serializeJson(stopSequences) : "not specified"} Temperature: {formatOptional(temperature, "not specified")} {includeContext && ( Include Context: {includeContext} )} {tools && tools.length > 0 && ( <> Available Tools: {tools.map((tool) => ( {tool.name} {tool.description && {tool.description}} ))} )} {toolChoice && Tool Choice: {toolChoice}} Response: