quantalogic 0.2.19__tar.gz → 0.2.21__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.
Files changed (79) hide show
  1. quantalogic-0.2.21/PKG-INFO +517 -0
  2. quantalogic-0.2.21/README.md +465 -0
  3. {quantalogic-0.2.19 → quantalogic-0.2.21}/pyproject.toml +2 -1
  4. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/agent.py +26 -5
  5. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/agent_config.py +7 -4
  6. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/coding_agent.py +13 -0
  7. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/main.py +9 -6
  8. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/server/agent_server.py +1 -1
  9. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/__init__.py +3 -1
  10. quantalogic-0.2.21/quantalogic/tools/jinja_tool.py +91 -0
  11. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/llm_tool.py +5 -0
  12. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/search_definition_names.py +55 -4
  13. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/tool.py +113 -7
  14. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/utils/get_coding_environment.py +7 -2
  15. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/utils/git_ls.py +27 -6
  16. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/xml_tool_parser.py +4 -2
  17. quantalogic-0.2.19/PKG-INFO +0 -992
  18. quantalogic-0.2.19/README.md +0 -941
  19. {quantalogic-0.2.19 → quantalogic-0.2.21}/LICENSE +0 -0
  20. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/__init__.py +0 -0
  21. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/console_print_events.py +0 -0
  22. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/console_print_token.py +0 -0
  23. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/docs_cli.py +0 -0
  24. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/event_emitter.py +0 -0
  25. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/generative_model.py +0 -0
  26. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/interactive_text_editor.py +0 -0
  27. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/memory.py +0 -0
  28. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/model_names.py +0 -0
  29. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/prompts.py +0 -0
  30. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/search_agent.py +0 -0
  31. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/server/__init__.py +0 -0
  32. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/server/models.py +0 -0
  33. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/server/routes.py +0 -0
  34. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/server/state.py +0 -0
  35. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/server/static/js/event_visualizer.js +0 -0
  36. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/server/static/js/quantalogic.js +0 -0
  37. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/server/templates/index.html +0 -0
  38. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tool_manager.py +0 -0
  39. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/agent_tool.py +0 -0
  40. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/download_http_file_tool.py +0 -0
  41. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/duckduckgo_search_tool.py +0 -0
  42. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/edit_whole_content_tool.py +0 -0
  43. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/elixir_tool.py +0 -0
  44. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/execute_bash_command_tool.py +0 -0
  45. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/input_question_tool.py +0 -0
  46. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/language_handlers/__init__.py +0 -0
  47. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/language_handlers/c_handler.py +0 -0
  48. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/language_handlers/cpp_handler.py +0 -0
  49. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/language_handlers/go_handler.py +0 -0
  50. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/language_handlers/java_handler.py +0 -0
  51. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/language_handlers/javascript_handler.py +0 -0
  52. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/language_handlers/python_handler.py +0 -0
  53. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/language_handlers/rust_handler.py +0 -0
  54. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/language_handlers/scala_handler.py +0 -0
  55. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/language_handlers/typescript_handler.py +0 -0
  56. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/list_directory_tool.py +0 -0
  57. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/llm_vision_tool.py +0 -0
  58. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/markitdown_tool.py +0 -0
  59. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/nodejs_tool.py +0 -0
  60. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/python_tool.py +0 -0
  61. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/read_file_block_tool.py +0 -0
  62. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/read_file_tool.py +0 -0
  63. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/replace_in_file_tool.py +0 -0
  64. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/ripgrep_tool.py +0 -0
  65. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/serpapi_search_tool.py +0 -0
  66. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/task_complete_tool.py +0 -0
  67. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/unified_diff_tool.py +0 -0
  68. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/wikipedia_search_tool.py +0 -0
  69. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/tools/write_file_tool.py +0 -0
  70. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/utils/__init__.py +0 -0
  71. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/utils/ask_user_validation.py +0 -0
  72. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/utils/check_version.py +0 -0
  73. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/utils/download_http_file.py +0 -0
  74. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/utils/get_environment.py +0 -0
  75. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/utils/get_quantalogic_rules_content.py +0 -0
  76. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/utils/read_file.py +0 -0
  77. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/utils/read_http_text_content.py +0 -0
  78. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/version.py +0 -0
  79. {quantalogic-0.2.19 → quantalogic-0.2.21}/quantalogic/xml_parser.py +0 -0
@@ -0,0 +1,517 @@
1
+ Metadata-Version: 2.1
2
+ Name: quantalogic
3
+ Version: 0.2.21
4
+ Summary: QuantaLogic ReAct Agents
5
+ Author: Raphaël MANSUY
6
+ Author-email: raphael.mansuy@gmail.com
7
+ Requires-Python: >=3.12,<4.0
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.12
10
+ Classifier: Programming Language :: Python :: 3.13
11
+ Requires-Dist: boto3 (>=1.35.86,<2.0.0)
12
+ Requires-Dist: click (>=8.1.8,<9.0.0)
13
+ Requires-Dist: duckduckgo-search (>=7.2.1,<8.0.0)
14
+ Requires-Dist: fastapi (>=0.115.6,<0.116.0)
15
+ Requires-Dist: google-auth (>=2.20.0,<3.0.0)
16
+ Requires-Dist: google-search-results (>=2.4.2,<3.0.0)
17
+ Requires-Dist: jinja2 (>=3.1.5,<4.0.0)
18
+ Requires-Dist: litellm (>=1.56.4,<2.0.0)
19
+ Requires-Dist: llmlingua (>=0.2.2,<0.3.0)
20
+ Requires-Dist: loguru (>=0.7.3,<0.8.0)
21
+ Requires-Dist: markitdown (>=0.0.1a3,<0.0.2)
22
+ Requires-Dist: mkdocs-git-revision-date-localized-plugin (>=1.2.0,<2.0.0)
23
+ Requires-Dist: mkdocs-macros-plugin (>=1.0.4,<2.0.0)
24
+ Requires-Dist: mkdocs-material[imaging] (>=9.5.49,<10.0.0)
25
+ Requires-Dist: mkdocs-mermaid2-plugin (>=1.1.1,<2.0.0)
26
+ Requires-Dist: mkdocs-minify-plugin (>=0.7.1,<0.8.0)
27
+ Requires-Dist: mkdocstrings (>=0.24.0,<0.25.0)
28
+ Requires-Dist: mkdocstrings-python (>=1.7.0,<2.0.0)
29
+ Requires-Dist: pathspec (>=0.12.1,<0.13.0)
30
+ Requires-Dist: prompt-toolkit (>=3.0.48,<4.0.0)
31
+ Requires-Dist: pydantic (>=2.10.4,<3.0.0)
32
+ Requires-Dist: pymdown-extensions (>=10.3.1,<11.0.0)
33
+ Requires-Dist: rich (>=13.9.4,<14.0.0)
34
+ Requires-Dist: serpapi (>=0.1.5,<0.2.0)
35
+ Requires-Dist: tenacity (>=9.0.0,<10.0.0)
36
+ Requires-Dist: toml (>=0.10.2,<0.11.0)
37
+ Requires-Dist: tree-sitter (>=0.23.2,<0.24.0)
38
+ Requires-Dist: tree-sitter-c (>=0.23.4,<0.24.0)
39
+ Requires-Dist: tree-sitter-cpp (>=0.23.4,<0.24.0)
40
+ Requires-Dist: tree-sitter-go (>=0.23.4,<0.24.0)
41
+ Requires-Dist: tree-sitter-java (>=0.23.5,<0.24.0)
42
+ Requires-Dist: tree-sitter-javascript (>=0.23.1,<0.24.0)
43
+ Requires-Dist: tree-sitter-python (>=0.23.6,<0.24.0)
44
+ Requires-Dist: tree-sitter-rust (>=0.23.2,<0.24.0)
45
+ Requires-Dist: tree-sitter-scala (>=0.23.4,<0.24.0)
46
+ Requires-Dist: tree-sitter-typescript (>=0.23.2,<0.24.0)
47
+ Requires-Dist: types-requests (>=2.32.0.20241016,<3.0.0.0)
48
+ Requires-Dist: uvicorn (>=0.34.0,<0.35.0)
49
+ Requires-Dist: websocket (>=0.2.1,<0.3.0)
50
+ Description-Content-Type: text/markdown
51
+
52
+ # QuantaLogic
53
+
54
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
55
+ [![Python](https://img.shields.io/badge/Python-3.12+-blue.svg)](https://www.python.org/downloads/)
56
+ [![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://quantalogic.github.io/quantalogic/)
57
+
58
+
59
+ QuantaLogic is a ReAct (Reasoning & Action) framework for building advanced AI agents.
60
+
61
+ It seamlessly integrates large language models (LLMs) with a robust tool system, enabling agents to understand, reason about, and execute complex tasks through natural language interaction.
62
+
63
+ The `cli` version include coding capabilities comparable to Aider.
64
+
65
+ [📖 Documentation](https://quantalogic.github.io/quantalogic/)
66
+
67
+ ![Video](./examples/generated_tutorials/python/quantalogic_8s.gif)
68
+
69
+ [HowTo Guide](./docs/howto/howto.md)
70
+
71
+ ## Why QuantaLogic?
72
+
73
+ We created [QuantaLogic](https://www.quantalogic.app) because we saw a significant gap between the advanced AI models developed by companies like OpenAI, Anthropic, DeepSeek and their practical implementation in everyday business processes.
74
+
75
+ > Our mission is to bridge this gap, making the power of generative AI accessible and actionable for businesses of all sizes.
76
+
77
+
78
+ ## 🌟 Highlights
79
+
80
+ - **ReAct Framework**: Advanced implementation combining LLM reasoning with concrete actions
81
+ - **Universal LLM Support**: Integration with OpenAI, Anthropic, LM Studio, Bedrock, Ollama, DeepSeek V3, via LiteLLM
82
+ - **Secure Tool System**: Docker-based code execution and file manipulation tools
83
+ - **Real-time Monitoring**: Web interface with SSE-based event visualization
84
+ - **Memory Management**: Intelligent context handling and optimization
85
+ - **Enterprise Ready**: Comprehensive logging, error handling, and validation system
86
+
87
+ ## 📋 Table of Contents
88
+
89
+ - [Release Notes](#release-notes)
90
+
91
+ - [Installation](#-installation)
92
+ - [Quick Start](#-quickstart)
93
+ - [Key Components](#-key-components)
94
+ - [Agent System](#-agent-system)
95
+ - [Tool System](#-tool-system)
96
+ - [Web Interface](#-web-interface)
97
+ - [Examples](#-examples)
98
+ - [Development](#-development)
99
+ - [Contributing](#-contributing)
100
+ - [License](#-license)
101
+ - [Documentation Development](#-documentation-development)
102
+
103
+ ## Release Notes
104
+
105
+ See our [Release Notes](RELEASE_NOTES.MD) for detailed version history and changes.
106
+
107
+ [TODO List](TODO.md)
108
+
109
+ ## 📦 Installation
110
+
111
+ ### Prerequisites
112
+
113
+ - Python 3.12+
114
+ - Docker (optional for code execution tools)
115
+
116
+ ### Via pip
117
+
118
+ ```bash
119
+ # Basic installation
120
+ pip install quantalogic
121
+ ```
122
+
123
+ ### From Source
124
+
125
+ ```bash
126
+ git clone https://github.com/quantalogic/quantalogic.git
127
+ cd quantalogic
128
+ python -m venv .venv
129
+ source ./venv/bin/activate
130
+ poetry install
131
+ ```
132
+
133
+ ## Using pipx
134
+
135
+ ```
136
+ pipx install quantalogic
137
+ ```
138
+
139
+
140
+ ## 🚀 Quickstart
141
+
142
+ ### Basic Usage
143
+
144
+ ## 📖 CLI Reference
145
+
146
+ The QuantaLogic CLI provides powerful command-line capabilities:
147
+
148
+ ```bash
149
+ Usage: quantalogic [OPTIONS] COMMAND [ARGS]...
150
+ QuantaLogic AI Assistant - A powerful AI tool for various tasks.
151
+
152
+ Options:
153
+ --version Show version information.
154
+ --model-name TEXT Specify the model (litellm format, e.g., "openrouter/deepseek/deepseek-chat").
155
+ --log [info|debug|warning] Set logging level.
156
+ --verbose Enable verbose output.
157
+ --mode [code|basic|interpreter|full|code-basic|search|search-full] Agent mode.
158
+ --vision-model-name TEXT Specify the vision model (litellm format, e.g., "openrouter/A/gpt-4o-mini").
159
+ --max-iterations INTEGER Maximum iterations for task solving (default: 30).
160
+ --max-tokens-working-memory INTEGER Maximum tokens to keep in working memory (default: 4000).
161
+ --compact-every-n-iteration INTEGER Compact memory every N iterations (default: 5).
162
+ --help Show this message and exit.
163
+
164
+ Commands:
165
+ task Execute a task with the QuantaLogic AI Assistant.
166
+ ```
167
+
168
+ ### Commands
169
+ task Execute a task with the QuantaLogic AI Assistant
170
+
171
+ **Usage:** `quantalogic task [OPTIONS] [TASK]`
172
+ **Description:** Execute a task with the QuantaLogic AI Assistant.
173
+ **Options:**
174
+ - `--file PATH`: Path to task file.
175
+ - `--model-name TEXT`: Specify the model (litellm format, e.g., `openrouter/deepseek/deepseek-chat`).
176
+ - `--verbose`: Enable verbose output.
177
+ - `--mode [code|basic|interpreter|full|code-basic|search|search-full]`: Agent mode.
178
+ - `--log [info|debug|warning]`: Set logging level.
179
+ - `--vision-model-name TEXT`: Specify the vision model (litellm format).
180
+ - `--max-iterations INTEGER`: Maximum iterations for task solving (default: 30).
181
+ - `--max-tokens-working-memory INTEGER`: Maximum tokens to keep in working memory (default: 4000).
182
+ - `--compact-every-n-iteration INTEGER`: Compact memory every N iterations (default: 5).
183
+ - `--no-stream`: Disable streaming output (default: enabled).
184
+ - `--help`: Show this message and exit.
185
+
186
+ **Detailed Parameter Descriptions:**
187
+
188
+ - **--model-name**: Specifies the LLM model to use (e.g., "openrouter/deepseek/deepseek-chat")
189
+ - **--mode**: Selects agent capabilities:
190
+ - *code*: Coding-focused with basic capabilities
191
+ - *basic*: General-purpose without coding tools
192
+ - *interpreter*: Interactive code execution
193
+ - *full*: All capabilities enabled
194
+ - *code-basic*: Coding with basic reasoning
195
+ - *search*: Web search integration
196
+ - **--log**: Controls logging verbosity (info, debug, warning)
197
+ - **--vision-model-name**: Specifies vision model for image processing
198
+ - **--max-iterations**: Limits task-solving attempts (default: 30)
199
+ - **--max-tokens-working-memory**: Controls memory usage (default: None)
200
+ - **--compact-every-n-iteration**: Memory optimization frequency (default: None)
201
+ - **--no-stream**: Disables real-time output streaming
202
+
203
+
204
+
205
+ ### Detailed Usage
206
+
207
+ #### Agent Modes
208
+ - code: Coding-focused agent with basic capabilities
209
+ - basic: General-purpose agent without coding tools
210
+ - interpreter: Interactive code execution agent
211
+ - full: Full-featured agent with all capabilities
212
+ - code-basic: Coding agent with basic reasoning
213
+ - search: Web search agent with Wikipedia, DuckDuckGo and SERPApi integration
214
+
215
+ #### Task Execution
216
+
217
+ Tasks can be provided:
218
+
219
+ 1. Directly via `task` parameter
220
+ 2. Through a file using --file parameter
221
+ 3. Interactively via standard input
222
+
223
+
224
+ #### Examples
225
+
226
+
227
+ Using a task file:
228
+ ```bash
229
+ quantalogic task --file tasks/example.md --verbose
230
+ ```
231
+
232
+ Selecting agent mode:
233
+ ```bash
234
+ quantalogic --mode interpreter task "Explain quantum computing"
235
+ ```
236
+
237
+ Interactive mode:
238
+ ```bash
239
+ quantalogic
240
+ ```
241
+
242
+ ### Using QuantaLogic With code
243
+
244
+ ```python
245
+ from quantalogic import Agent
246
+
247
+ # Initialize agent with default configuration
248
+ agent = Agent(model_name="deepseek/deepseek-chat")
249
+
250
+ # Execute a task
251
+ result = agent.solve_task(
252
+ "Create a Python function that calculates the Fibonacci sequence"
253
+ )
254
+ print(result)
255
+ ```
256
+
257
+ ### Environment Configuration Example
258
+
259
+ ```python
260
+ import os
261
+
262
+ from quantalogic import Agent
263
+
264
+ # Verify that DEEPSEEK_API_KEY is set
265
+ if not os.environ.get("DEEPSEEK_API_KEY"):
266
+ raise ValueError("DEEPSEEK_API_KEY environment variable is not set")
267
+
268
+ # Initialize the AI agent with default configuration
269
+ agent = Agent(model_name="deepseek/deepseek-chat")
270
+
271
+ # Execute a sample task
272
+ result = agent.solve_task("Create a Python function that calculates the Fibonacci sequence")
273
+ print(result)
274
+ ```
275
+
276
+ ## 📖 Examples
277
+
278
+ Watch how QuantaLogic can generate complete tutorials from simple prompts:
279
+
280
+ [![Tutorial Generation Demo](./examples/generated_tutorials/python/quantalogic_long.mp4)](./examples/generated_tutorials/python/quantalogic_long.mp4)
281
+
282
+ Example prompt: [04-write-a-tutorial.md](./examples/tasks/04-write-a-tutorial.md)
283
+
284
+ Here are some practical examples to help you get started:
285
+
286
+ Here is the markdown table based on the provided directory listing:
287
+
288
+ | Example | Description | File |
289
+ |---------|-------------|------|
290
+ | Simple Agent | A basic example of an agent implementation. | [examples/01-simple-agent.py](examples/01-simple-agent.py) |
291
+ | Agent with Event Monitoring | An example of an agent with event monitoring capabilities. | [examples/02-agent-with-event-monitoring.py](examples/02-agent-with-event-monitoring.py) |
292
+ | Agent with Interpreter | An example of an agent that includes an interpreter. | [examples/03-agent-with-interpreter.py](examples/03-agent-with-interpreter.py) |
293
+ | Agent Summary Task | An example of an agent performing a summary task. | [examples/04-agent-summary-task.py](examples/04-agent-summary-task.py) |
294
+ | Code Example | A general code example. | [examples/05-code.py](examples/05-code.py) |
295
+
296
+
297
+ ## 🔨 Key Components
298
+
299
+ ### Agent System
300
+
301
+ The core agent implements the `ReAct`paradigm, combining:
302
+
303
+ - Language model reasoning
304
+ - Tool execution capabilities
305
+ - Memory management
306
+ - Event handling
307
+ - Task validation
308
+
309
+ ```python
310
+ from quantalogic import Agent
311
+ from quantalogic.tools import PythonTool, ReadFileTool
312
+
313
+ # Create agent with specific tools
314
+ agent = Agent(
315
+ model_name="openrouter/deepseek/deepseek-chat",
316
+ tools=[
317
+ PythonTool(),
318
+ ReadFileTool()
319
+ ]
320
+ )
321
+
322
+ ```
323
+
324
+ ### How it works
325
+
326
+
327
+ The ReAct (Reasoning & Action) framework represents a significant advancement in the development of intelligent agents capable of autonomously reasoning through tasks and taking appropriate actions.
328
+
329
+ QuantaLogic implements this framework, allowing integration with large language models (LLMs) to construct sophisticated agents that can tackle complex problems through natural language interaction.
330
+
331
+ ## What is a ReAct Agent?
332
+
333
+ ### Basic Concept
334
+
335
+ A ReAct agent utilizes the synergy of reasoning and action. It not only processes natural language inputs but also executes actions in response to these inputs, utilizing various available tools. This functionality is particularly beneficial for environments where complex tasks can be decomposed into manageable subtasks.
336
+
337
+ ### The QuantaLogic Implementation
338
+
339
+ QuantaLogic provides an effective implementation of the ReAct framework with several core components:
340
+
341
+ - **Generative Model**: This serves as the agent's brain, enabling it to interpret tasks and generate human-like text responses.
342
+ - **Memory Management**: This capability allows the agent to maintain context, keeping track of previous inputs and interactions to provide coherent responses.
343
+ - **Tool Management**: The agent has access to a diverse range of tools, enabling it to perform actions such as code execution, file manipulation, and API communication.
344
+
345
+ ## How the ReAct Framework Works
346
+
347
+ ### Workflow of a ReAct Agent
348
+
349
+ The following state diagram shows the core workflow of a QuantaLogic agent:
350
+
351
+ ```mermaid
352
+ stateDiagram-v2
353
+ [*] --> InitializeAgent
354
+ InitializeAgent --> Idle: Agent Initialized
355
+
356
+ state Idle {
357
+ [*] --> WaitForTask
358
+ WaitForTask --> SolveTask: Task Received
359
+ }
360
+
361
+ state SolveTask {
362
+ [*] --> ResetSession
363
+ ResetSession --> AddSystemPrompt
364
+ AddSystemPrompt --> PreparePrompt
365
+ PreparePrompt --> EmitTaskStartEvent
366
+ EmitTaskStartEvent --> UpdateTokens
367
+ UpdateTokens --> CompactMemoryIfNeeded
368
+ CompactMemoryIfNeeded --> GenerateResponse
369
+ GenerateResponse --> ObserveResponse
370
+ ObserveResponse --> CheckToolExecution
371
+ CheckToolExecution --> TaskComplete: Tool Executed (task_complete)
372
+ CheckToolExecution --> UpdatePrompt: Tool Not Executed
373
+ UpdatePrompt --> UpdateTokens
374
+ TaskComplete --> EmitTaskCompleteEvent
375
+ EmitTaskCompleteEvent --> [*]
376
+ }
377
+
378
+ state CompactMemoryIfNeeded {
379
+ [*] --> CheckMemoryOccupancy
380
+ CheckMemoryOccupancy --> CompactMemory: Memory Occupancy > MAX_OCCUPANCY
381
+ CheckMemoryOccupancy --> [*]: Memory Occupancy <= MAX_OCCUPANCY
382
+ CompactMemory --> [*]
383
+ }
384
+
385
+ state ObserveResponse {
386
+ [*] --> ProcessResponse
387
+ ProcessResponse --> ExecuteTool: Tool Identified
388
+ ProcessResponse --> UpdateAnswer: No Tool Identified
389
+ ExecuteTool --> UpdateAnswer
390
+ UpdateAnswer --> [*]
391
+ }
392
+
393
+
394
+
395
+ Idle --> [*]: Task Completed
396
+ SolveTask --> Idle: Task Completed
397
+ ```
398
+
399
+ The following sequence diagram illustrates the workflow of a ReAct agent as it processes and solves a task:
400
+
401
+ ```mermaid
402
+ sequenceDiagram
403
+ participant User
404
+ participant Agent
405
+ participant ToolManager
406
+ participant Memory
407
+
408
+ User->>Agent: Submit task
409
+ Agent->>Memory: Store task details
410
+ Agent->>ToolManager: Retrieve tools
411
+ ToolManager-->>Agent: Provide available tools
412
+ Agent->>Agent: Prepare prompt for task
413
+ Agent->>Agent: Analyze input and generate response
414
+ Agent->>ToolManager: Execute required tool
415
+ ToolManager-->>Agent: Return tool execution result
416
+ Agent->>User: Present final result
417
+ ```
418
+
419
+ ### Key Components Explained
420
+
421
+ 1. **User Input**: The agent begins by receiving a task or question from the user, which initiates the interaction.
422
+ 2. **Memory Management**: Before tackling the task, the agent logs relevant task details into its memory, ensuring it has the necessary context for processing.
423
+ 3. **Tool Retrieval**: The agent communicates with the ToolManager to inquire about available tools that can facilitate the required actions.
424
+ 4. **Prompt Generation**: The agent constructs a prompt that outlines the task specifics, available tools, and any other pertinent context information.
425
+ 5. **Analysis and Response Generation**: The agent uses its generative model to analyze the task input and formulate a response.
426
+ 6. **Tool Execution**: If certain tools are needed for the task, the agent instructs the ToolManager to execute those tools, fetching the results for processing.
427
+ 7. **Output to User**: Finally, the agent compiles and presents the results back to the user.
428
+
429
+ ### Tool System
430
+
431
+ The QuantaLogic framework incorporates a well-defined tool system that enhances the functionality of AI agents by enabling them to perform a variety of tasks efficiently. Each tool is designed to address specific needs that arise in the context of complex problem-solving and task execution:
432
+
433
+ 1. **Core Functionality**: Tools such as **AgentTool** and **LLMTool** are fundamental to the agent's operation, allowing it to manage tasks and interact with large language models. The integration of these tools enables the agent to process natural language inputs and execute corresponding actions effectively. **AgentTool** enables the agent to delegate tasks to specialized agents, and **LLMTool** provides the agent to explore a specific area of a latent space using role play.
434
+
435
+ 2. **Code Execution**: Tools like **PythonTool**, **NodeJsTool**, and **ElixirTool** are vital for executing code in different programming languages. This capability allows the agent to handle programming tasks directly, facilitating real-time coding assistance and code evaluation.
436
+
437
+ 3. **File Operations**: The framework includes tools for file management, such as **ReadFileTool**, **WriteFileTool**, and **ReplaceInFileTool**. These tools are essential for enabling the agent to read from and write to files, as well as update file content dynamically. This functionality supports scenarios where agents need to manipulate data or configuration files as part of the task execution process.
438
+
439
+ 4. **Search Capabilities**: Tools like **RipgrepTool** and **SearchDefinitionNames** enhance the agent's ability to search through codebases and identify relevant definitions. This is crucial when dealing with large volumes of code, allowing the agent to quickly locate information necessary for problem-solving.
440
+
441
+ 5. **Utility Functions**: Additional tools such as **DownloadHttpFileTool**, **ListDirectoryTool**, and **ExecuteBashCommandTool** provide broader functionality that supports various tasks, from fetching external resources to executing system commands. These utilities expand the operational scope of agents, allowing them to perform diverse actions beyond simple text processing.
442
+
443
+ 6. **Documentation and Representation**: Tools like **MarkitdownTool** facilitate the generation of documentation, ensuring that output from the agent can be formatted and presented clearly. This is particularly beneficial for creating reports or guides based on the agent's findings and actions.
444
+
445
+ By integrating these tools into its architecture, QuantaLogic allows agents to perform a wide range of tasks autonomously while ensuring that they have the necessary resources and capabilities to do so effectively. This tool system is fundamental to the agent's ability to reason and act in sophisticated ways, thereby enhancing the overall utility of the framework in complex scenarios.
446
+
447
+
448
+
449
+ ### Development
450
+
451
+ ### Tools Documentation
452
+
453
+ For detailed documentation of all available tools, please see [REFERENCE_TOOLS.md](REFERENCE_TOOLS.md).
454
+ ## 🔧 Development
455
+ ### Setup Development Environment
456
+
457
+ ```bash
458
+ # Clone repository
459
+ git clone https://github.com/quantalogic/quantalogic.git
460
+ cd quantalogic
461
+
462
+ # Create virtual environment
463
+ python -m venv venv
464
+ source venv/bin/activate # Windows: venv\Scripts\activate
465
+
466
+ # Install dependencies
467
+ poetry install
468
+
469
+ ```
470
+
471
+ ### Run Tests
472
+
473
+ ```bash
474
+ # Run all tests
475
+ pytest
476
+
477
+ # With coverage
478
+ pytest --cov=quantalogic
479
+
480
+ # Run specific tests
481
+ pytest tests/unit
482
+ ```
483
+
484
+ ### Code Quality
485
+
486
+ ```bash
487
+ # Format code
488
+ ruff format
489
+
490
+ # Type checking
491
+ mypy quantalogic
492
+
493
+ # Linting
494
+ ruff check quantalogic
495
+ ```
496
+
497
+ ## 🤝 Contributing
498
+
499
+ 1. Fork the repository
500
+ 2. Create a feature branch
501
+ 3. Write tests
502
+ 4. Implement changes
503
+ 5. Submit pull request
504
+
505
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
506
+
507
+ ## 📄 License
508
+
509
+ Copyright 2024 QuantaLogic Contributors
510
+
511
+ Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.
512
+
513
+ ## Project Growth
514
+ [![Star History Chart](https://api.star-history.com/svg?repos=quantalogic/quantalogic&type=Date)](https://star-history.com/#quantalogic/quantalogic&Date)
515
+
516
+ Initiated with ❤️ by Raphaël MANSUY. Founder of [Quantalogic](https://www.quantalogic.app).
517
+