Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docs #19

Merged
merged 35 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
74fbd35
add docs and update docstrings
Blaizzy Jul 16, 2024
c6bcbf6
add auto update changelong
Blaizzy Jul 16, 2024
0a0831d
remove semver
Blaizzy Jul 16, 2024
09c6fb4
add condition to release
Blaizzy Jul 16, 2024
4d44fba
remove changelog
Blaizzy Jul 16, 2024
82b89eb
change token
Blaizzy Jul 16, 2024
af39cdf
test commit changes
Blaizzy Jul 16, 2024
71c03b3
test push
Blaizzy Jul 16, 2024
3b58919
add checkout
Blaizzy Jul 16, 2024
acb6f51
formatting
Blaizzy Jul 16, 2024
94abf48
formatting
Blaizzy Jul 16, 2024
f7a1acc
formatting
Blaizzy Jul 16, 2024
f1c44a4
formatting
Blaizzy Jul 16, 2024
b88e572
add fetch
Blaizzy Jul 16, 2024
1085c36
fix fetch
Blaizzy Jul 16, 2024
be269de
Update changelog for latest release
actions-user Jul 16, 2024
6bfa1f2
remove test
Blaizzy Jul 16, 2024
a4f75b2
Merge branch 'pc/docs' of https://github.com/Blaizzy/fastmlx into pc/…
Blaizzy Jul 16, 2024
376d41a
deploy docs
Blaizzy Jul 16, 2024
403af15
fix requirements
Blaizzy Jul 16, 2024
d74f443
add git revision
Blaizzy Jul 16, 2024
28f785e
add mkdocs jupyter
Blaizzy Jul 16, 2024
c75a53b
add cli reference
Blaizzy Jul 16, 2024
bba0576
remove docstring
Blaizzy Jul 16, 2024
8b9443f
add repo name and remove edit_uri
Blaizzy Jul 16, 2024
4f25670
remove docstring and reformat
Blaizzy Jul 28, 2024
1f96d09
New Docs
Charmaineem Sep 9, 2024
83b1ed6
New Dovs
Charmaineem Sep 9, 2024
fb1148e
Fastmlx docs v01
Oct 27, 2024
5014cf4
Delete venv directory
Charmaineem Oct 27, 2024
101ad7f
Merge branch 'main' into pc/docs
Blaizzy Oct 27, 2024
dc96dea
v01
Oct 27, 2024
6f7e913
black
Charmaineem Oct 28, 2024
884fbc1
patch tests
Blaizzy Oct 28, 2024
7307a5f
tests fix 2
Blaizzy Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy Documentation

on:
push:
branches:
- main # or your default branch name
pull_request:
branches:
- main # or your default branch name

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install mkdocs mkdocs-material mkdocstrings[python] mkdocs-autorefs mkdocs-git-revision-date-localized-plugin mkdocs-jupyter

- name: Build documentation
run: mkdocs build

- name: Deploy to GitHub Pages
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
67 changes: 36 additions & 31 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
name: Test PRs

on:
pull_request:
branches:
- main
pull_request:
branches:
- main

jobs:
test:
runs-on: macos-14

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
run: |
brew install python@3.10
python3 -m venv env
source env/bin/activate


- name: Run style checks
run: |
pip install pre-commit
pre-commit run --all
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

- name: Install dependencies
run: |
pip install pytest
pip install -e .

- name: Run Python tests
run: |
pytest -s .
test:
runs-on: macos-14

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'

- name: Install MLX
run: |
pip install mlx>=0.15

- name: Install pre-commit
run: |
python -m pip install pre-commit
pre-commit run --all
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

- name: Install package and dependencies
run: |
python -m pip install pytest
python -m pip install -e .

- name: Run tests
run: |
pytest -s .
67 changes: 67 additions & 0 deletions .github/workflows/update_changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Update Changelog

on:
release:
types: [published]

jobs:
update-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests python-dotenv
- name: Update Changelog
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python update_changelog.py
- name: Commit changes
run: |
set -x # Enable verbose output

echo "Configuring Git..."
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"

echo "GitHub event name: ${{ github.event_name }}"
echo "GitHub head ref: ${{ github.head_ref }}"
echo "GitHub ref name: ${{ github.ref_name }}"

echo "Fetching latest changes..."
git fetch origin

echo "Checking out and updating branch..."
if [ "${{ github.event_name }}" = "pull_request" ]; then
git checkout -B "${{ github.head_ref }}" "origin/${{ github.head_ref }}"
git pull origin "${{ github.head_ref }}"
else
git checkout -B "${{ github.ref_name }}" "origin/${{ github.ref_name }}"
git pull origin "${{ github.ref_name }}"
fi

echo "Current branch after checkout:"
git branch

echo "Running update script..."
python update_changelog.py

