Skip to main content

llama-index llms modelslab integration

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llama_index_llms_modelslab-0.1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llama_index_llms_modelslab-0.1.0-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file llama_index_llms_modelslab-0.1.0.tar.gz.

File metadata

  • Download URL: llama_index_llms_modelslab-0.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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}

File hashes

Hashes for llama_index_llms_modelslab-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8c2e7e3351391c6985c5bbeea3feed79baa765627e59e16b00335c2257281649
MD5 50540743838bcd5a7b4339fe1196acc8
BLAKE2b-256 5f4f8767a14a602c5fffe9a53e65b721a7254aa8efca702cef60b0da3e868e22

See more details on using hashes here.

File details

Details for the file llama_index_llms_modelslab-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: llama_index_llms_modelslab-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.4 {"installer":{"name":"uv","version":"0.10.4","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}

File hashes

Hashes for llama_index_llms_modelslab-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf86c1ca4e7a765a7b7d22740d5bd210018d1703389f35d5131a6350e065975d
MD5 28da212029d62b42cd3a44855a8c6fc8
BLAKE2b-256 b2ce8467ebd564ef34f512cf7302d3a6ed997de922cdae8ed260596e2fe3c402

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page