FastAPI REST API server for Microsoft's BitNet LLM - Initialize and chat with many BitNet servers!
949
This project provides a robust REST API built with FastAPI and Docker to manage and interact with llama.cpp-based BitNet model instances. It allows developers and researchers to programmatically control llama-cli processes for automated testing, benchmarking, and interactive chat sessions.
It serves as a backend replacement for the Electron-BitNet project, offering enhanced performance, scalability, and persistent chat sessions.
llama-cli and llama-server session based chats.Create and activate a Conda environment:
conda create -n bitnet python=3.11
conda activate bitnet
Install the Huggingface-CLI tool to download the models:
pip install -U "huggingface_hub[cli]"
Download Microsoft's official BitNet model:
huggingface-cli download microsoft/BitNet-b1.58-2B-4T-gguf --local-dir app/models/BitNet-b1.58-2B-4T
This is the easiest and recommended way to run the application.
Build the Docker image:
docker build -t fastapi_bitnet .
Run the Docker container:
This command runs the container in detached mode (-d) and maps port 8080 on your host to port 8080 in the container.
docker run -d --name ai_container -p 8080:8080 fastapi_bitnet
For development, you can run the application directly with Uvicorn, which enables auto-reloading.
uvicorn app.main:app --host 0.0.0.0 --port 8080 --reload
Once the server is running, you can access the interactive API documentation:
You can connect this API directly to VS Code's Copilot Chat to create and interact with models.
+ Add MCP Server, then choose HTTP.http://127.0.0.1:8080/mcpCopilot will now be able to use the API to launch and chat with BitNet instances.
For a more integrated experience, check out the companion VS Code extension:
This project is licensed under the MIT License. See the LICENSE file for details.
Content type
Image
Digest
sha256:89c528748…
Size
2 GB
Last updated
about 1 year ago
docker pull grctest/fastapi_bitnet