echo "Checking for changes..."
git add docs/changelog.md
git pull
if git diff --staged --quiet; then
echo "No changes to commit"
else
echo "Changes detected, committing..."
git commit -m "Update changelog for latest release"
echo "Pushing changes..."
git push origin HEAD:"${{ github.head_ref || github.ref_name }}" || echo "Failed to push changes"
fi

echo "Final Git status:"
git status
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
__pycache__
*.egg-info
*.egg-info
venv/*
29 changes: 24 additions & 5 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
# Changelog

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

**Improvement**:

- TBD
**What's Changed**

- Add support for token streaming and custom CORS by [@Blaizzy](https://github.com/Blaizzy)
- Add support for Parallel calls by [@Blaizzy](https://github.com/Blaizzy)
- Add Parallel calls usage by [@Blaizzy](https://github.com/Blaizzy)

**Fixes :**

- Cross origin Support [#2](https://github.com/Blaizzy/fastmlx/issues/2)
- Max tokens not overriding [#5](https://github.com/Blaizzy/fastmlx/issues/5)

## [v0.0.1] - 09 July 2024


**What's Changed**

- Setup FastMLX by [@Blaizzy](https://github.com/Blaizzy)
- Add support for VLMs by [@Blaizzy](https://github.com/Blaizzy)
- Add support for LMs by by [@Blaizzy](https://github.com/Blaizzy)

**New Contributors**

- [@Blaizzy](https://github.com/Blaizzy) made their first contribution in [https://github.com/Blaizzy/fastmlx/pull/1](https://github.com/Blaizzy/fastmlx/pull/1)

**New Features**:

- TBD
84 changes: 84 additions & 0 deletions docs/cli_reference.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# CLI Reference

The **FastMLX** API server can be configured using various command-line arguments. Here is a detailed reference for each available option.

## Usage

```
fastmlx [OPTIONS]
```

## Options

### `--allowed-origins`

- **Type**: List of strings
- **Default**: `["*"]`
- **Description**: List of allowed origins for CORS (Cross-Origin Resource Sharing).

### `--host`

- **Type**: String
- **Default**: `"0.0.0.0"`
- **Description**: Host to run the server on.

### `--port`

- **Type**: Integer
- **Default**: `8000`
- **Description**: Port to run the server on.

### `--reload`

- **Type**: Boolean
- **Default**: `False`
- **Description**: Enable auto-reload of the server. Only works when 'workers' is set to None.

### `--workers`

- **Type**: Integer or Float
- **Default**: Calculated based on `FASTMLX_NUM_WORKERS` environment variable or 2 if not set.
- **Description**: Number of workers. This option overrides the `FASTMLX_NUM_WORKERS` environment variable.

- If an integer, it specifies the exact number of workers to use.
- If a float, it represents the fraction of available CPU cores to use (minimum 1 worker).
- To use all available CPU cores, set it to 1.0.

**Examples**:
- `--workers 1`: Use 1 worker
- `--workers 1.0`: Use all available CPU cores
- `--workers 0.5`: Use half of the available CPU cores
- `--workers 0.0`: Use 1 worker

## Environment Variables

- `FASTMLX_NUM_WORKERS`: Sets the default number of workers if not specified via the `--workers` argument.

## Examples

1. Run the server on localhost with default settings:
```
fastmlx
```

2. Run the server on a specific host and port:
```
fastmlx --host 127.0.0.1 --port 5000
```

3. Run the server with 4 workers:
```
fastmlx --workers 4
```

4. Run the server using half of the available CPU cores:
```
fastmlx --workers 0.5
```

5. Enable auto-reload (for development):
```
fastmlx --reload
```

Remember that the `--reload` option is intended for development purposes and should not be used in production environments.
3 changes: 0 additions & 3 deletions docs/common.md

This file was deleted.

21 changes: 21 additions & 0 deletions docs/community_projects.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Here are some projects built by the community that use FastMLX:

1. FastMLX-MineCraft by Mathieu
2. MLX Chat by Nils Durner
3. AI Home Hub by Prince Canuma


### PROJECTS IN DETAIL
#### [FastMLX-MineCraft](https://x.com/mwrites__/status/1837465176582353080) by [Mathieu](https://x.com/mwrites__)

<img src="https://pbs.twimg.com/media/GYMsGnaXUAA_Ga5?format=jpg&name=medium" alt="Remote image" width="400">

####[MLX Chat](https://github.com/ndurner/mlx_chat) by [Nils Durner](https://github.com/ndurner)
Chat interface for MLX for on-device Language Model use on Apple Silicon. Built on FastMLX.

![MLX Chat](./mlxchat.png)

####[Home Hub](https://x.com/Prince_Canuma/status/1813689110089101623) by [Prince Canuma](https://x.com/Prince_Canuma)
Turning your Mac into an AI home server.

![AI Home Hub](./homehub.png)
Loading
Loading