-
Notifications
You must be signed in to change notification settings - Fork 3.2k
feat(copilot): add training interface #1445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Summary
This PR implements a comprehensive copilot training interface that allows users to capture workflow editing sessions and send them to an external indexer for training purposes. The implementation adds a modal-based UI for starting/stopping training sessions, viewing collected datasets, and exporting training data.
Key Changes:
- Training API Route: New
/api/copilot/trainingendpoint that forwards training data to an external agent indexer with proper validation and error handling - Training UI Components: Complete modal interface with tabbed views for starting sessions, monitoring progress, and managing datasets
- State Management: Zustand store managing training sessions, workflow snapshots, and dataset collection with comprehensive edit sequence computation
- Database Schema: Addition of
showTrainingControlssetting to control feature visibility - Environment Configuration: New environment variables for agent indexer integration
Technical Implementation:
The system captures workflow state snapshots before and after editing sessions, computes detailed edit sequences (add/edit/delete operations), converts states to YAML format, and forwards everything to an external training indexer. The UI provides full dataset management including bulk operations, individual sending, and export functionality.
Issues Found:
- Use of
z.any()in API validation schema reduces type safety - Large functions in training modal should be extracted for better maintainability
- Minor type assertion issues in metadata processing
Confidence Score: 4/5
- This PR is safe to merge with minor code quality improvements recommended
- Score reflects solid implementation with comprehensive functionality, proper error handling, and good state management, but some code quality issues around type safety and function complexity should be addressed
- Pay attention to the training API route and modal component for the mentioned type safety and refactoring improvements
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/api/copilot/training/route.ts | 3/5 | New API route for training data submission with proper validation and error handling, but uses loose typing with z.any() |
| apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/training-controls/training-modal.tsx | 3/5 | Complex training interface modal with comprehensive functionality but contains large functions that should be refactored |
| apps/sim/stores/copilot-training/store.ts | 4/5 | Well-structured Zustand store for training state management with clear separation of concerns |
Sequence Diagram
sequenceDiagram
participant User
participant TrainingModal as Training Modal
participant TrainingStore as Training Store
participant WorkflowStore as Workflow Store
participant TrainingAPI as Training API
participant IndexerAPI as Agent Indexer API
participant YAMLConverter as YAML Converter
User->>TrainingModal: Click "Start Training Session"
TrainingModal->>TrainingStore: startTraining(title, prompt)
TrainingStore->>WorkflowStore: captureWorkflowSnapshot()
WorkflowStore-->>TrainingStore: WorkflowState
TrainingStore-->>TrainingModal: Session started
Note over User, TrainingModal: User edits workflow...
User->>TrainingModal: Click "Save Dataset"
TrainingModal->>TrainingStore: stopTraining()
TrainingStore->>WorkflowStore: captureWorkflowSnapshot()
WorkflowStore-->>TrainingStore: EndWorkflowState
TrainingStore->>TrainingStore: computeEditSequence(start, end)
TrainingStore-->>TrainingModal: Dataset created
User->>TrainingModal: Click "Send" on dataset
TrainingModal->>YAMLConverter: Convert start/end states to YAML
YAMLConverter-->>TrainingModal: YAML representations
TrainingModal->>TrainingAPI: POST /api/copilot/training
TrainingAPI->>TrainingAPI: Validate request body
TrainingAPI->>IndexerAPI: POST /operations/add
IndexerAPI-->>TrainingAPI: Success/Error response
TrainingAPI-->>TrainingModal: Response
TrainingModal-->>User: Success/Error notification
18 files reviewed, 3 comments
Summary
Training interface that will be enabled on Staging environment.
Type of Change
Testing
Tested with indexer repo @Sg312
Checklist