We're excited about your interest in contributing to Lexio!
- Node.js (v20 or higher)
- Python 3.9+
- npm
- Git
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/lexio.git cd lexio
- Install dependencies:
# install the React UI dependencies cd lexio npm install
The python package is located in the lexio directory. The Python package is auto-generated from the frontend library. It contains API types for the lexio frontend library as pydantic models.
The core types are defined in python/lexio/lexio/types/__init__.py
and are generated from the frontend library's TypeScript definitions. These models include:
Source
: Represents a source of information that can be displayed and referencedMessage
: Represents a chat message in the conversationStreamChunk
: Represents a chunk of streamed content- Other utility types like
Rect
,PDFHighlight
, etc.
- Update the frontend library with the latest changes.
- If you want to add new types to the Python package, update the types-to-include.json file.
- Run
npm run build-python-package
to:- Generate the Python package with Pydantic models from the TypeScript types
- Run tests to ensure the package is working as expected
- Build the package in the
python/lexio
folder
- Commit the changes to the Python package.
Note: We use the version from the frontend library's
package.json
file as the version for the Python package.
The Pydantic models can be imported directly in your backend code:
from lexio.types import Source, Message, StreamChunk
These models provide type safety and validation for data exchanged between your backend and the Lexio frontend.
# cd to the python/lexio directory from the root of the project
cd python/lexio
# activate the virtual environment
source .venv/bin/activate
# build the package
hatch build
# check the package
twine check dist/*
# upload the package
twine upload dist/*
Since we are creating the lexio
Python package automatically, we run several tests with 'pytest' to ensure the package is working as expected. The tests are located in the python/lexio/tests folder.
If you add new types which are exported to the Python package, you should also add tests for them to ensure they work correctly.
- Follow the existing ESLint configuration
- Use TypeScript strict mode
- Use TSDoc notation for documenting code
- Use functional components and hooks
- Follow React best practices
- Include docstrings/TSDoc comments for new functions and components
- Update type definitions where necessary
- Add examples to the documentation where necessary
- Add stories to the Storybook for new components under components
- Open an issue for bugs or feature requests
- Check the existing documentation and issues before opening new ones
By contributing, you agree that your contributions will be licensed under the project's license.
- Use TypeScript for all new code
- Provide comprehensive type definitions
- Document public APIs with JSDoc comments
- Components should be well-documented with JSDoc comments
- Follow the existing pattern of separating component logic from presentation
- Use the ThemeContext for styling to maintain consistency
- Ensure components are accessible
- Write tests for new functionality
- Update tests when modifying existing functionality
- Aim for good test coverage
When adding new components, please include Storybook stories that demonstrate:
- Basic usage
- Different configurations/props
- Edge cases
- Use clear, descriptive commit messages
- Reference issue numbers in commit messages when applicable
All submissions require review. We use GitHub pull requests for this purpose.
Thank you for contributing to Lexio!