Skip to content

Commit

Permalink
Merge pull request qnguyen3#4 from qnguyen3/onuralpszr-feature/pyproj…
Browse files Browse the repository at this point in the history
…ect/pypi

Onuralpszr feature/pyproject/pypi
  • Loading branch information
qnguyen3 authored Feb 28, 2024
2 parents aa7329b + 5e3a880 commit a3f1c7b
Show file tree
Hide file tree
Showing 13 changed files with 154 additions and 40 deletions.
16 changes: 16 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2
updates:
# GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: ⬆️
# Python
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "daily"
commit-message:
prefix: ⬆️
45 changes: 45 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Releases to PyPi
on:
push:
branches:
- main
tags:
- '[0-9]+.[0-9]+[0-9]+.[0-9]'
- '[0-9]+.[0-9]+[0-9]+.[0-9]'
- '[0-9]+.[0-9]+[0-9]+.[0-9]'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
build:
runs-on: macos-latest
strategy:
matrix:
python-version: [3.8]
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: 🏗️ Build source and wheel distributions
run: |
python -m pip install --upgrade build twine wheel setuptools
python -m build
twine check --strict dist/*
- name: 🚀 Publish to PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: ${{ secrets.PYPI_USERNAME }}
password: ${{ secrets.PYPI_PASSWORD }}
- name: 🚀 Publish to Test-PyPi
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
user: ${{ secrets.PYPI_TEST_USERNAME }}
password: ${{ secrets.PYPI_TEST_PASSWORD }}
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include chat_with_mlx *.yaml
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,29 @@ This repository showcases a Retrieval-augmented Generation (RAG) chat interface
- **Multilingual**: English🏴󠁧󠁢󠁥󠁮󠁧󠁿, Spanish🇪🇸, Chinese 🇨🇳, Vietnamese🇻🇳, and Turkish🇹🇷.
- **Easy Integration**: Easy integrate any HuggingFace and MLX Compatible Open-Source Model.

## How to Use
## Installation and Usage

- Install Conda and follow the following commands:
### Pip Installation

```bash
git clone https://github.com/qnguyen3/chat-with-mlx.git
cd chat-with-mlx
pip install -e .
```

### Conda Installation

```bash
git clone https://github.com/qnguyen3/chat-with-mlx.git
cd chat-with-mlx
conda create -n mlx-chat python=3.11
conda activate mlx-chat
pip install -r requirements.txt
pip install -e .
```

- Start the app: `python app.py`
### Usage

- Start the app: `chat-with-mlx`

## Supported Models

Expand Down
7 changes: 7 additions & 0 deletions chat_with_mlx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import importlib.metadata as importlib_metadata

try:
# This will read version from pyproject.toml
__version__ = importlib_metadata.version(__package__ or __name__)
except importlib_metadata.PackageNotFoundError:
__version__ = "development"
8 changes: 7 additions & 1 deletion app.py → chat_with_mlx/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,10 @@ def chatbot(query, history, temp, max_tokens, freq_penalty, k_docs):
stop_index_button = gr.Button('Stop Indexing')
stop_index_button.click(kill_index, outputs=[index_status])

demo.launch(inbrowser=True)

def main():
demo.launch(inbrowser=True)


if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion chat_with_mlx/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def model_info():
yml_list = {}
final_cfg_list = {}
mlx_config_list = {}
yaml_files = get_yaml_files('chat_with_mlx/models/configs/')
directory_path = os.path.dirname(os.path.abspath(__file__))
yaml_files = get_yaml_files(f'{directory_path}/configs')
for file in yaml_files:
model_dict, yml_path, final_cfg, mlx_config = process_yaml(file)
model_list.update(model_dict)
Expand Down
Empty file added chat_with_mlx/rag/__init__.py
Empty file.
5 changes: 3 additions & 2 deletions chat_with_mlx/rag/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from ..models.utils import load_yaml_config
from .rag_prompt import *
from chat_with_mlx.models.utils import load_yaml_config
from chat_with_mlx.rag.rag_prompt import rag_prompt_default_en, rag_prompt_default_vi, rag_prompt_default_es, rag_prompt_default_zh, rag_prompt_default_tr, rag_prompt_history_default_en, rag_prompt_history_default_vi, rag_prompt_history_default_es, rag_prompt_history_default_zh, rag_prompt_history_default_tr


prompt_dict = {'en': [rag_prompt_default_en, rag_prompt_history_default_en],
'vi': [rag_prompt_default_vi, rag_prompt_history_default_vi],
Expand Down
5 changes: 0 additions & 5 deletions convert.py

This file was deleted.

59 changes: 59 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "chat_with_mlx"
version = "0.1.1"
description = "A Retrieval-augmented Generation (RAG) chat interface with support for multiple open-source models, designed to run natively on MacOS and Apple Silicon with MLX."
readme = "README.md"
keywords = ["mlx","chat","chatbot","chat_with_mlx","chat_with_mlx"]
authors = [
{ name = "Quan Nguyen", email = "[email protected]" },
]

license = {text = "MIT License"}

classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
requires-python = ">= 3.8"

dependencies = [
"mlx-lm==0.0.12",
"gradio==4.19.1",
"tiktoken==0.6.0",
"openai==1.12.0",
"langchain==0.1.9",
"langchain-community==0.0.24",
"langchain-core==0.1.26",
"sentence-transformers==2.4.0",
"einops==0.7.0",
"chromadb==0.4.23",
"pypdf==4.0.2",
"youtube-transcript-api==0.6.2",
"sentencepiece==0.2.0",
"docx2txt==0.8"
]

[tool.setuptools]
package-dir = {"chat_with_mlx" = "chat_with_mlx"}
include-package-data = true
license-files = ["LICENSE"]
zip-safe = true

[tool.setuptools.packages.find]
include = ["chat_with_mlx*"]
exclude = ["docs*", "tests*","third_party*","assets*", "chat_with_mlx/models/*"]

[project.scripts]
chat-with-mlx = "chat_with_mlx.app:main"
14 changes: 0 additions & 14 deletions requirements.txt

This file was deleted.

13 changes: 0 additions & 13 deletions state.py

This file was deleted.

0 comments on commit a3f1c7b

Please sign in to comment.