Cat-Agent: Enhancing LLMs with Agent Workflows, RAG, Function Calling, and Code Interpreter.
Project description
Cat-Agent
Overview
Cat-Agent is a Python framework for building LLM-powered agents with pluggable tools, multi-agent workflows, and production-ready features. Use it to add function calling, RAG, code execution, and custom tools to your chat or automation pipelines.
Features
- Agent workflows —
Agent,Assistant,ReActChat,FnCallAgent,DocQAAgent,GroupChat,Router, and more - Function calling — Native tool/function support for LLMs
- RAG — Retrieval-augmented generation with vector, keyword, and hybrid search
- Code interpreter — Safe Python execution via Docker or WASM sandbox (no Docker required)
- Rich tool set — Web search, doc parsing, image generation, MCP, storage, and extensible custom tools
- Multiple LLM backends — OpenAI-compatible APIs, LlamaCpp (+ vision), OpenVINO, Transformers
- Structured logging — Loguru-powered logging with coloured console, JSON, and file rotation support
Installation
pip install cat-agent
Optional extras:
pip install cat-agent[rag] # RAG (retrieval, doc parsing, etc.)
pip install cat-agent[mcp] # MCP (Model Context Protocol)
pip install cat-agent[python_executor] # Python executor (math, sympy, etc.)
pip install cat-agent[code_interpreter] # Code interpreter server (Jupyter, FastAPI)
Logging
Cat-Agent uses Loguru for structured, coloured logging. By default the logger is silent (library-friendly). Activate it with a single environment variable:
# Pretty coloured output
CAT_AGENT_LOG_LEVEL=INFO python my_script.py
# Full debug verbosity
CAT_AGENT_LOG_LEVEL=DEBUG python my_script.py
# Structured JSON logs (for log aggregation pipelines)
CAT_AGENT_LOG_LEVEL=INFO CAT_AGENT_LOG_FORMAT=json python my_script.py
# Also write to a rotating log file
CAT_AGENT_LOG_LEVEL=DEBUG CAT_AGENT_LOG_FILE=agent.log python my_script.py
Or configure programmatically:
from cat_agent.log import logger, setup_logger
setup_logger(level="DEBUG") # coloured stderr
setup_logger(level="INFO", log_file="/tmp/cat.log") # + rotating file
setup_logger(level="DEBUG", fmt="json") # structured JSON
logger.info("Agent started")
logger.debug("Processing query: {}", query)
| Env Variable | Values | Default |
|---|---|---|
CAT_AGENT_LOG_LEVEL |
TRACE, DEBUG, INFO, WARNING, ERROR, CRITICAL |
(silent) |
CAT_AGENT_LOG_FILE |
file path | (none) |
CAT_AGENT_LOG_FORMAT |
pretty, json |
pretty |
Examples
Math tool with LlamaCpp
Registers a custom sum_two_number tool and uses a local GGUF model:
python examples/llama_cpp_math_guy/llama_cpp_example.py
Math tool with Transformers
Same concept using the HuggingFace Transformers backend (Qwen3-1.7B):
python examples/transformers_math_guy/math_guy.py
Vision with LlamaCpp
Analyse images from URLs using a multimodal GGUF model (Qwen2-VL):
python examples/llama_cpp_vision/llama_cpp_vision_example.py
Document parsing agent
Parse CSV/PDF/DOCX files and ask questions about their contents:
python examples/doc_parser_agent/doc_parser_example.py
Multi-agent: GroupChat
Two agents (Alice and Bob) converse in round-robin to plan a weekend trip:
python examples/multi_agent/group_chat_example.py
Multi-agent: Router
Intelligently route queries to specialised agents (MathExpert vs GeneralAssistant):
python examples/multi_agent/router_example.py
RAG with LEANN retriever
Retrieval-augmented generation using LEANN semantic search:
pip install cat-agent[rag]
python examples/rag_leann/leann_qwen3_demo.py
Minimal RAG usage in code:
from pathlib import Path
from cat_agent.llm.schema import Message, USER
from cat_agent.memory import Memory
import torch
llm_cfg = {
"model": "Qwen/Qwen3-1.7B",
"model_type": "transformers",
"device": "cuda:0" if torch.cuda.is_available() else "cpu",
}
mem = Memory(llm=llm_cfg, files=["doc.txt"], rag_cfg={"enable_leann": True, "rag_searchers": ["leann_search"]})
messages = [Message(role=USER, content="How much storage does LEANN save?")]
responses = mem.run_nonstream(messages, force_search=True)
print(responses[-1].content)
WASM code interpreter
Secure Python code execution in a WebAssembly sandbox (no Docker or Node.js needed):
python examples/wasm_code_interpreter/wasm_code_interpreter_example.py
Logging demo
Demonstrates coloured console logs, JSON output, and file logging alongside an agent:
python examples/logging_demo/logging_example.py
# Or with env-var driven config:
CAT_AGENT_LOG_LEVEL=DEBUG python examples/logging_demo/logging_example.py
LLM Backends
| Backend | model_type |
Description |
|---|---|---|
| OpenAI-compatible | oai |
Any OpenAI-compatible API (default) |
| LlamaCpp | llama_cpp |
Local GGUF models via llama-cpp-python |
| LlamaCpp Vision | llama_cpp_vision |
Multimodal GGUF models (Qwen2-VL, LLaVA, etc.) |
| Transformers | transformers |
HuggingFace Transformers models |
| OpenVINO | openvino |
Optimised inference on Intel hardware |
from cat_agent.agents import Assistant
bot = Assistant(
llm={"model_type": "llama_cpp", "repo_id": "Salesforce/xLAM-2-3b-fc-r-gguf", "filename": "xLAM-2-3B-fc-r-F16.gguf"},
name="MyAgent",
function_list=["my_tool"],
)
Project Structure
| Component | Description |
|---|---|
cat_agent.agent |
Base Agent class |
cat_agent.agents |
Assistant, ReActChat, FnCallAgent, DocQA, GroupChat, Router |
cat_agent.llm |
Chat model backends (OAI, LlamaCpp, LlamaCpp Vision, OpenVINO, Transformers) |
cat_agent.tools |
CodeInterpreter, WASMCodeInterpreter, Retrieval, DocParser, Storage, MCP, and more |
cat_agent.memory |
Memory, RAG, and context utilities |
cat_agent.log |
Loguru-based structured logging |
cat_agent.settings |
Configuration via environment variables |
Testing
- Test count: 222+ tests across
tests/test_agent.py,tests/test_agents.py,tests/test_llm.py,tests/test_memory.py,tests/test_tools.py, andtests/test_utils.py. - Test coverage: 59% (6,038 lines total).
- Run tests:
pytest(install withpip install -e ".[test]"). - Report coverage:
pytest --cov=cat_agent --cov-report=term
License
Licensed under the Apache License 2.0.
Author
Kemalcan Bora — kemalcanbora@gmail.com GitHub: kemalcanbora/cat-agent
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cat_agent-0.1.1.tar.gz.
File metadata
- Download URL: cat_agent-0.1.1.tar.gz
- Upload date:
- Size: 6.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b73561429de5fe5f81aee0bca6e555f1106d78adf940ea72db2a103a3c126cc5
|
|
| MD5 |
81edaee2999aa56fa9d24a74415c565a
|
|
| BLAKE2b-256 |
c59f46c3e01f0334f09136396fecbe9f309cb54d508d23c080a33267cf9b0527
|
File details
Details for the file cat_agent-0.1.1-py3-none-any.whl.
File metadata
- Download URL: cat_agent-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd62b7f645ab7304634d4f04f6cb88e01b58d0244e5efeab5788610626d906a0
|
|
| MD5 |
99eb411857f45b196fb2a092ba2eadc6
|
|
| BLAKE2b-256 |
45d06643d6ecd351a6ad088f291bbf5bbf768297527b593b6f64eca73fb8c3f7
|