
gittech. site
for different kinds of informations and explorations.
CoWriter β Open-Source Tool to Accelerate Writing with Local LLMs
CoWriter
CoWriter is an AI-powered writing assistant that helps you improve your writing through various actions like expanding, shortening, and critiquing text. It provides an intuitive interface for real-time writing enhancement.
Screenshots
The main CoWriter interface with AI-powered writing assistance
Video Demo
Features
- Text Expansion: Elaborate on your ideas with AI-powered suggestions
- Text Shortening: Make your writing more concise and impactful
- Writing Critique: Get constructive feedback on your writing
- Custom Actions: Define your own actions to help you write, e.g. Add Facts, Add Quotes, etc.
- Interactive Chat: Engage in a conversation about your text
- Modern UI: Clean and intuitive interface built with Next.js
- Flexible AI Backend: Support for both OpenAI and Llama models
Project Structure
/backend
- FastAPI backend service- Python-based API with FastAPI
- Support for OpenAI and Llama.cpp models
- Type-safe with mypy
- Formatted with black and isort
- Linted with flake8
/co_writer
- Next.js frontend application- Modern React with TypeScript
- Beautiful UI with Tailwind CSS
- Real-time editing with Tiptap
- ESLint and Prettier for code quality
Prerequisites
- Node.js 18+ for the frontend
- Python 3.9+ for the backend
- Poetry (Python package manager)
- npm or yarn
Quick Start
Clone the repository:
git clone https://github.com/yourusername/co_writer.git cd co_writer
Run the setup script:
./setup.sh
This will:
- Check for required dependencies
- Install all dependencies for both frontend and backend
- Set up development tools (linters, formatters)
- Configure pre-commit hooks
(Optional) Configure environment: If you want to use OpenAI's API or customize the backend settings:
cp backend/.env.example backend/.env
Then edit
backend/.env
to add your OpenAI API key and customize other settings. The application will work with default settings if no environment file is present.Start the services:
./run.sh
This will:
- Start the backend service (FastAPI)
- Wait for backend health check
- Start the frontend service (Next.js)
- Monitor both services
Access the application at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
Development
For development work, you'll want to run the services separately with full development dependencies:
Backend
cd backend
poetry install # Includes development dependencies
poetry shell
uvicorn app.main:app --reload --port 8000
Frontend
cd co_writer
npm install # Includes development dependencies
npm run dev
Code Quality Tools
Backend:
cd backend
poetry run black . # Format code
poetry run isort . # Sort imports
poetry run flake8 # Lint code
poetry run mypy app/ # Type check
Frontend:
cd co_writer
npm run lint # Run ESLint
npm run format # Run Prettier
npm run type-check # Run TypeScript checks
API Documentation
When the backend is running, you can access:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.