Skip to main content

The Python library that lets you spin up any LLM with a single function. Route between local and remote LLMs with a unified interface.

Project description

LLMPop

The Python library that lets you spin up any LLM with a single function.
Why did we need this library:

  1. Needed a single simple command for any LLM, including the free local LLMs that Ollama offers.
  2. Needed a better way for introducing a code library to a LLM that helps you build code. The llmpop library comes with a machine-readable file that is minimal and sufficent, see LLM_READABLE_GUIDE.md. Add it to your conversation with the coding LLM and it will learn how to build code with llmpop. From a security aspect, this approach is safer then directing your LLM to read someone's entire codebase.

Devs: Lior Gazit, and GPT5

*Total hours spent in total on this project so far: 14 hours

Quick run of LLMPop:

Quickest on Colab:
Open In Colab
Or if you want to set it up yourself, pick the free T4 GPU, and copy code over:

print("Installing llmpop:")
%pip -q install git+https://github.com/LiorGazit/llmpop.git 
print("Done installing llmpop.\n")
from llmpop import init_llm, start_resource_monitoring
from langchain_core.prompts import ChatPromptTemplate

# Spinning up OpenAI's free GPT-OSS-20B, give it a few minutes, it's worth it.
# If you want a quick LLM, set model="llama3.2:1b".
model = init_llm(model="gpt-oss:20b", provider="ollama")
prompt = ChatPromptTemplate.from_template("Q: {q}\nA:")
user_prompt = "What OS is better for deploying high scale programs in production? Linux, or Windows?"
print((prompt | model).invoke({"q":user_prompt}).content)

Features

  • Plug-and-play local LLMs via Ollama—no cloud or API costs required.
  • Easy remote API support (OpenAI, extendable).
  • Unified interface: Seamlessly switch between local and remote models in your code.
  • Resource monitoring: Track CPU, memory, and (optionally) GPU usage while your agents run.

Using LLMPop while coding with an LLM/chatbot

A dedicated, machine readable guide file, is designed to be the one single necessary file for a bot to get to know LLMPop and to build your code with it.
This guide file is LLM_READABLE_GUIDE.md
So, either upload this file to your bot's conversation, or copy the file's content to paste for the bot's context, and it would allow your bot to leverage LLMPop as it builds code.
Note that this machine readable file is super useful in cases that your bot doesn't have access to the internet and can't learn about code libraries it wasn't trained on.
More on this guide file in docs/index.md

Quick start via Colab

Start by running run_ollama_in_colab.ipynb in Colab.

Codebase Structure

llmpop/
├─ .github/
│ └─ workflows/
│ └─ ci.yml
├─ docs/
│ └─ index.md
├─ examples/
│ ├─ quick_run_llmpop.py
│ └─ run_ollama_in_colab.ipynb
├─ src/
│ └─ llmpop/
│ ├─ init.py
│ ├─ init_llm.py
│ ├─ monitor_resources.py
│ └─ version.py
├─ tests/
│ ├─ test_init_llm.py
│ ├─ test_llm_readable_guide.py
│ └─ test_monitor_resources.py
├─ .gitignore
├─ .pre-commit-config.yaml
├─ CHANGELOG.md
├─ CODE_OF_CONDUCT.md
├─ CONTRIBUTING.md
├─ DEVLOG.md
├─ LICENSE
├─ LLM_READABLE_GUIDE.md
├─ Makefile
├─ pyproject.toml
├─ README.md
├─ requirements-dev.txt
└─ requirements.txt

Where:
src/ layout is the modern standard for packaging.
tests/ use pytest; we’ll mock shell/network so CI doesn’t try to actually install/run Ollama.
examples/ contains notebooks users can run locally/Colab.
docs/ is optional now; you can add mkdocs later.
CI runs lint + unit tests on pushes and PRs.
CHANGELOG follows Keep a Changelog; DEVLOG is your running engineering journal.

Quick setting up

  1. Install from GitHub
    pip install git+https://github.com/LiorGazit/llmpop.git

  2. Try it

    from llmpop import init_llm, start_resource_monitoring
    from langchain_core.prompts import ChatPromptTemplate
    
    model = init_llm(model="gemma3:1b", provider="ollama")
    # Or:
    # os.environ["OPENAI_API_KEY"] = "sk-..."
    # model = init_llm(chosen_llm="gpt-4o", provider="openai")
    
    prompt = ChatPromptTemplate.from_template("Q: {q}\nA:")
    print((prompt | model).invoke({"q":"What is an agent?"}).content)
    
  3. Optional - Resource Monitoring

    monitor_thread = start_resource_monitoring(duration=600, interval=10)
    

Enjoy!

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

llmpop-0.2.2.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

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

llmpop-0.2.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file llmpop-0.2.2.tar.gz.

File metadata

  • Download URL: llmpop-0.2.2.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for llmpop-0.2.2.tar.gz
Algorithm Hash digest
SHA256 ac71e93356b2637b5cbc6b1f23f9615240bdf2594e08016bc1b993fde88c8f83
MD5 9966c0a60b7872bcc5a494e313370482
BLAKE2b-256 65e3deb4a43f95c2459405a2acab75ed1bc485bc38645e984436e2fd17b98057

See more details on using hashes here.

File details

Details for the file llmpop-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: llmpop-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for llmpop-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 432bc01503a6330eb2ba88099f925c93f933deea05126d133511c1a3ec76b7c1
MD5 eea33a2599d58df5c7201f9c12ecabb3
BLAKE2b-256 9e39624f3bd3fa6da4704bf0d24985822b96a43d25a05e7286bdac29c80868ee

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