Skip to content

harpertoken/ml-api

Repository files navigation

ml-api

build, deploy, and scale machine learning with ease.

ML API

features

  • upload models: deploy your models effortlessly.
  • real-time inference: generate predictions instantly.
  • version management: keep your models organized and up to date.

get started

  1. clone the repository:

    git clone https://github.com/harpertoken/ml-api.git  
  2. navigate to the project:

    cd ml-api  
  3. install dependencies:

    pip install -r requirements.txt  

    Note: numpy is not included in requirements.txt due to Python version constraints. For local development with numpy 2.3.3, ensure Python >=3.11 and install separately: pip install numpy==2.3.3. Docker builds use Python 3.12 and install numpy 2.3.3 automatically.

deploy the web interface

kubectl apply -f k8s.yaml

run the api

launch the server with:

python main.py  

example request

curl -X POST http://localhost:8000/chat -H "Content-Type: application/json" -d '{"prompt": "Hello, world!"}'

additional endpoints

  • GET /models: list available models
  • GET /status: get api and model status

requirements

  • python 3.8+ (3.11+ recommended for numpy 2.3.3)
  • fastapi, huggingface transformers, pytorch, numpy (see installation notes)

contribute

shape the future of ml-api. submit issues or pull requests to make it even better.

conventional commits

this project follows conventional commit standards to ensure clear and consistent commit messages.

setup

to enable commit message validation:

  1. copy the hook script to your local git hooks:

    for unix/linux/macos:

    cp scripts/commit-msg .git/hooks/commit-msg
    chmod +x .git/hooks/commit-msg

    for windows (powershell):

    cp scripts/commit-msg.ps1 .git/hooks/commit-msg

commit message format

commit messages must follow this format:

  • start with a type: feat:, fix:, docs:, style:, refactor:, test:, chore:, perf:, ci:, build:, revert:
  • followed by a space and a lowercase description
  • first line ≤60 characters

example: feat: add user authentication

history cleanup

if you need to clean up existing commit messages (make lowercase and truncate), use the rewrite script:

for unix/linux/macos:

bash scripts/rewrite_msg.sh

for windows (powershell):

get-content | scripts/rewrite_msg.ps1

for rewriting the entire history:

git filter-branch --msg-filter 'bash scripts/rewrite_msg.sh' -- --all

(on windows, use powershell equivalent)

note: this rewrites history, so use with caution and force-push if necessary.

releases

to create an alpha release:

bash scripts/release_alpha.sh

this will bump the version, create a tag, push, and publish a prerelease on github.

license

licensed under the mit license. see the LICENSE file for details.