Metadata-Version: 2.4
Name: llmpop
Version: 0.3
Summary: The Python library that lets you spin up any LLM with a single function. Route between local and remote LLMs with a unified interface.
Author: Lior Gazit
License: MIT
Project-URL: Homepage, https://github.com/LiorGazit/llmpop
Project-URL: Issues, https://github.com/LiorGazit/llmpop/issues
Keywords: LLM,Ollama,LangChain,Agents,OpenAI,Router
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Operating System :: POSIX :: Linux
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.31.0
Requires-Dist: psutil>=5.9.0
Requires-Dist: langchain-core>=0.2.0
Requires-Dist: langchain-ollama>=0.1.0
Provides-Extra: openai
Requires-Dist: langchain-openai>=0.2.0; extra == "openai"
Provides-Extra: dev
Requires-Dist: pytest>=7.4; extra == "dev"
Requires-Dist: pytest-cov>=4.1; extra == "dev"
Requires-Dist: ruff>=0.5; extra == "dev"
Requires-Dist: black>=24.8.0; extra == "dev"
Requires-Dist: mypy>=1.10.0; extra == "dev"
Requires-Dist: pre-commit>=3.7.0; extra == "dev"
Dynamic: license-file

# [LLMPop](https://pypi.org/project/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`**](https://raw.githubusercontent.com/LiorGazit/llmpop/main/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](https://github.com/LiorGazit), and GPT5  
Total hours spent in total on this project so far: `23 hours`   

### Quick run of LLMPop:  
Quickest on Colab:  
<a target="_blank" href="https://colab.research.google.com/github/LiorGazit/llmpop/blob/main/examples/quick_run_llmpop.ipynb">
  <img src="https://colab.research.google.com/assets/colab-badge.svg" alt="Open In Colab"/>
</a>  
Or if you want to set it up yourself, pick the free `T4 GPU`, and copy code over:    
**Setup:**  
```python
%pip -q install llmpop 
from llmpop import init_llm
```  
**Run:**  
```python
# Start with Meta's Llama. If you want a stronger (and bigger) model, try OpenAI's free "gpt-oss:20b":
model = init_llm(model="llama3.2:1b", provider="ollama")
user_prompt = "What OS is better for deploying high scale programs in production? Linux, or Windows?"
print(model.invoke(user_prompt).content)
```

## Examples and tools built with LLMPop  
- `../notebooks/`  
- `../examples/`  

## 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`**](https://raw.githubusercontent.com/LiorGazit/llmpop/main/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](https://colab.research.google.com/github/LiorGazit/llmpop/blob/main/examples/run_ollama_in_colab.ipynb).  

📖 **Quick Guides**
- **Library usage (human-readable):** See [`LLM_READABLE_GUIDE.md`](./LLM_READABLE_GUIDE.md)  
- **Full docs homepage:** See [`docs/index.md`](./docs/index.md)  


## Codebase Structure  
llmpop/  
├─ .github/  
│  └─ workflows/  
│     └─ ci.yml  
├─ docs/  
│  └─ index.md  
├─ notebooks/  
│  └─ multi_llm_webapp.ipynb  
├─ examples/  
│  ├─ quick_run_llmpop.ipynb  
│  ├─ quick_run_llmpop.py  
│  └─ run_ollama_in_colab.ipynb  
├─ src/  
│  └─ llmpop/  
│     ├─ \_\_init\_\_.py  
│     ├─ init_llm.py   
│     ├─ monitor_resources.py  
│     ├─ py.typed  
│     └─ 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            
├─ MANIFEST.in            
├─ 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 -q install llmpop`  

2. Try it  
    ```python
    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
    ```python
    monitor_thread = start_resource_monitoring(duration=600, interval=10)
    ```

Enjoy!
