cat-agent 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cat_agent-0.0.1/PKG-INFO +286 -0
- cat_agent-0.0.1/README.md +226 -0
- cat_agent-0.0.1/cat_agent/__init__.py +8 -0
- cat_agent-0.0.1/cat_agent/agent.py +269 -0
- cat_agent-0.0.1/cat_agent/agents/__init__.py +31 -0
- cat_agent-0.0.1/cat_agent/agents/assistant.py +169 -0
- cat_agent-0.0.1/cat_agent/agents/doc_qa/__init__.py +21 -0
- cat_agent-0.0.1/cat_agent/agents/doc_qa/basic_doc_qa.py +73 -0
- cat_agent-0.0.1/cat_agent/agents/doc_qa/parallel_doc_qa.py +536 -0
- cat_agent-0.0.1/cat_agent/agents/doc_qa/parallel_doc_qa_member.py +153 -0
- cat_agent-0.0.1/cat_agent/agents/doc_qa/parallel_doc_qa_summary.py +89 -0
- cat_agent-0.0.1/cat_agent/agents/fncall_agent.py +111 -0
- cat_agent-0.0.1/cat_agent/agents/group_chat.py +308 -0
- cat_agent-0.0.1/cat_agent/agents/group_chat_auto_router.py +95 -0
- cat_agent-0.0.1/cat_agent/agents/keygen_strategies/__init__.py +25 -0
- cat_agent-0.0.1/cat_agent/agents/keygen_strategies/gen_keyword.py +83 -0
- cat_agent-0.0.1/cat_agent/agents/keygen_strategies/gen_keyword_with_knowledge.py +83 -0
- cat_agent-0.0.1/cat_agent/agents/keygen_strategies/split_query.py +104 -0
- cat_agent-0.0.1/cat_agent/agents/keygen_strategies/split_query_then_gen_keyword.py +69 -0
- cat_agent-0.0.1/cat_agent/agents/keygen_strategies/split_query_then_gen_keyword_with_knowledge.py +32 -0
- cat_agent-0.0.1/cat_agent/agents/memo_assistant.py +110 -0
- cat_agent-0.0.1/cat_agent/agents/react_chat.py +151 -0
- cat_agent-0.0.1/cat_agent/agents/router.py +107 -0
- cat_agent-0.0.1/cat_agent/agents/user_agent.py +26 -0
- cat_agent-0.0.1/cat_agent/agents/virtual_memory_agent.py +97 -0
- cat_agent-0.0.1/cat_agent/agents/writing/__init__.py +25 -0
- cat_agent-0.0.1/cat_agent/agents/writing/continue_writing.py +54 -0
- cat_agent-0.0.1/cat_agent/agents/writing/expand_writing.py +82 -0
- cat_agent-0.0.1/cat_agent/agents/writing/outline_writing.py +56 -0
- cat_agent-0.0.1/cat_agent/llm/__init__.py +35 -0
- cat_agent-0.0.1/cat_agent/llm/base/__init__.py +16 -0
- cat_agent-0.0.1/cat_agent/llm/base/model.py +437 -0
- cat_agent-0.0.1/cat_agent/llm/base/postprocessing.py +81 -0
- cat_agent-0.0.1/cat_agent/llm/base/retry.py +75 -0
- cat_agent-0.0.1/cat_agent/llm/base/truncation.py +237 -0
- cat_agent-0.0.1/cat_agent/llm/fncall_prompts/__init__.py +14 -0
- cat_agent-0.0.1/cat_agent/llm/fncall_prompts/base_fncall_prompt.py +87 -0
- cat_agent-0.0.1/cat_agent/llm/fncall_prompts/nous_fncall_prompt.py +342 -0
- cat_agent-0.0.1/cat_agent/llm/fncall_prompts/qwen_fncall_prompt.py +402 -0
- cat_agent-0.0.1/cat_agent/llm/function_calling.py +194 -0
- cat_agent-0.0.1/cat_agent/llm/llama_cpp.py +173 -0
- cat_agent-0.0.1/cat_agent/llm/llama_cpp_vision.py +297 -0
- cat_agent-0.0.1/cat_agent/llm/oai.py +190 -0
- cat_agent-0.0.1/cat_agent/llm/openvino.py +159 -0
- cat_agent-0.0.1/cat_agent/llm/schema.py +164 -0
- cat_agent-0.0.1/cat_agent/llm/transformers_llm.py +198 -0
- cat_agent-0.0.1/cat_agent/log.py +143 -0
- cat_agent-0.0.1/cat_agent/memory/__init__.py +19 -0
- cat_agent-0.0.1/cat_agent/memory/memory.py +176 -0
- cat_agent-0.0.1/cat_agent/multi_agent_hub.py +50 -0
- cat_agent-0.0.1/cat_agent/settings.py +39 -0
- cat_agent-0.0.1/cat_agent/tools/__init__.py +49 -0
- cat_agent-0.0.1/cat_agent/tools/base.py +221 -0
- cat_agent-0.0.1/cat_agent/tools/code_interpreter.py +493 -0
- cat_agent-0.0.1/cat_agent/tools/doc_parser.py +309 -0
- cat_agent-0.0.1/cat_agent/tools/extract_doc_vocabulary.py +68 -0
- cat_agent-0.0.1/cat_agent/tools/image_search.py +205 -0
- cat_agent-0.0.1/cat_agent/tools/mcp_manager.py +476 -0
- cat_agent-0.0.1/cat_agent/tools/parsers/__init__.py +65 -0
- cat_agent-0.0.1/cat_agent/tools/parsers/base.py +41 -0
- cat_agent-0.0.1/cat_agent/tools/parsers/excel_parser.py +111 -0
- cat_agent-0.0.1/cat_agent/tools/parsers/html_parser.py +35 -0
- cat_agent-0.0.1/cat_agent/tools/parsers/pdf_parser.py +122 -0
- cat_agent-0.0.1/cat_agent/tools/parsers/ppt_parser.py +42 -0
- cat_agent-0.0.1/cat_agent/tools/parsers/txt_parser.py +13 -0
- cat_agent-0.0.1/cat_agent/tools/parsers/word_parser.py +23 -0
- cat_agent-0.0.1/cat_agent/tools/python_executor.py +270 -0
- cat_agent-0.0.1/cat_agent/tools/resource/__init__.py +0 -0
- cat_agent-0.0.1/cat_agent/tools/resource/docker_runtime/__init__.py +0 -0
- cat_agent-0.0.1/cat_agent/tools/resource/docker_runtime/code_interpreter_init_kernel.py +64 -0
- cat_agent-0.0.1/cat_agent/tools/retrieval.py +109 -0
- cat_agent-0.0.1/cat_agent/tools/search_tools/__init__.py +27 -0
- cat_agent-0.0.1/cat_agent/tools/search_tools/base_search.py +186 -0
- cat_agent-0.0.1/cat_agent/tools/search_tools/front_page_search.py +49 -0
- cat_agent-0.0.1/cat_agent/tools/search_tools/hybrid_search.py +61 -0
- cat_agent-0.0.1/cat_agent/tools/search_tools/keyword_search.py +195 -0
- cat_agent-0.0.1/cat_agent/tools/search_tools/leann_search.py +140 -0
- cat_agent-0.0.1/cat_agent/tools/search_tools/vector_search.py +60 -0
- cat_agent-0.0.1/cat_agent/tools/simple_doc_parser.py +132 -0
- cat_agent-0.0.1/cat_agent/tools/storage.py +110 -0
- cat_agent-0.0.1/cat_agent/tools/wasm_code_interpreter.py +256 -0
- cat_agent-0.0.1/cat_agent/tools/web_extractor.py +39 -0
- cat_agent-0.0.1/cat_agent/tools/web_search.py +67 -0
- cat_agent-0.0.1/cat_agent/utils/__init__.py +0 -0
- cat_agent-0.0.1/cat_agent/utils/file_utils.py +180 -0
- cat_agent-0.0.1/cat_agent/utils/json_utils.py +51 -0
- cat_agent-0.0.1/cat_agent/utils/media_utils.py +54 -0
- cat_agent-0.0.1/cat_agent/utils/message_utils.py +254 -0
- cat_agent-0.0.1/cat_agent/utils/misc.py +110 -0
- cat_agent-0.0.1/cat_agent/utils/output_beautify.py +164 -0
- cat_agent-0.0.1/cat_agent/utils/parallel_executor.py +63 -0
- cat_agent-0.0.1/cat_agent/utils/qwen.tiktoken +151643 -0
- cat_agent-0.0.1/cat_agent/utils/str_processing.py +44 -0
- cat_agent-0.0.1/cat_agent/utils/tokenization_qwen.py +246 -0
- cat_agent-0.0.1/cat_agent/utils/utils.py +67 -0
- cat_agent-0.0.1/cat_agent.egg-info/PKG-INFO +286 -0
- cat_agent-0.0.1/cat_agent.egg-info/SOURCES.txt +148 -0
- cat_agent-0.0.1/cat_agent.egg-info/dependency_links.txt +1 -0
- cat_agent-0.0.1/cat_agent.egg-info/requires.txt +53 -0
- cat_agent-0.0.1/cat_agent.egg-info/top_level.txt +3 -0
- cat_agent-0.0.1/pyproject.toml +94 -0
- cat_agent-0.0.1/setup.cfg +4 -0
- cat_agent-0.0.1/tests/__init__.py +0 -0
- cat_agent-0.0.1/tests/test_agent.py +309 -0
- cat_agent-0.0.1/tests/test_assistant.py +95 -0
- cat_agent-0.0.1/tests/test_base_fncall_prompt.py +39 -0
- cat_agent-0.0.1/tests/test_base_search.py +36 -0
- cat_agent-0.0.1/tests/test_code_interpreter.py +48 -0
- cat_agent-0.0.1/tests/test_continue_writing.py +34 -0
- cat_agent-0.0.1/tests/test_doc_parser.py +89 -0
- cat_agent-0.0.1/tests/test_expand_writing.py +95 -0
- cat_agent-0.0.1/tests/test_front_page_search.py +25 -0
- cat_agent-0.0.1/tests/test_function_calling.py +102 -0
- cat_agent-0.0.1/tests/test_gen_keyword.py +17 -0
- cat_agent-0.0.1/tests/test_group_chat.py +187 -0
- cat_agent-0.0.1/tests/test_group_chat_auto_router.py +91 -0
- cat_agent-0.0.1/tests/test_image_search.py +18 -0
- cat_agent-0.0.1/tests/test_keyword_search.py +104 -0
- cat_agent-0.0.1/tests/test_leann_search.py +71 -0
- cat_agent-0.0.1/tests/test_llama_cpp.py +120 -0
- cat_agent-0.0.1/tests/test_llama_cpp_vision.py +440 -0
- cat_agent-0.0.1/tests/test_llm_base.py +161 -0
- cat_agent-0.0.1/tests/test_memo_assistant.py +152 -0
- cat_agent-0.0.1/tests/test_memory.py +568 -0
- cat_agent-0.0.1/tests/test_multi_agent_hub.py +39 -0
- cat_agent-0.0.1/tests/test_nous_fncall_prompt.py +111 -0
- cat_agent-0.0.1/tests/test_openvino.py +12 -0
- cat_agent-0.0.1/tests/test_outline_writing.py +32 -0
- cat_agent-0.0.1/tests/test_output_beautify.py +100 -0
- cat_agent-0.0.1/tests/test_parallel_doc_qa.py +119 -0
- cat_agent-0.0.1/tests/test_parallel_executor.py +20 -0
- cat_agent-0.0.1/tests/test_parsers.py +829 -0
- cat_agent-0.0.1/tests/test_python_executor.py +473 -0
- cat_agent-0.0.1/tests/test_qwen_fncall_prompt.py +133 -0
- cat_agent-0.0.1/tests/test_react_chat.py +100 -0
- cat_agent-0.0.1/tests/test_retrieval.py +36 -0
- cat_agent-0.0.1/tests/test_router.py +92 -0
- cat_agent-0.0.1/tests/test_schema.py +126 -0
- cat_agent-0.0.1/tests/test_simple_doc_parser.py +235 -0
- cat_agent-0.0.1/tests/test_storage.py +54 -0
- cat_agent-0.0.1/tests/test_str_processing.py +33 -0
- cat_agent-0.0.1/tests/test_tokenization_qwen.py +67 -0
- cat_agent-0.0.1/tests/test_tools_base.py +75 -0
- cat_agent-0.0.1/tests/test_transformers_llm.py +21 -0
- cat_agent-0.0.1/tests/test_user_agent.py +17 -0
- cat_agent-0.0.1/tests/test_utils.py +271 -0
- cat_agent-0.0.1/tests/test_vector_search.py +78 -0
- cat_agent-0.0.1/tests/test_virtual_memory_agent.py +88 -0
- cat_agent-0.0.1/tests/test_web_extractor.py +25 -0
- cat_agent-0.0.1/tests/test_web_search.py +33 -0
cat_agent-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cat-agent
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Cat-Agent: Enhancing LLMs with Agent Workflows, RAG, Function Calling, and Code Interpreter.
|
|
5
|
+
Author-email: Kemalcan Bora <kemalcanbora@gmail.com>
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/kemalcanbora/cat-agent
|
|
8
|
+
Project-URL: Issue Tracker, https://github.com/kemalcanbora/cat-agent/issues
|
|
9
|
+
Keywords: LLM,Agent,Function Calling,RAG,Code Interpreter
|
|
10
|
+
Requires-Python: >=3.10
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: eval_type_backport
|
|
13
|
+
Requires-Dist: json5
|
|
14
|
+
Requires-Dist: jsonlines
|
|
15
|
+
Requires-Dist: jsonschema
|
|
16
|
+
Requires-Dist: openai
|
|
17
|
+
Requires-Dist: pydantic>=2.3.0
|
|
18
|
+
Requires-Dist: pydantic-core==2.23.4
|
|
19
|
+
Requires-Dist: requests
|
|
20
|
+
Requires-Dist: tiktoken
|
|
21
|
+
Requires-Dist: pillow
|
|
22
|
+
Requires-Dist: dotenv
|
|
23
|
+
Requires-Dist: llama-cpp-python==0.3.16
|
|
24
|
+
Requires-Dist: wasmtime==41.0.0
|
|
25
|
+
Requires-Dist: loguru==0.7.3
|
|
26
|
+
Provides-Extra: rag
|
|
27
|
+
Requires-Dist: charset-normalizer; extra == "rag"
|
|
28
|
+
Requires-Dist: rank_bm25; extra == "rag"
|
|
29
|
+
Requires-Dist: jieba; extra == "rag"
|
|
30
|
+
Requires-Dist: snowballstemmer; extra == "rag"
|
|
31
|
+
Requires-Dist: beautifulsoup4; extra == "rag"
|
|
32
|
+
Requires-Dist: pdfminer.six; extra == "rag"
|
|
33
|
+
Requires-Dist: pdfplumber; extra == "rag"
|
|
34
|
+
Requires-Dist: python-docx; extra == "rag"
|
|
35
|
+
Requires-Dist: python-pptx; extra == "rag"
|
|
36
|
+
Requires-Dist: polars; extra == "rag"
|
|
37
|
+
Requires-Dist: xlsx2csv; extra == "rag"
|
|
38
|
+
Requires-Dist: fastexcel; extra == "rag"
|
|
39
|
+
Requires-Dist: pyarrow==17.0.0; extra == "rag"
|
|
40
|
+
Requires-Dist: tabulate; extra == "rag"
|
|
41
|
+
Requires-Dist: leann==0.3.6; extra == "rag"
|
|
42
|
+
Provides-Extra: mcp
|
|
43
|
+
Requires-Dist: mcp; extra == "mcp"
|
|
44
|
+
Provides-Extra: python-executor
|
|
45
|
+
Requires-Dist: pebble; extra == "python-executor"
|
|
46
|
+
Requires-Dist: multiprocess; extra == "python-executor"
|
|
47
|
+
Requires-Dist: timeout_decorator; extra == "python-executor"
|
|
48
|
+
Requires-Dist: python-dateutil; extra == "python-executor"
|
|
49
|
+
Requires-Dist: sympy; extra == "python-executor"
|
|
50
|
+
Requires-Dist: numpy; extra == "python-executor"
|
|
51
|
+
Requires-Dist: scipy; extra == "python-executor"
|
|
52
|
+
Provides-Extra: code-interpreter
|
|
53
|
+
Requires-Dist: anyio>=3.7.1; extra == "code-interpreter"
|
|
54
|
+
Requires-Dist: fastapi>=0.103.1; extra == "code-interpreter"
|
|
55
|
+
Requires-Dist: jupyter>=1.0.0; extra == "code-interpreter"
|
|
56
|
+
Requires-Dist: uvicorn>=0.23.2; extra == "code-interpreter"
|
|
57
|
+
Provides-Extra: test
|
|
58
|
+
Requires-Dist: pytest; extra == "test"
|
|
59
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
60
|
+
|
|
61
|
+
# Cat-Agent
|
|
62
|
+
|
|
63
|
+
<div align="center">
|
|
64
|
+
|
|
65
|
+
<img src="https://i.ibb.co/gZJj7LTC/Chat-GPT-Image-Feb-7-2026-02-04-10-PM-removebg-preview.png" width="120" alt="Cat-Agent" />
|
|
66
|
+
|
|
67
|
+
**Enhancing LLMs with Agent Workflows, RAG, Function Calling, and Code Interpreter.**
|
|
68
|
+
|
|
69
|
+
[](https://pypi.org/project/cat-agent/)
|
|
70
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
71
|
+
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Overview
|
|
77
|
+
|
|
78
|
+
**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.
|
|
79
|
+
|
|
80
|
+
### Features
|
|
81
|
+
|
|
82
|
+
- **Agent workflows** — `Agent`, `Assistant`, `ReActChat`, `FnCallAgent`, `DocQAAgent`, `GroupChat`, `Router`, and more
|
|
83
|
+
- **Function calling** — Native tool/function support for LLMs
|
|
84
|
+
- **RAG** — Retrieval-augmented generation with vector, keyword, and hybrid search
|
|
85
|
+
- **Code interpreter** — Safe Python execution via Docker or WASM sandbox (no Docker required)
|
|
86
|
+
- **Rich tool set** — Web search, doc parsing, image generation, MCP, storage, and extensible custom tools
|
|
87
|
+
- **Multiple LLM backends** — OpenAI-compatible APIs, LlamaCpp (+ vision), OpenVINO, Transformers
|
|
88
|
+
- **Structured logging** — Loguru-powered logging with coloured console, JSON, and file rotation support
|
|
89
|
+
|
|
90
|
+
## Installation
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pip install cat-agent
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Optional extras:**
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pip install cat-agent[rag] # RAG (retrieval, doc parsing, etc.)
|
|
100
|
+
pip install cat-agent[mcp] # MCP (Model Context Protocol)
|
|
101
|
+
pip install cat-agent[python_executor] # Python executor (math, sympy, etc.)
|
|
102
|
+
pip install cat-agent[code_interpreter] # Code interpreter server (Jupyter, FastAPI)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Logging
|
|
106
|
+
|
|
107
|
+
Cat-Agent uses [Loguru](https://github.com/Delgan/loguru) for structured, coloured logging. By default the logger is **silent** (library-friendly). Activate it with a single environment variable:
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
# Pretty coloured output
|
|
111
|
+
CAT_AGENT_LOG_LEVEL=INFO python my_script.py
|
|
112
|
+
|
|
113
|
+
# Full debug verbosity
|
|
114
|
+
CAT_AGENT_LOG_LEVEL=DEBUG python my_script.py
|
|
115
|
+
|
|
116
|
+
# Structured JSON logs (for log aggregation pipelines)
|
|
117
|
+
CAT_AGENT_LOG_LEVEL=INFO CAT_AGENT_LOG_FORMAT=json python my_script.py
|
|
118
|
+
|
|
119
|
+
# Also write to a rotating log file
|
|
120
|
+
CAT_AGENT_LOG_LEVEL=DEBUG CAT_AGENT_LOG_FILE=agent.log python my_script.py
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Or configure programmatically:
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from cat_agent.log import logger, setup_logger
|
|
127
|
+
|
|
128
|
+
setup_logger(level="DEBUG") # coloured stderr
|
|
129
|
+
setup_logger(level="INFO", log_file="/tmp/cat.log") # + rotating file
|
|
130
|
+
setup_logger(level="DEBUG", fmt="json") # structured JSON
|
|
131
|
+
|
|
132
|
+
logger.info("Agent started")
|
|
133
|
+
logger.debug("Processing query: {}", query)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
| Env Variable | Values | Default |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `CAT_AGENT_LOG_LEVEL` | `TRACE`, `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL` | *(silent)* |
|
|
139
|
+
| `CAT_AGENT_LOG_FILE` | file path | *(none)* |
|
|
140
|
+
| `CAT_AGENT_LOG_FORMAT` | `pretty`, `json` | `pretty` |
|
|
141
|
+
|
|
142
|
+
## Examples
|
|
143
|
+
|
|
144
|
+
### Math tool with LlamaCpp
|
|
145
|
+
|
|
146
|
+
Registers a custom `sum_two_number` tool and uses a local GGUF model:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
python examples/llama_cpp_math_guy/llama_cpp_example.py
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Math tool with Transformers
|
|
153
|
+
|
|
154
|
+
Same concept using the HuggingFace Transformers backend (Qwen3-1.7B):
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
python examples/transformers_math_guy/math_guy.py
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Vision with LlamaCpp
|
|
161
|
+
|
|
162
|
+
Analyse images from URLs using a multimodal GGUF model (Qwen2-VL):
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
python examples/llama_cpp_vision/llama_cpp_vision_example.py
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Document parsing agent
|
|
169
|
+
|
|
170
|
+
Parse CSV/PDF/DOCX files and ask questions about their contents:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
python examples/doc_parser_agent/doc_parser_example.py
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Multi-agent: GroupChat
|
|
177
|
+
|
|
178
|
+
Two agents (Alice and Bob) converse in round-robin to plan a weekend trip:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
python examples/multi_agent/group_chat_example.py
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Multi-agent: Router
|
|
185
|
+
|
|
186
|
+
Intelligently route queries to specialised agents (MathExpert vs GeneralAssistant):
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
python examples/multi_agent/router_example.py
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### RAG with LEANN retriever
|
|
193
|
+
|
|
194
|
+
Retrieval-augmented generation using LEANN semantic search:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
pip install cat-agent[rag]
|
|
198
|
+
python examples/rag_leann/leann_qwen3_demo.py
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Minimal RAG usage in code:
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
from pathlib import Path
|
|
205
|
+
from cat_agent.llm.schema import Message, USER
|
|
206
|
+
from cat_agent.memory import Memory
|
|
207
|
+
import torch
|
|
208
|
+
|
|
209
|
+
llm_cfg = {
|
|
210
|
+
"model": "Qwen/Qwen3-1.7B",
|
|
211
|
+
"model_type": "transformers",
|
|
212
|
+
"device": "cuda:0" if torch.cuda.is_available() else "cpu",
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
mem = Memory(llm=llm_cfg, files=["doc.txt"], rag_cfg={"enable_leann": True, "rag_searchers": ["leann_search"]})
|
|
216
|
+
messages = [Message(role=USER, content="How much storage does LEANN save?")]
|
|
217
|
+
responses = mem.run_nonstream(messages, force_search=True)
|
|
218
|
+
print(responses[-1].content)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### WASM code interpreter
|
|
222
|
+
|
|
223
|
+
Secure Python code execution in a WebAssembly sandbox (no Docker or Node.js needed):
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
python examples/wasm_code_interpreter/wasm_code_interpreter_example.py
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Logging demo
|
|
230
|
+
|
|
231
|
+
Demonstrates coloured console logs, JSON output, and file logging alongside an agent:
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
python examples/logging_demo/logging_example.py
|
|
235
|
+
|
|
236
|
+
# Or with env-var driven config:
|
|
237
|
+
CAT_AGENT_LOG_LEVEL=DEBUG python examples/logging_demo/logging_example.py
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## LLM Backends
|
|
241
|
+
|
|
242
|
+
| Backend | `model_type` | Description |
|
|
243
|
+
|---|---|---|
|
|
244
|
+
| OpenAI-compatible | `oai` | Any OpenAI-compatible API (default) |
|
|
245
|
+
| LlamaCpp | `llama_cpp` | Local GGUF models via llama-cpp-python |
|
|
246
|
+
| LlamaCpp Vision | `llama_cpp_vision` | Multimodal GGUF models (Qwen2-VL, LLaVA, etc.) |
|
|
247
|
+
| Transformers | `transformers` | HuggingFace Transformers models |
|
|
248
|
+
| OpenVINO | `openvino` | Optimised inference on Intel hardware |
|
|
249
|
+
|
|
250
|
+
```python
|
|
251
|
+
from cat_agent.agents import Assistant
|
|
252
|
+
|
|
253
|
+
bot = Assistant(
|
|
254
|
+
llm={"model_type": "llama_cpp", "repo_id": "Salesforce/xLAM-2-3b-fc-r-gguf", "filename": "xLAM-2-3B-fc-r-F16.gguf"},
|
|
255
|
+
name="MyAgent",
|
|
256
|
+
function_list=["my_tool"],
|
|
257
|
+
)
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Project Structure
|
|
261
|
+
|
|
262
|
+
| Component | Description |
|
|
263
|
+
|---|---|
|
|
264
|
+
| `cat_agent.agent` | Base `Agent` class |
|
|
265
|
+
| `cat_agent.agents` | Assistant, ReActChat, FnCallAgent, DocQA, GroupChat, Router |
|
|
266
|
+
| `cat_agent.llm` | Chat model backends (OAI, LlamaCpp, LlamaCpp Vision, OpenVINO, Transformers) |
|
|
267
|
+
| `cat_agent.tools` | CodeInterpreter, WASMCodeInterpreter, Retrieval, DocParser, Storage, MCP, and more |
|
|
268
|
+
| `cat_agent.memory` | Memory, RAG, and context utilities |
|
|
269
|
+
| `cat_agent.log` | Loguru-based structured logging |
|
|
270
|
+
| `cat_agent.settings` | Configuration via environment variables |
|
|
271
|
+
|
|
272
|
+
## Testing
|
|
273
|
+
|
|
274
|
+
- **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`, and `tests/test_utils.py`.
|
|
275
|
+
- **Test coverage:** **59%** (6,038 lines total).
|
|
276
|
+
- **Run tests:** `pytest` (install with `pip install -e ".[test]"`).
|
|
277
|
+
- **Report coverage:** `pytest --cov=cat_agent --cov-report=term`
|
|
278
|
+
|
|
279
|
+
## License
|
|
280
|
+
|
|
281
|
+
Licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
|
|
282
|
+
|
|
283
|
+
## Author
|
|
284
|
+
|
|
285
|
+
**Kemalcan Bora** — [kemalcanbora@gmail.com](mailto:kemalcanbora@gmail.com)
|
|
286
|
+
GitHub: [kemalcanbora/cat-agent](https://github.com/kemalcanbora/cat-agent)
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
# Cat-Agent
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
<img src="https://i.ibb.co/gZJj7LTC/Chat-GPT-Image-Feb-7-2026-02-04-10-PM-removebg-preview.png" width="120" alt="Cat-Agent" />
|
|
6
|
+
|
|
7
|
+
**Enhancing LLMs with Agent Workflows, RAG, Function Calling, and Code Interpreter.**
|
|
8
|
+
|
|
9
|
+
[](https://pypi.org/project/cat-agent/)
|
|
10
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Overview
|
|
17
|
+
|
|
18
|
+
**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.
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
- **Agent workflows** — `Agent`, `Assistant`, `ReActChat`, `FnCallAgent`, `DocQAAgent`, `GroupChat`, `Router`, and more
|
|
23
|
+
- **Function calling** — Native tool/function support for LLMs
|
|
24
|
+
- **RAG** — Retrieval-augmented generation with vector, keyword, and hybrid search
|
|
25
|
+
- **Code interpreter** — Safe Python execution via Docker or WASM sandbox (no Docker required)
|
|
26
|
+
- **Rich tool set** — Web search, doc parsing, image generation, MCP, storage, and extensible custom tools
|
|
27
|
+
- **Multiple LLM backends** — OpenAI-compatible APIs, LlamaCpp (+ vision), OpenVINO, Transformers
|
|
28
|
+
- **Structured logging** — Loguru-powered logging with coloured console, JSON, and file rotation support
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install cat-agent
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Optional extras:**
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
pip install cat-agent[rag] # RAG (retrieval, doc parsing, etc.)
|
|
40
|
+
pip install cat-agent[mcp] # MCP (Model Context Protocol)
|
|
41
|
+
pip install cat-agent[python_executor] # Python executor (math, sympy, etc.)
|
|
42
|
+
pip install cat-agent[code_interpreter] # Code interpreter server (Jupyter, FastAPI)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Logging
|
|
46
|
+
|
|
47
|
+
Cat-Agent uses [Loguru](https://github.com/Delgan/loguru) for structured, coloured logging. By default the logger is **silent** (library-friendly). Activate it with a single environment variable:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Pretty coloured output
|
|
51
|
+
CAT_AGENT_LOG_LEVEL=INFO python my_script.py
|
|
52
|
+
|
|
53
|
+
# Full debug verbosity
|
|
54
|
+
CAT_AGENT_LOG_LEVEL=DEBUG python my_script.py
|
|
55
|
+
|
|
56
|
+
# Structured JSON logs (for log aggregation pipelines)
|
|
57
|
+
CAT_AGENT_LOG_LEVEL=INFO CAT_AGENT_LOG_FORMAT=json python my_script.py
|
|
58
|
+
|
|
59
|
+
# Also write to a rotating log file
|
|
60
|
+
CAT_AGENT_LOG_LEVEL=DEBUG CAT_AGENT_LOG_FILE=agent.log python my_script.py
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Or configure programmatically:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from cat_agent.log import logger, setup_logger
|
|
67
|
+
|
|
68
|
+
setup_logger(level="DEBUG") # coloured stderr
|
|
69
|
+
setup_logger(level="INFO", log_file="/tmp/cat.log") # + rotating file
|
|
70
|
+
setup_logger(level="DEBUG", fmt="json") # structured JSON
|
|
71
|
+
|
|
72
|
+
logger.info("Agent started")
|
|
73
|
+
logger.debug("Processing query: {}", query)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
| Env Variable | Values | Default |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| `CAT_AGENT_LOG_LEVEL` | `TRACE`, `DEBUG`, `INFO`, `WARNING`, `ERROR`, `CRITICAL` | *(silent)* |
|
|
79
|
+
| `CAT_AGENT_LOG_FILE` | file path | *(none)* |
|
|
80
|
+
| `CAT_AGENT_LOG_FORMAT` | `pretty`, `json` | `pretty` |
|
|
81
|
+
|
|
82
|
+
## Examples
|
|
83
|
+
|
|
84
|
+
### Math tool with LlamaCpp
|
|
85
|
+
|
|
86
|
+
Registers a custom `sum_two_number` tool and uses a local GGUF model:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
python examples/llama_cpp_math_guy/llama_cpp_example.py
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Math tool with Transformers
|
|
93
|
+
|
|
94
|
+
Same concept using the HuggingFace Transformers backend (Qwen3-1.7B):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
python examples/transformers_math_guy/math_guy.py
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Vision with LlamaCpp
|
|
101
|
+
|
|
102
|
+
Analyse images from URLs using a multimodal GGUF model (Qwen2-VL):
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
python examples/llama_cpp_vision/llama_cpp_vision_example.py
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Document parsing agent
|
|
109
|
+
|
|
110
|
+
Parse CSV/PDF/DOCX files and ask questions about their contents:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
python examples/doc_parser_agent/doc_parser_example.py
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Multi-agent: GroupChat
|
|
117
|
+
|
|
118
|
+
Two agents (Alice and Bob) converse in round-robin to plan a weekend trip:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
python examples/multi_agent/group_chat_example.py
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Multi-agent: Router
|
|
125
|
+
|
|
126
|
+
Intelligently route queries to specialised agents (MathExpert vs GeneralAssistant):
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
python examples/multi_agent/router_example.py
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### RAG with LEANN retriever
|
|
133
|
+
|
|
134
|
+
Retrieval-augmented generation using LEANN semantic search:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
pip install cat-agent[rag]
|
|
138
|
+
python examples/rag_leann/leann_qwen3_demo.py
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Minimal RAG usage in code:
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from pathlib import Path
|
|
145
|
+
from cat_agent.llm.schema import Message, USER
|
|
146
|
+
from cat_agent.memory import Memory
|
|
147
|
+
import torch
|
|
148
|
+
|
|
149
|
+
llm_cfg = {
|
|
150
|
+
"model": "Qwen/Qwen3-1.7B",
|
|
151
|
+
"model_type": "transformers",
|
|
152
|
+
"device": "cuda:0" if torch.cuda.is_available() else "cpu",
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
mem = Memory(llm=llm_cfg, files=["doc.txt"], rag_cfg={"enable_leann": True, "rag_searchers": ["leann_search"]})
|
|
156
|
+
messages = [Message(role=USER, content="How much storage does LEANN save?")]
|
|
157
|
+
responses = mem.run_nonstream(messages, force_search=True)
|
|
158
|
+
print(responses[-1].content)
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### WASM code interpreter
|
|
162
|
+
|
|
163
|
+
Secure Python code execution in a WebAssembly sandbox (no Docker or Node.js needed):
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
python examples/wasm_code_interpreter/wasm_code_interpreter_example.py
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Logging demo
|
|
170
|
+
|
|
171
|
+
Demonstrates coloured console logs, JSON output, and file logging alongside an agent:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
python examples/logging_demo/logging_example.py
|
|
175
|
+
|
|
176
|
+
# Or with env-var driven config:
|
|
177
|
+
CAT_AGENT_LOG_LEVEL=DEBUG python examples/logging_demo/logging_example.py
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## LLM Backends
|
|
181
|
+
|
|
182
|
+
| Backend | `model_type` | Description |
|
|
183
|
+
|---|---|---|
|
|
184
|
+
| OpenAI-compatible | `oai` | Any OpenAI-compatible API (default) |
|
|
185
|
+
| LlamaCpp | `llama_cpp` | Local GGUF models via llama-cpp-python |
|
|
186
|
+
| LlamaCpp Vision | `llama_cpp_vision` | Multimodal GGUF models (Qwen2-VL, LLaVA, etc.) |
|
|
187
|
+
| Transformers | `transformers` | HuggingFace Transformers models |
|
|
188
|
+
| OpenVINO | `openvino` | Optimised inference on Intel hardware |
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
from cat_agent.agents import Assistant
|
|
192
|
+
|
|
193
|
+
bot = Assistant(
|
|
194
|
+
llm={"model_type": "llama_cpp", "repo_id": "Salesforce/xLAM-2-3b-fc-r-gguf", "filename": "xLAM-2-3B-fc-r-F16.gguf"},
|
|
195
|
+
name="MyAgent",
|
|
196
|
+
function_list=["my_tool"],
|
|
197
|
+
)
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
## Project Structure
|
|
201
|
+
|
|
202
|
+
| Component | Description |
|
|
203
|
+
|---|---|
|
|
204
|
+
| `cat_agent.agent` | Base `Agent` class |
|
|
205
|
+
| `cat_agent.agents` | Assistant, ReActChat, FnCallAgent, DocQA, GroupChat, Router |
|
|
206
|
+
| `cat_agent.llm` | Chat model backends (OAI, LlamaCpp, LlamaCpp Vision, OpenVINO, Transformers) |
|
|
207
|
+
| `cat_agent.tools` | CodeInterpreter, WASMCodeInterpreter, Retrieval, DocParser, Storage, MCP, and more |
|
|
208
|
+
| `cat_agent.memory` | Memory, RAG, and context utilities |
|
|
209
|
+
| `cat_agent.log` | Loguru-based structured logging |
|
|
210
|
+
| `cat_agent.settings` | Configuration via environment variables |
|
|
211
|
+
|
|
212
|
+
## Testing
|
|
213
|
+
|
|
214
|
+
- **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`, and `tests/test_utils.py`.
|
|
215
|
+
- **Test coverage:** **59%** (6,038 lines total).
|
|
216
|
+
- **Run tests:** `pytest` (install with `pip install -e ".[test]"`).
|
|
217
|
+
- **Report coverage:** `pytest --cov=cat_agent --cov-report=term`
|
|
218
|
+
|
|
219
|
+
## License
|
|
220
|
+
|
|
221
|
+
Licensed under the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0).
|
|
222
|
+
|
|
223
|
+
## Author
|
|
224
|
+
|
|
225
|
+
**Kemalcan Bora** — [kemalcanbora@gmail.com](mailto:kemalcanbora@gmail.com)
|
|
226
|
+
GitHub: [kemalcanbora/cat-agent](https://github.com/kemalcanbora/cat-agent)
|