LlamaIndex Llms Integration: llamafile
Setup Steps
1. Download a LlamaFile
Use the following command to download a LlamaFile from Hugging Face:
wget https://huggingface.co/jartine/TinyLlama-1.1B-Chat-v1.0-GGUF/resolve/main/TinyLlama-1.1B-Chat-v1.0.Q5_K_M.llamafile
2. Make the File Executable
On Unix-like systems, run the following command:
chmod +x TinyLlama-1.1B-Chat-v1.0.Q5_K_M.llamafile
For Windows, simply rename the file to end with .exe.
3. Start the Model Server
Run the following command to start the model server, which will listen on http://localhost:8080 by default:
./TinyLlama-1.1B-Chat-v1.0.Q5_K_M.llamafile --server --nobrowser --embedding
Using LlamaIndex
If you are using Google Colab or want to interact with LlamaIndex, you will need to install the necessary packages:
%pip install llama-index-llms-llamafile
!pip install llama-index
Import Required Libraries
from llama_index.llms.llamafile import Llamafile
from llama_index.core.llms import ChatMessage
Initialize the LLM
Create an instance of the LlamaFile LLM:
llm = Llamafile(temperature=0, seed=0)
Generate Completions
To generate a completion for a prompt, use the complete method:
resp = llm.complete("Who is Octavia Butler?")
print(resp)
Call Chat with a List of Messages
You can also interact with the LLM using a list of messages:
messages = [
ChatMessage(
role="system",
content="Pretend you are a pirate with a colorful personality.",
),
ChatMessage(role="user", content="What is your name?"),
]
resp = llm.chat(messages)
print(resp)
Streaming Responses
To use the streaming capabilities, you can call the stream_complete method:
response = llm.stream_complete("Who is Octavia Butler?")
for r in response:
print(r.delta, end="")
You can also stream chat responses:
messages = [
ChatMessage(
role="system",
content="Pretend you are a pirate with a colorful personality.",
),
ChatMessage(role="user", content="What is your name?"),
]
resp = llm.stream_chat(messages)
for r in resp:
print(r.delta, end="")
LLM Implementation example
https://docs.llamaindex.ai/en/stable/examples/llm/llamafile/
Metadata
Release files for llama-index-llms-llamafile 0.7.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_llms_llamafile-0.7.0.tar.gz | 5.8 kB | Without provenance | Details for llama_index_llms_llamafile-0.7.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_llms_llamafile-0.7.0-py3-none-any.whl | Python 3 | none | any | Details for llama_index_llms_llamafile-0.7.0-py3-none-any.whl |
Total release size: 11.3 kB
Release files / llama_index_llms_llamafile-0.7.0.tar.gz
| Download URL | llama_index_llms_llamafile-0.7.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f4001d87586311233e92028f8c578d4d46492518cc5b185a155ee35318c1d1e
|
|
BLAKE2b-256 checksum How to use checksums |
fd400fac88f0420363752de516cc00152cd23aae6278ab450ae4acee9ed855ea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / llama_index_llms_llamafile-0.7.0-py3-none-any.whl
| Download URL | llama_index_llms_llamafile-0.7.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b12960429e097b420ca248cfeec8940d4b38e55e584edaa39534c9571527dd5a
|
|
BLAKE2b-256 checksum How to use checksums |
d3d5d9d39ddc2e433ac1695b3a0b20e945e115b549b7d847269ed4015e9fb099
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.8 {"installer":{"name":"uv","version":"0.13.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for llama-index-llms-llamafile 0.7.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.