Skip to content

feat: Add comprehensive Playground UI for model testing#259

Open
fdkgenie wants to merge 18 commits intodecolua:masterfrom
fdkgenie:dev_playground
Open

feat: Add comprehensive Playground UI for model testing#259
fdkgenie wants to merge 18 commits intodecolua:masterfrom
fdkgenie:dev_playground

Conversation

@fdkgenie
Copy link

@fdkgenie fdkgenie commented Mar 7, 2026

Overview

Add a full-featured Playground UI to test models, debug requests, and evaluate performance directly from the dashboard.

Key Features

🎯 Core Testing

  • Model selection with auto-fetch support
  • Streaming/non-streaming toggle with live output
  • Custom prompt templates (coding, translation, summarization, etc.)
  • Multi-turn chat sessions with context preservation
  • Authorization header support

🔧 Advanced Controls

  • Parameter tuning (temperature, top_p, max_tokens)
  • System prompt customization
  • Request/response debug panel
  • Cost estimation with pricing data integration

📊 Batch Evaluation

  • Run multiple prompts sequentially
  • Performance metrics (latency, avg response time)
  • Side-by-side result comparison

💾 Developer Tools

  • Copy as cURL command
  • Copy as JavaScript/SDK snippet
  • Request/response history with replay
  • Raw JSON response viewer

🎨 UI/UX

  • 2-column responsive layout (input controls | output results)
  • Mobile-friendly (stacks to 1 column on small screens)
  • Real-time streaming character count
  • Persistent preferences (default model, parameters)

Technical Details

  • New Route: /dashboard/playground
  • Main File: src/app/(dashboard)/dashboard/playground/page.js (776 lines)
  • Dependencies: Existing Card, Button, Input, Select components
  • API Integration: Uses /api/v1/chat/completions endpoint

Testing

  • ✅ Build passes without errors
  • ✅ Streaming and non-streaming modes work
  • ✅ Batch evaluation tested with multiple prompts
  • ✅ Cost estimation calculates correctly
  • ✅ Responsive layout verified

Screenshots

The playground provides a clean, intuitive interface similar to OpenAI Playground and Anthropic Console, with all controls on the left and results on the right.

Migration Notes

No breaking changes. This is a pure addition with no impact on existing functionality.

Claude AI and others added 18 commits March 6, 2026 14:44
Co-authored-by: fdkgenie <75261157+fdkgenie@users.noreply.github.com>
- Fixed syntax errors in autoFetchModels.js (removed duplicate lines)
- Added Ramclouds to validation endpoint
- Added automatic model fetching when creating provider connections
- Updated /v1/models API to prioritize dynamically fetched models over static ones
- Updated test-models endpoint to use fetched models from connection data
- Updated provider detail page to reactively compute models using useMemo

This ensures that when adding Ramclouds with a valid API key, the system
automatically fetches and displays all 12 available models instead of
falling back to the static "auto" model.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Added Amp CLI configuration to cliTools.js with settings and secrets file paths
- Created API endpoint /api/cli-tools/amp-settings for managing Amp configuration
- Created AmpToolCard component for Amp CLI configuration UI
- Integrated Amp CLI into CLI Tools page with status checking and auto-apply
- Added Amp logo (amp.svg) to public/providers

Configuration supports:
- Base URL configuration (~/.config/amp/settings.json)
- API key management (~/.local/share/amp/secrets.json)
- Environment variable alternatives (AMP_URL, AMP_API_KEY)
- Manual configuration export for copy-paste setup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Added comprehensive Amp CLI integration with:

**Settings & Configuration:**
- Added ampUpstreamUrl, ampUpstreamApiKey, ampRestrictManagementToLocalhost to settings
- Added 6 default Amp modes with model mappings (Smart, Rush, Oracle, Librarian, Search, Review)
- Created settings UI in profile page for Amp upstream configuration

**Server-Side Proxy Endpoints:**
- /api/provider/[provider]/[...path] - Routes provider API requests
  - Checks if model is mapped locally → uses local 9router providers
  - If not mapped → forwards to ampcode.com as reverse proxy
- /api/auth/[...path] - Proxies management API auth requests
- /api/threads/[...path] - Proxies threads management API
- /api/user/[...path] - Proxies user management API
- All management APIs authenticate with 9router API keys and forward to upstream

**Client-Side UI:**
- Updated AmpToolCard with model mapping UI for 6 Amp modes
- Added model selector for each Amp mode
- Integrated with CLIToolsPageClient for model mappings state
- Updated amp-settings API to save model mappings

**Features:**
- Auto-decompression of gzipped responses from upstream
- Localhost restriction option for management APIs
- Model mapping storage in 9router settings
- Seamless routing between local and upstream models

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This aligns internal, user, auth, threads, and provider endpoint behavior with Amp expectations so login, startup checks, and execute flows work reliably with local 9router routing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Implement /api/providers/[id]/models endpoint to fetch models from provider APIs
- Update ModelSelectModal to use dynamic models from providerSpecificData
- Update CLI Tools and MITM pages to prioritize dynamic models over static config
- Add Ramclouds provider logo
- Fallback to static models when dynamic fetch is unavailable
Resolves issue where proxy returned malformed payloads mixing JSON and SSE terminators (e.g., JSON body followed by `data: [DONE]`), causing SDK/client parsers to fail.

Changes:
- Correct stream intent: require explicit `stream: true` instead of defaulting to streaming when omitted
- Add upstream content-type validation: route non-SSE responses to JSON handler even when streaming is requested
- Gate [DONE] sentinel: only append SSE terminator when valid SSE data events were observed

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fixes issue where gemini-web-to-api returns non-streaming JSON but Claude Code CLI expects SSE format, causing "request ended without sending any chunks" error.

Changes:
- Add jsonToSseHandler to convert JSON responses to SSE streams
- Update chatCore to route JSON responses through converter when client requests streaming
- Preserve SSE headers in Amp CLI proxy route handler

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implemented medium-priority features:
- Multi-turn chat session with context preservation
- Parameter controls (temperature, top_p, max_tokens)
- System prompt support
- Persist default model and preferences to localStorage
- Enhanced streaming with character count display

This builds on the high-priority features already committed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…n, and batch eval

Implemented step 3 advanced features:
- Debug panel showing request/response headers and details
- Cost estimation with pricing data integration
- Batch evaluation mode to run multiple prompts sequentially
- Toggle between single and batch mode
- Summary statistics for batch runs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Changed from single column to 2-column layout for better balance:
- Left column: Input controls (model, prompts, parameters, batch mode)
- Right column: Output and results (output, chat session, debug panel, history)
- Responsive: stacks to 1 column on smaller screens (xl breakpoint)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants