Skip to main content

LlamaIndex LLMs ModelsLab Integration

Provides ModelsLab as an LLM provider for LlamaIndex — giving RAG pipelines, agents, and query engines access to uncensored Llama 3.1 models with 128K context windows.

Installation

pip install llama-index-llms-modelslab

Setup

Get your API key at modelslab.com, then:

export MODELSLAB_API_KEY="your-api-key"

Usage

Basic completion

from llama_index.llms.modelslab import ModelsLabLLM

llm = ModelsLabLLM(model="llama-3.1-8b-uncensored")

resp = llm.complete("Explain how attention mechanisms work in transformers.")
print(resp)

Chat

from llama_index.core.llms import ChatMessage

messages = [
    ChatMessage(
        role="user",
        content="Write a Python function to merge two sorted lists.",
    ),
]
resp = llm.chat(messages)
print(resp)

RAG pipeline

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.llms.modelslab import ModelsLabLLM

Settings.llm = ModelsLabLLM(model="llama-3.1-70b-uncensored")

documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()

response = query_engine.query("Summarize the key findings.")
print(response)

Streaming

llm = ModelsLabLLM(model="llama-3.1-8b-uncensored")

for chunk in llm.stream_complete("Write a haiku about code:"):
    print(chunk.delta, end="", flush=True)

Models

Model Context Window Best for
llama-3.1-8b-uncensored 128K Fast completions, most tasks (default)
llama-3.1-70b-uncensored 128K Complex reasoning, high quality output

Configuration

llm = ModelsLabLLM(
    model="llama-3.1-8b-uncensored",
    api_key="your-key",  # or MODELSLAB_API_KEY env var
    context_window=131072,  # 128K (default)
    temperature=0.7,  # sampling temperature
    max_tokens=2048,  # max output tokens
    is_chat_model=True,  # use chat endpoint (default)
)

API Reference

Metadata

Release files for llama-index-llms-modelslab 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-llms-modelslab 0.3.1
File Size Uploaded Provenance
llama_index_llms_modelslab-0.3.1.tar.gz 3.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-llms-modelslab 0.3.1
File Interpreter ABI Platform
llama_index_llms_modelslab-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 6.7 kB

Release files / llama_index_llms_modelslab-0.3.1.tar.gz

Download URL llama_index_llms_modelslab-0.3.1.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e9d7bc36b7f16aaf9ea8f4da22faaeb003f0cc7867200becae0bf640389b6f37
BLAKE2b-256 checksum
How to use checksums
fdfd92a049122931bc52ae70c39f115c8db2eef0eefed8c92da9724ff9430a63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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_modelslab-0.3.1-py3-none-any.whl

Download URL llama_index_llms_modelslab-0.3.1-py3-none-any.whl
Size 3.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2e28e9a8439df8e083344cb4cf734e865840548cd318fccd0cc853efd1f52e06
BLAKE2b-256 checksum
How to use checksums
0394f1a7b03b6621b8a5664ec44fa063d30a004fe8ec5f1291cc50f866c78892
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.7 {"installer":{"name":"uv","version":"0.12.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","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-modelslab 0.3.1

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page