Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Ucbepic Docetl AI Chat And Prompt Improvement

From Leeroopedia


Knowledge Sources
Domains Prompt_Engineering, User_Interface
Last Updated 2026-02-08 01:40 GMT

Overview

Concrete UI components and backend endpoints for AI-assisted prompt iteration in the DocETL playground.

Description

The AIChatPanel React component provides a streaming chat interface using the ai/react useChat hook. The PromptImprovementDialog provides automated prompt rewriting with comparison rationale. The backend supports operation decomposition via WebSocket /ws/decompose/{client_id} which uses the FastDecomposer to split complex operations.

Usage

Open the AI Chat Panel from the playground sidebar to ask questions or request improvements. Use the decompose button on an operation card to automatically split it into simpler operations.

Code Reference

Source Location

  • Repository: docetl
  • File: website/src/components/AIChatPanel.tsx (L50-512), website/src/components/PromptImprovementDialog.tsx (L1-1270), server/app/routes/pipeline.py (L469-622)

Signature

// AI Chat Panel
function AIChatPanel(): JSX.Element
// Uses POST /api/chat with streaming response

// Prompt Improvement Dialog
function PromptImprovementDialog({
  operation, onUpdate, onClose
}: PromptImprovementDialogProps): JSX.Element
# Backend decomposition
@router.websocket("/ws/decompose/{client_id}")
async def websocket_decompose(websocket: WebSocket, client_id: str):
    """Decompose operation using FastDecomposer."""

Import

# Frontend: React component imports
# Backend: included via app.include_router(pipeline.router)

I/O Contract

Inputs

Name Type Required Description
chat messages string Yes User questions/instructions in natural language
operation prompt string Yes Current operation prompt text for improvement
sample output list[dict] No Pipeline output for context

Outputs

Name Type Description
chat responses streaming text AI-generated suggestions and explanations
improved prompts string Rewritten operation prompts
decomposed operations Operation[] Split operations from decomposition

Usage Examples

# Example AI Chat interaction
User: "Why are some entities being missed in the extraction?"
AI: "Looking at the output, I notice the prompt doesn't specify the
entity types clearly. Try updating the prompt to list specific entity
types: persons, organizations, locations, dates..."

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment