chatterbox-ui/OpenCode.md

1.4 KiB

OpenCode.md

Build/Test Commands

# Backend setup and run (from project root)
pip install -r backend/requirements.txt
uvicorn backend.app.main:app --reload --host 0.0.0.0 --port 8000

# Frontend tests
npm test                    # Run all Jest tests
npm test -- --testNamePattern="getSpeakers"  # Run single test

# Backend API test
python backend/run_api_test.py

# Alternative interface
python gradio_app.py

Code Style Guidelines

Python (Backend)

  • Imports: Standard library first, third-party, then local imports with blank lines between groups
  • Types: Use type hints extensively (List[Speaker], Optional[str], Dict[str, Any])
  • Classes: PascalCase (SpeakerManagementService, DialogRequest)
  • Functions/Variables: snake_case (get_speakers, speaker_id, audio_url)
  • Error Handling: Use FastAPI HTTPException with descriptive messages
  • Models: Pydantic models with Field descriptions and validators

JavaScript (Frontend)

  • Modules: ES6 modules with explicit imports/exports
  • Functions: camelCase with JSDoc comments (getSpeakers, addSpeaker)
  • Constants: UPPER_SNAKE_CASE (API_BASE_URL)
  • Error Handling: Comprehensive try/catch with detailed error messages
  • Async: Use async/await consistently, handle response.ok checks
  • Testing: Jest with descriptive test names and comprehensive mocking