Skip to content

Commit c0ce5fd

Browse files
Blaizzyactions-userCharmaineemCharmaine Mahachi
authored
Add Docs (#19)
* add docs and update docstrings * add auto update changelong * remove semver * add condition to release * remove changelog * change token * test commit changes * test push * add checkout * formatting * formatting * formatting * formatting * add fetch * fix fetch * Update changelog for latest release * remove test * deploy docs * fix requirements * add git revision * add mkdocs jupyter * add cli reference * remove docstring * add repo name and remove edit_uri * remove docstring and reformat * New Docs * Fastmlx docs v01 * Delete venv directory * v01 * black * patch tests * tests fix 2 --------- Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Charmaine <[email protected]> Co-authored-by: Charmaine Mahachi <[email protected]> Co-authored-by: Charmaine Mahachi <[email protected]>
1 parent 0bbcf55 commit c0ce5fd

24 files changed

+1094
-136
lines changed

.github/workflows/deploy-docs.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
push:
5+
branches:
6+
- main # or your default branch name
7+
pull_request:
8+
branches:
9+
- main # or your default branch name
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v2
19+
with:
20+
python-version: '3.x'
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install mkdocs mkdocs-material mkdocstrings[python] mkdocs-autorefs mkdocs-git-revision-date-localized-plugin mkdocs-jupyter
26+
27+
- name: Build documentation
28+
run: mkdocs build
29+
30+
- name: Deploy to GitHub Pages
31+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
32+
uses: peaceiris/actions-gh-pages@v3
33+
with:
34+
github_token: ${{ secrets.GITHUB_TOKEN }}
35+
publish_dir: ./site

.github/workflows/tests.yml

+36-31
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,41 @@
11
name: Test PRs
22

33
on:
4-
pull_request:
5-
branches:
6-
- main
4+
pull_request:
5+
branches:
6+
- main
77

88
jobs:
9-
test:
10-
runs-on: macos-14
11-
12-
steps:
13-
- name: Checkout code
14-
uses: actions/checkout@v2
15-
16-
- name: Set up Python
17-
run: |
18-
brew install [email protected]
19-
python3 -m venv env
20-
source env/bin/activate
21-
22-
23-
- name: Run style checks
24-
run: |
25-
pip install pre-commit
26-
pre-commit run --all
27-
if ! git diff --quiet; then echo 'Style checks failed, please install pre-commit and run pre-commit run --all and push the change'; exit 1; fi
28-
29-
- name: Install dependencies
30-
run: |
31-
pip install pytest
32-
pip install -e .
33-
34-
- name: Run Python tests
35-
run: |
36-
pytest -s .
9+
test:
10+
runs-on: macos-14
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: '3.10'
20+
21+
- name: Install MLX
22+
run: |
23+
pip install mlx>=0.15
24+
25+
- name: Install pre-commit
26+
run: |
27+
python -m pip install pre-commit
28+
pre-commit run --all
29+
if ! git diff --quiet; then
30+
echo 'Style checks failed, please install pre-commit and run pre-commit run --all and push the change'
31+
exit 1
32+
fi
33+
34+
- name: Install package and dependencies
35+
run: |
36+
python -m pip install pytest
37+
python -m pip install -e .
38+
39+
- name: Run tests
40+
run: |
41+
pytest -s .
+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Update Changelog
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
update-changelog:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Set up Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: '3.x'
16+
- name: Install dependencies
17+
run: |
18+
python -m pip install --upgrade pip
19+
pip install requests python-dotenv
20+
- name: Update Changelog
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
run: python update_changelog.py
24+
- name: Commit changes
25+
run: |
26+
set -x # Enable verbose output
27+
28+
echo "Configuring Git..."
29+
git config --local user.email "[email protected]"
30+
git config --local user.name "GitHub Action"
31+
32+
echo "GitHub event name: ${{ github.event_name }}"
33+
echo "GitHub head ref: ${{ github.head_ref }}"
34+
echo "GitHub ref name: ${{ github.ref_name }}"
35+
36+
echo "Fetching latest changes..."
37+
git fetch origin
38+
39+
echo "Checking out and updating branch..."
40+
if [ "${{ github.event_name }}" = "pull_request" ]; then
41+
git checkout -B "${{ github.head_ref }}" "origin/${{ github.head_ref }}"
42+
git pull origin "${{ github.head_ref }}"
43+
else
44+
git checkout -B "${{ github.ref_name }}" "origin/${{ github.ref_name }}"
45+
git pull origin "${{ github.ref_name }}"
46+
fi
47+
48+
echo "Current branch after checkout:"
49+
git branch
50+
51+
echo "Running update script..."
52+
python update_changelog.py
53+
54+
echo "Checking for changes..."
55+
git add docs/changelog.md
56+
git pull
57+
if git diff --staged --quiet; then
58+
echo "No changes to commit"
59+
else
60+
echo "Changes detected, committing..."
61+
git commit -m "Update changelog for latest release"
62+
echo "Pushing changes..."
63+
git push origin HEAD:"${{ github.head_ref || github.ref_name }}" || echo "Failed to push changes"
64+
fi
65+
66+
echo "Final Git status:"
67+
git status

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.DS_Store
22
__pycache__
3-
*.egg-info
3+
*.egg-info
4+
venv/*

docs/changelog.md

+24-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
11
# Changelog
22

3-
## v0.0.1 - Date
3+
## [v0.1.0] - 11 July 2024
44

5-
**Improvement**:
65

7-
- TBD
6+
**What's Changed**
7+
8+
- Add support for token streaming and custom CORS by [@Blaizzy](https://github.com/Blaizzy)
9+
- Add support for Parallel calls by [@Blaizzy](https://github.com/Blaizzy)
10+
- Add Parallel calls usage by [@Blaizzy](https://github.com/Blaizzy)
11+
12+
**Fixes :**
13+
14+
- Cross origin Support [#2](https://github.com/Blaizzy/fastmlx/issues/2)
15+
- Max tokens not overriding [#5](https://github.com/Blaizzy/fastmlx/issues/5)
16+
17+
## [v0.0.1] - 09 July 2024
18+
19+
20+
**What's Changed**
21+
22+
- Setup FastMLX by [@Blaizzy](https://github.com/Blaizzy)
23+
- Add support for VLMs by [@Blaizzy](https://github.com/Blaizzy)
24+
- Add support for LMs by by [@Blaizzy](https://github.com/Blaizzy)
25+
26+
**New Contributors**
27+
28+
- [@Blaizzy](https://github.com/Blaizzy) made their first contribution in [https://github.com/Blaizzy/fastmlx/pull/1](https://github.com/Blaizzy/fastmlx/pull/1)
829

9-
**New Features**:
1030

11-
- TBD

docs/cli_reference.md

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# CLI Reference
2+
3+
The **FastMLX** API server can be configured using various command-line arguments. Here is a detailed reference for each available option.
4+
5+
## Usage
6+
7+
```
8+
fastmlx [OPTIONS]
9+
```
10+
11+
## Options
12+
13+
### `--allowed-origins`
14+
15+
- **Type**: List of strings
16+
- **Default**: `["*"]`
17+
- **Description**: List of allowed origins for CORS (Cross-Origin Resource Sharing).
18+
19+
### `--host`
20+
21+
- **Type**: String
22+
- **Default**: `"0.0.0.0"`
23+
- **Description**: Host to run the server on.
24+
25+
### `--port`
26+
27+
- **Type**: Integer
28+
- **Default**: `8000`
29+
- **Description**: Port to run the server on.
30+
31+
### `--reload`
32+
33+
- **Type**: Boolean
34+
- **Default**: `False`
35+
- **Description**: Enable auto-reload of the server. Only works when 'workers' is set to None.
36+
37+
### `--workers`
38+
39+
- **Type**: Integer or Float
40+
- **Default**: Calculated based on `FASTMLX_NUM_WORKERS` environment variable or 2 if not set.
41+
- **Description**: Number of workers. This option overrides the `FASTMLX_NUM_WORKERS` environment variable.
42+
43+
- If an integer, it specifies the exact number of workers to use.
44+
- If a float, it represents the fraction of available CPU cores to use (minimum 1 worker).
45+
- To use all available CPU cores, set it to 1.0.
46+
47+
**Examples**:
48+
- `--workers 1`: Use 1 worker
49+
- `--workers 1.0`: Use all available CPU cores
50+
- `--workers 0.5`: Use half of the available CPU cores
51+
- `--workers 0.0`: Use 1 worker
52+
53+
## Environment Variables
54+
55+
- `FASTMLX_NUM_WORKERS`: Sets the default number of workers if not specified via the `--workers` argument.
56+
57+
## Examples
58+
59+
1. Run the server on localhost with default settings:
60+
```
61+
fastmlx
62+
```
63+
64+
2. Run the server on a specific host and port:
65+
```
66+
fastmlx --host 127.0.0.1 --port 5000
67+
```
68+
69+
3. Run the server with 4 workers:
70+
```
71+
fastmlx --workers 4
72+
```
73+
74+
4. Run the server using half of the available CPU cores:
75+
```
76+
fastmlx --workers 0.5
77+
```
78+
79+
5. Enable auto-reload (for development):
80+
```
81+
fastmlx --reload
82+
```
83+
84+
Remember that the `--reload` option is intended for development purposes and should not be used in production environments.

docs/common.md

-3
This file was deleted.

docs/community_projects.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Here are some projects built by the community that use FastMLX:
2+
3+
1. FastMLX-MineCraft by Mathieu
4+
2. MLX Chat by Nils Durner
5+
3. AI Home Hub by Prince Canuma
6+
7+
8+
### PROJECTS IN DETAIL
9+
#### [FastMLX-MineCraft](https://x.com/mwrites__/status/1837465176582353080) by [Mathieu](https://x.com/mwrites__)
10+
11+
<img src="https://pbs.twimg.com/media/GYMsGnaXUAA_Ga5?format=jpg&name=medium" alt="Remote image" width="400">
12+
13+
####[MLX Chat](https://github.com/ndurner/mlx_chat) by [Nils Durner](https://github.com/ndurner)
14+
Chat interface for MLX for on-device Language Model use on Apple Silicon. Built on FastMLX.
15+
16+
![MLX Chat](./mlxchat.png)
17+
18+
####[Home Hub](https://x.com/Prince_Canuma/status/1813689110089101623) by [Prince Canuma](https://x.com/Prince_Canuma)
19+
Turning your Mac into an AI home server.
20+
21+
![AI Home Hub](./homehub.png)

0 commit comments

Comments
 (0)