Skip to main content

When you think about light weight LLMs, call brollm!

Project description

brollm

A lightweight Python library providing unified interfaces for LLM models, embeddings, and rerankers. Built for AI agent development with consistent APIs across different providers.

Features

  • Unified Interface: Same API across AWS Bedrock and Ollama
  • LLM Models: Chat completion with system prompts and message history
  • Embeddings: Text embedding generation for semantic search
  • Rerankers: Document reranking capabilities (base class ready)
  • Lightweight: Minimal dependencies, maximum flexibility

Installation

pip install brollm

or

uv add brollm

Quick Start

AWS Bedrock

from brollm import BedrockChat, BedrockEmbedding

# Chat completion
chat = BedrockChat(model_name="us.meta.llama3-2-11b-instruct-v1:0")
messages = [
    chat.UserMessage("What is machine learning?"),
    chat.AIMessage("Machine learning is..."),
    chat.UserMessage("Give me an example")
]
response = chat.run("You are a helpful AI assistant", messages)
print(response)

# Embeddings
embedding = BedrockEmbedding()
vector = embedding.embed_text("Hello world")
print(f"Embedding dimension: {len(vector)}")

Ollama

from brollm import OllamaChat, OllamaEmbedding

# Chat completion
chat = OllamaChat(model_name="qwen3:8b")
messages = [
    chat.UserMessage("Explain quantum computing"),
    chat.AIMessage("Quantum computing uses..."),
    chat.UserMessage("What are the applications?")
]
response = chat.run("You are a physics expert", messages)
print(response)

# Embeddings
embedding = OllamaEmbedding(model_name="nomic-embed-text")
vectors = embedding.embed_texts(["Hello", "World", "AI"])
print(f"Generated {len(vectors)} embeddings")

Multimodal Support (Bedrock)

from brollm import BedrockChat

chat = BedrockChat()
with open("image.jpg", "rb") as f:
    image_bytes = f.read()

messages = [
    chat.UserMessage("Describe this image", image_bytes=image_bytes, image_format="jpeg")
]
response = chat.run("You are a vision AI assistant", messages)
print(response)

Provider Switching

Switch between providers without changing your code structure:

# Use Bedrock
llm = BedrockChat(temperature=0.7)

# Switch to Ollama
llm = OllamaChat(temperature=0.7)

# Same interface for both
messages = [llm.UserMessage("Hello AI!")]
response = llm.run("You are helpful", messages)

Configuration

Bedrock

chat = BedrockChat(
    model_name="us.meta.llama3-2-11b-instruct-v1:0",
    temperature=0.7,
    region_name="us-west-2",
    aws_access_key_id="your-key",  # Optional, uses default AWS config
    aws_secret_access_key="your-secret",  # Optional
    aws_session_token="your-token"  # Optional
)

Ollama

chat = OllamaChat(
    model_name="qwen3:8b",
    temperature=0.7,
    base_url="http://localhost:11434"  # Default Ollama endpoint
)

License

MIT License

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

brollm-0.1.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

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

brollm-0.1.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file brollm-0.1.2.tar.gz.

File metadata

  • Download URL: brollm-0.1.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for brollm-0.1.2.tar.gz
Algorithm Hash digest
SHA256 535b33da9065aa827ee5ec1beb1953712e6cf1e1180a3ed531a329bfa62cb66e
MD5 caa1c7395b861bbaea3abf07ab1c4267
BLAKE2b-256 b8770cda5d443819a9297b73fd0ba566f1a297f6070f5da428a2b7d22377095b

See more details on using hashes here.

File details

Details for the file brollm-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: brollm-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for brollm-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f9658f449c0da0de7d2f052648713e1a7dc3bed53abb3dc65fa7efed76c1a20b
MD5 a3ce970844413dff226d8b1452f4e539
BLAKE2b-256 ae55f165df969d7b70c62e8ff77df864e97fe6b59a3cd0ed2390aea66ef57cc7

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