- File:
code-interpreter/server.py - Changes: Added HTML file detection (
.htmlextension) - MIME Type: Returns
text/htmlfor HTML files - Dependencies: Plotly added to requirements.txt
- Status: ✅ Tested with direct curl - working correctly
curl -X POST http://localhost:5001/execute -H "Content-Type: application/json" \
-d '{"code": "import plotly.graph_objects as go\nfig = go.Figure(data=[go.Bar(x=[\"A\",\"B\",\"C\"], y=[10,20,15])])\nfig.write_html(\"chart.html\")", "files": []}'
Response:
{"error":null,"files":[{"id":"chart.html","name":"chart.html","type":"text/html"}],"session_id":"...","stdout":"...","success":true}- File:
client/src/components/Chat/Messages/Content/Parts/Attachment.tsx - Features:
- Detects
.htmlfile extensions - Renders in sandboxed iframe
- Styled container with filename header
- 600px height for visibility
- Smooth fade-in animation
- Security:
sandbox="allow-scripts allow-same-origin"
- Detects
const HTMLAttachment = memo(({ attachment }: { attachment: TAttachment }) => {
// ... iframe rendering with styled container
});- Updated
Attachmentcomponent to detect HTML files - Updated
AttachmentGroupto group and render HTML attachments separately
Problem: Frontend changes are in source code but not in the running Docker container.
Why:
- Using pre-built image:
ghcr.io/danny-avila/librechat-dev:latest - Build tools (vite) not available in production container
- Client source is mounted (
./client/src:/app/client/src:ro) but dist not rebuilt
Attempted Solutions:
- ❌ Build inside container - vite not available
- ❌ Build on host - missing dependencies/configuration issues
- ✅ Solution: Mount client src and rebuild, OR use agents endpoint
- In LibreChat, create or use an Agent with "Execute Code" capability
- Ask: "Create a Plotly bar chart and save it as chart.html"
- Expected: HTML file should render in iframe (once frontend is deployed)
cd /Users/simo/librechat
# Install deps if not done
cd client && npm install
# Build (needs resolution of package issues)
npm run build
# Restart container
docker compose restart apiRun vite dev server locally to test changes without full rebuild.
- Resolve frontend build: Need to successfully compile client with our changes
- Test with Agents: Use agents endpoint with execute_code capability
- Verify iframe rendering: Confirm HTML files display in iframe
- Test interactivity: Ensure Plotly charts are fully interactive
- ✅ Code interpreter running on port 5001
- ✅ API configured with CODE_INTERPRETER_URL=http://code-interpreter:5000
- ✅ Agents endpoint has
execute_codecapability enabled - ✅ Volume mounts in docker-compose.override.yml
⚠️ Frontend needs rebuild or dev mode
code-interpreter/server.py- HTML detectioncode-interpreter/requirements.txt- Added plotlycode-interpreter/Dockerfile- Rebuilt with plotly
client/src/components/Chat/Messages/Content/Parts/Attachment.tsx- HTML rendering
docker-compose.override.yml- Volume mounts