-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ff39cd6
Showing
180 changed files
with
23,858 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
OPENAI_API_KEY=YOUR_OPENAI_API_KEY |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Contribute to Chainlit | ||
To contribute to Chainlit, you first need to setup the project on your local machine. | ||
|
||
## Local setup | ||
|
||
### Requirements | ||
|
||
1. Python >= `3.8` | ||
2. Poetry ([See how to install](https://python-poetry.org/docs/#installation)) | ||
3. NodeJS >= `16` ([See how to install](https://nodejs.org/en/download)) | ||
|
||
|
||
### Clone the repo | ||
|
||
```sh | ||
git clone https://github.com/Chainlit/chainlit.git | ||
cd chainlit | ||
``` | ||
|
||
### Install JS dependencies | ||
|
||
```sh | ||
npm install | ||
npm run installUiDeps | ||
``` | ||
|
||
### Install python env | ||
|
||
```sh | ||
cd src | ||
poetry install | ||
``` | ||
|
||
## Contribute to the UI | ||
|
||
The source code of the UI is in [src/chainlit/frontend](src/chainlit/frontend). | ||
|
||
Before anything, go to [src/chainlit/frontend/api/index.ts](src/chainlit/frontend/api/index.ts). Find the definition of `const server` and inverse the comment: | ||
|
||
```ts | ||
// export const server = 'http://127.0.0.1:8000'; | ||
export const server = ''; | ||
``` | ||
|
||
Don't forget to revert that change before pushing. | ||
|
||
### Start the UI | ||
|
||
```sh | ||
cd src/chainlit/frontend | ||
npm run dev -- --port 5174 | ||
``` | ||
|
||
If you visit `http://127.0.0.1:5174/`, it should say that it can't connect to the server. | ||
|
||
### Start the server | ||
- If you only wish to contribute to the UI, you can use any Chainlit installation | ||
- If your contribution impacts both the UI and the Python package, you need to start the server from your [local installation](#contribute-to-the-python-package) | ||
|
||
Starting the chainlit server in headless mode (since we manually started the UI) | ||
```sh | ||
chainlit run target.py -h | ||
``` | ||
|
||
## Contribute to the Python package | ||
|
||
- If you only wish to contribute to the Python package, run: | ||
```sh | ||
npm run buildUi | ||
``` | ||
|
||
- If your contribution impacts both the Python package and the UI, check the section above | ||
|
||
### Install from local sources | ||
|
||
```sh | ||
pip install PATH_TO_CHAINLIT_REPO/src | ||
``` | ||
|
||
You need to repeat that step everytime you make a change in the Python codebase | ||
|
||
### Start the server | ||
|
||
```sh | ||
chainlit run target.py [-h] | ||
``` | ||
|
||
The `-h` parameter (headless) means the UI will not automatically open. Only use this if you are already running the UI yourself. | ||
|
||
## Run the tests | ||
|
||
1. Create an `.env` file at the root of the repo following the model of `.env.example` | ||
2. Run `npm test` | ||
|
||
Once you create a pull request, the tests will automatically run. It is a good practice to run the tests locally before pushing. | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
branches: [main, dev] | ||
push: | ||
branches: [main, dev] | ||
|
||
jobs: | ||
tests: | ||
uses: ./.github/workflows/tests.yaml | ||
secrets: inherit | ||
ci: | ||
runs-on: ubuntu-latest | ||
name: Run CI | ||
needs: [tests] | ||
steps: | ||
- name: "Done" | ||
run: echo "Done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: Publish | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
tests: | ||
uses: ./.github/workflows/tests.yaml | ||
secrets: inherit | ||
build-n-publish: | ||
name: Upload release to PyPI | ||
runs-on: ubuntu-latest | ||
needs: [tests] | ||
env: | ||
name: pypi | ||
url: https://pypi.org/p/chainlit | ||
permissions: | ||
contents: read | ||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: main | ||
- name: Use Node.js 16.15.0 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16.15.0" | ||
cache: "npm" | ||
- name: Install UI JS dependencies | ||
run: npm run installUiDeps | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.8" | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
- name: Copy readme to src | ||
run: cp README.md src/ | ||
- name: Build chainlit | ||
run: npm run build | ||
- name: Publish package distributions to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
packages-dir: src/dist | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Tests | ||
|
||
on: [workflow_call] | ||
|
||
jobs: | ||
ci: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, windows-latest] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: shine1594/secrets-to-env-action@master | ||
with: | ||
secrets: ${{ toJSON(secrets) }} | ||
secrets_env: production | ||
file_name_prod: .env | ||
prefix_prod: "" | ||
- name: Use Node.js 16.15.0 | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "16.15.0" | ||
cache: "npm" | ||
- name: Install test JS dependencies | ||
run: npm install | ||
- name: Install UI JS dependencies | ||
run: npm run installUiDeps | ||
- name: Lint UI | ||
run: npm run lintUi | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.8" | ||
cache: "pip" | ||
- name: Install Python CI dependencies | ||
run: pip install -r src/ci-requirements.txt | ||
- name: Run tests | ||
run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
build | ||
dist | ||
|
||
*.egg-info | ||
|
||
.env | ||
|
||
poetry.lock | ||
|
||
venv | ||
|
||
.DS_Store | ||
|
||
chainlit.md | ||
|
||
cypress/screenshots | ||
cypress/videos | ||
cypress/downloads | ||
|
||
__pycache__ | ||
|
||
.ipynb_checkpoints | ||
|
||
.langchain.db | ||
database.db | ||
|
||
.chroma | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env sh | ||
. "$(dirname -- "$0")/_/husky.sh" | ||
|
||
npm run lintUi | ||
npm run formatUi | ||
npm run formatPython |
Oops, something went wrong.