This project runs a LLAMA 3.1 language model locally on a Raspberry Pi using Ollama and provides an API for users and developers to create apps. The API accepts questions from users and provides outputs in HTML format.
- Local hosting of LLAMA 3.1 model on Raspberry Pi
- RESTful API for querying the model
- HTML-formatted responses
- Easy integration for developers to build applications
llama-api-project/
├── src/
│ ├── api/
│ │ ├── __init__.py
│ │ ├── main.py
│ │ └── routes.py
│ ├── model/
│ │ ├── __init__.py
│ │ └── llama_wrapper.py
│ └── utils/
│ ├── __init__.py
│ └── html_formatter.py
├── tests/
│ ├── __init__.py
│ ├── test_api.py
│ └── test_model.py
├── .gitignore
├── README.md
├── requirements.txt
└── setup.py
- Raspberry Pi (3 or newer recommended)/Windows/MAC
- Python 3.7+
- Ollama installed on the Raspberry Pi
-
Clone the repository:
git clone https://github.com/Shivp1413/Local-LLM-api-project.git cd Local-LLM-api-project
-
Install dependencies:
pip install -r requirements.txt
-
Ensure Ollama is installed and the LLAMA 3.1 model is available:
ollama pull llama:3.1
-
Run the API:
uvicorn src.api.main:app --host 0.0.0.0 --port 8000
To query the model, send a POST request to the /api/query
endpoint:
curl -X POST "http://your-raspberry-pi-ip:8000/api/query" \
-H "Content-Type: application/json" \
-d '{"question": "What is the capital of France?"}'
The API will return an HTML-formatted response.
GET /
: Welcome messagePOST /api/query
: Query the LLAMA 3.1 model
{
"question": "Your question here"
}
{
"response": "<div class=\"llama-response\"><p>HTML-formatted answer here</p></div>"
}
pytest tests/
- Implement new functionality in the appropriate module.
- Add corresponding tests in the
tests/
directory. - Update this README if necessary.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
- Meta for the LLAMA 3.1 model
- Ollama for providing easy model deployment
- FastAPI for the web framework