quantalogic 0.2.18__py3-none-any.whl → 0.2.20__py3-none-any.whl

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.
@@ -1,984 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: quantalogic
3
- Version: 0.2.18
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: litellm (>=1.56.4,<2.0.0)
18
- Requires-Dist: llmlingua (>=0.2.2,<0.3.0)
19
- Requires-Dist: loguru (>=0.7.3,<0.8.0)
20
- Requires-Dist: markitdown (>=0.0.1a3,<0.0.2)
21
- Requires-Dist: mkdocs-git-revision-date-localized-plugin (>=1.2.0,<2.0.0)
22
- Requires-Dist: mkdocs-macros-plugin (>=1.0.4,<2.0.0)
23
- Requires-Dist: mkdocs-material[imaging] (>=9.5.49,<10.0.0)
24
- Requires-Dist: mkdocs-mermaid2-plugin (>=1.1.1,<2.0.0)
25
- Requires-Dist: mkdocs-minify-plugin (>=0.7.1,<0.8.0)
26
- Requires-Dist: mkdocstrings (>=0.24.0,<0.25.0)
27
- Requires-Dist: mkdocstrings-python (>=1.7.0,<2.0.0)
28
- Requires-Dist: pathspec (>=0.12.1,<0.13.0)
29
- Requires-Dist: prompt-toolkit (>=3.0.48,<4.0.0)
30
- Requires-Dist: pydantic (>=2.10.4,<3.0.0)
31
- Requires-Dist: pymdown-extensions (>=10.3.1,<11.0.0)
32
- Requires-Dist: rich (>=13.9.4,<14.0.0)
33
- Requires-Dist: serpapi (>=0.1.5,<0.2.0)
34
- Requires-Dist: tenacity (>=9.0.0,<10.0.0)
35
- Requires-Dist: toml (>=0.10.2,<0.11.0)
36
- Requires-Dist: tree-sitter (>=0.23.2,<0.24.0)
37
- Requires-Dist: tree-sitter-c (>=0.23.4,<0.24.0)
38
- Requires-Dist: tree-sitter-cpp (>=0.23.4,<0.24.0)
39
- Requires-Dist: tree-sitter-go (>=0.23.4,<0.24.0)
40
- Requires-Dist: tree-sitter-java (>=0.23.5,<0.24.0)
41
- Requires-Dist: tree-sitter-javascript (>=0.23.1,<0.24.0)
42
- Requires-Dist: tree-sitter-python (>=0.23.6,<0.24.0)
43
- Requires-Dist: tree-sitter-rust (>=0.23.2,<0.24.0)
44
- Requires-Dist: tree-sitter-scala (>=0.23.4,<0.24.0)
45
- Requires-Dist: tree-sitter-typescript (>=0.23.2,<0.24.0)
46
- Requires-Dist: types-requests (>=2.32.0.20241016,<3.0.0.0)
47
- Requires-Dist: uvicorn (>=0.34.0,<0.35.0)
48
- Requires-Dist: websocket (>=0.2.1,<0.3.0)
49
- Description-Content-Type: text/markdown
50
-
51
- # QuantaLogic
52
-
53
- [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
54
- [![Python](https://img.shields.io/badge/Python-3.12+-blue.svg)](https://www.python.org/downloads/)
55
- [![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://quantalogic.github.io/quantalogic/)
56
-
57
- QuantaLogic is a ReAct (Reasoning & Action) framework for building advanced AI agents.
58
-
59
- 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.
60
-
61
- The `cli` version include coding capabilities comparable to Aider.
62
-
63
- [📖 Documentation](https://quantalogic.github.io/quantalogic/)
64
-
65
-
66
- ## Why QuantaLogic?
67
-
68
- 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.
69
-
70
- > Our mission is to bridge this gap, making the power of generative AI accessible and actionable for businesses of all sizes.
71
-
72
-
73
- ## 🌟 Highlights
74
-
75
- - **ReAct Framework**: Advanced implementation combining LLM reasoning with concrete actions
76
- - **Universal LLM Support**: Integration with OpenAI, Anthropic, LM Studio, Bedrock, Ollama, DeepSeek V3, via LiteLLM
77
- - **Secure Tool System**: Docker-based code execution and file manipulation tools
78
- - **Real-time Monitoring**: Web interface with SSE-based event visualization
79
- - **Memory Management**: Intelligent context handling and optimization
80
- - **Enterprise Ready**: Comprehensive logging, error handling, and validation system
81
-
82
- ## 📋 Table of Contents
83
-
84
- - [Release Notes](#release-notes)
85
-
86
- - [Installation](#-installation)
87
- - [Quick Start](#-quickstart)
88
- - [Key Components](#-key-components)
89
- - [Agent System](#-agent-system)
90
- - [Tool System](#-tool-system)
91
- - [Web Interface](#-web-interface)
92
- - [Examples](#-examples)
93
- - [Development](#-development)
94
- - [Contributing](#-contributing)
95
- - [License](#-license)
96
- - [Documentation Development](#-documentation-development)
97
-
98
- ## Release Notes
99
-
100
- See our [Release Notes](RELEASE_NOTES.MD) for detailed version history and changes.
101
-
102
- [TODO List](TODO.md)
103
-
104
- ## 📦 Installation
105
-
106
- ### Prerequisites
107
-
108
- - Python 3.12+
109
- - Docker (optional for code execution tools)
110
-
111
- ### Via pip
112
-
113
- ```bash
114
- # Basic installation
115
- pip install quantalogic
116
- ```
117
-
118
- ### From Source
119
-
120
- ```bash
121
- git clone https://github.com/quantalogic/quantalogic.git
122
- cd quantalogic
123
- python -m venv .venv
124
- source ./venv/bin/activate
125
- poetry install
126
- ```
127
-
128
- ## Using pipx
129
-
130
- ```
131
- pipx install quantalogic
132
- ```
133
-
134
-
135
- ## 🚀 Quickstart
136
-
137
- ### Basic Usage
138
-
139
- ## 📖 CLI Reference
140
-
141
- The QuantaLogic CLI provides powerful command-line capabilities:
142
-
143
- ```bash
144
- Usage: quantalogic [OPTIONS] COMMAND [ARGS]...
145
- QuantaLogic AI Assistant - A powerful AI tool for various tasks.
146
-
147
- Options:
148
- --version Show version information.
149
- --model-name TEXT Specify the model (litellm format, e.g., "openrouter/deepseek/deepseek-chat").
150
- --log [info|debug|warning] Set logging level.
151
- --verbose Enable verbose output.
152
- --mode [code|basic|interpreter|full|code-basic|search|search-full] Agent mode.
153
- --vision-model-name TEXT Specify the vision model (litellm format, e.g., "openrouter/A/gpt-4o-mini").
154
- --max-iterations INTEGER Maximum iterations for task solving (default: 30).
155
- --max-tokens-working-memory INTEGER Maximum tokens to keep in working memory (default: 4000).
156
- --compact-every-n-iteration INTEGER Compact memory every N iterations (default: 5).
157
- --help Show this message and exit.
158
-
159
- Commands:
160
- task Execute a task with the QuantaLogic AI Assistant.
161
- ```
162
-
163
- ### Commands
164
- task Execute a task with the QuantaLogic AI Assistant
165
-
166
- **Usage:** `quantalogic task [OPTIONS] [TASK]`
167
- **Description:** Execute a task with the QuantaLogic AI Assistant.
168
- **Options:**
169
- - `--file PATH`: Path to task file.
170
- - `--model-name TEXT`: Specify the model (litellm format, e.g., `openrouter/deepseek/deepseek-chat`).
171
- - `--verbose`: Enable verbose output.
172
- - `--mode [code|basic|interpreter|full|code-basic|search|search-full]`: Agent mode.
173
- - `--log [info|debug|warning]`: Set logging level.
174
- - `--vision-model-name TEXT`: Specify the vision model (litellm format).
175
- - `--max-iterations INTEGER`: Maximum iterations for task solving (default: 30).
176
- - `--max-tokens-working-memory INTEGER`: Maximum tokens to keep in working memory (default: 4000).
177
- - `--compact-every-n-iteration INTEGER`: Compact memory every N iterations (default: 5).
178
- - `--no-stream`: Disable streaming output (default: enabled).
179
- - `--help`: Show this message and exit.
180
-
181
- **Detailed Parameter Descriptions:**
182
-
183
- - **--model-name**: Specifies the LLM model to use (e.g., "openrouter/deepseek/deepseek-chat")
184
- - **--mode**: Selects agent capabilities:
185
- - *code*: Coding-focused with basic capabilities
186
- - *basic*: General-purpose without coding tools
187
- - *interpreter*: Interactive code execution
188
- - *full*: All capabilities enabled
189
- - *code-basic*: Coding with basic reasoning
190
- - *search*: Web search integration
191
- - **--log**: Controls logging verbosity (info, debug, warning)
192
- - **--vision-model-name**: Specifies vision model for image processing
193
- - **--max-iterations**: Limits task-solving attempts (default: 30)
194
- - **--max-tokens-working-memory**: Controls memory usage (default: None)
195
- - **--compact-every-n-iteration**: Memory optimization frequency (default: None)
196
- - **--no-stream**: Disables real-time output streaming
197
-
198
-
199
-
200
- ### Detailed Usage
201
-
202
- #### Agent Modes
203
- - code: Coding-focused agent with basic capabilities
204
- - basic: General-purpose agent without coding tools
205
- - interpreter: Interactive code execution agent
206
- - full: Full-featured agent with all capabilities
207
- - code-basic: Coding agent with basic reasoning
208
- - search: Web search agent with Wikipedia, DuckDuckGo and SERPApi integration
209
-
210
- #### Task Execution
211
-
212
- Tasks can be provided:
213
-
214
- 1. Directly via `task` parameter
215
- 2. Through a file using --file parameter
216
- 3. Interactively via standard input
217
-
218
-
219
- #### Examples
220
-
221
-
222
- Using a task file:
223
- ```bash
224
- quantalogic task --file tasks/example.md --verbose
225
- ```
226
-
227
- Selecting agent mode:
228
- ```bash
229
- quantalogic --mode interpreter task "Explain quantum computing"
230
- ```
231
-
232
- Interactive mode:
233
- ```bash
234
- quantalogic
235
- ```
236
-
237
- ### Using QuantaLogic With code
238
-
239
- ```python
240
- from quantalogic import Agent
241
-
242
- # Initialize agent with default configuration
243
- agent = Agent(model_name="deepseek/deepseek-chat")
244
-
245
- # Execute a task
246
- result = agent.solve_task(
247
- "Create a Python function that calculates the Fibonacci sequence"
248
- )
249
- print(result)
250
- ```
251
-
252
- ### Environment Configuration Example
253
-
254
- ```python
255
- import os
256
-
257
- from quantalogic import Agent
258
-
259
- # Verify that DEEPSEEK_API_KEY is set
260
- if not os.environ.get("DEEPSEEK_API_KEY"):
261
- raise ValueError("DEEPSEEK_API_KEY environment variable is not set")
262
-
263
- # Initialize the AI agent with default configuration
264
- agent = Agent(model_name="deepseek/deepseek-chat")
265
-
266
- # Execute a sample task
267
- result = agent.solve_task("Create a Python function that calculates the Fibonacci sequence")
268
- print(result)
269
- ```
270
-
271
- ## 📖 Examples
272
-
273
- Here are some practical examples to help you get started:
274
-
275
- Here is the markdown table based on the provided directory listing:
276
-
277
- | Example | Description | File |
278
- |---------|-------------|------|
279
- | Simple Agent | A basic example of an agent implementation. | [examples/01-simple-agent.py](examples/01-simple-agent.py) |
280
- | 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) |
281
- | Agent with Interpreter | An example of an agent that includes an interpreter. | [examples/03-agent-with-interpreter.py](examples/03-agent-with-interpreter.py) |
282
- | Agent Summary Task | An example of an agent performing a summary task. | [examples/04-agent-summary-task.py](examples/04-agent-summary-task.py) |
283
- | Code Example | A general code example. | [examples/05-code.py](examples/05-code.py) |
284
-
285
-
286
- ## 🔨 Key Components
287
-
288
- ### Agent System
289
-
290
- The core agent implements the `ReAct`paradigm, combining:
291
-
292
- - Language model reasoning
293
- - Tool execution capabilities
294
- - Memory management
295
- - Event handling
296
- - Task validation
297
-
298
- ```python
299
- from quantalogic import Agent
300
- from quantalogic.tools import PythonTool, ReadFileTool
301
-
302
- # Create agent with specific tools
303
- agent = Agent(
304
- model_name="openrouter/deepseek/deepseek-chat",
305
- tools=[
306
- PythonTool(),
307
- ReadFileTool()
308
- ]
309
- )
310
-
311
- ```
312
-
313
- ### How it works
314
-
315
-
316
- 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.
317
-
318
- QuantaLogic implements this framework, allowing integration with large language models (LLMs) to construct sophisticated agents that can tackle complex problems through natural language interaction.
319
-
320
- ## What is a ReAct Agent?
321
-
322
- ### Basic Concept
323
-
324
- 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.
325
-
326
- ### The QuantaLogic Implementation
327
-
328
- QuantaLogic provides an effective implementation of the ReAct framework with several core components:
329
-
330
- - **Generative Model**: This serves as the agent's brain, enabling it to interpret tasks and generate human-like text responses.
331
- - **Memory Management**: This capability allows the agent to maintain context, keeping track of previous inputs and interactions to provide coherent responses.
332
- - **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.
333
-
334
- ## How the ReAct Framework Works
335
-
336
- ### Workflow of a ReAct Agent
337
-
338
- The following state diagram shows the core workflow of a QuantaLogic agent:
339
-
340
- ```mermaid
341
- stateDiagram-v2
342
- [*] --> InitializeAgent
343
- InitializeAgent --> Idle: Agent Initialized
344
-
345
- state Idle {
346
- [*] --> WaitForTask
347
- WaitForTask --> SolveTask: Task Received
348
- }
349
-
350
- state SolveTask {
351
- [*] --> ResetSession
352
- ResetSession --> AddSystemPrompt
353
- AddSystemPrompt --> PreparePrompt
354
- PreparePrompt --> EmitTaskStartEvent
355
- EmitTaskStartEvent --> UpdateTokens
356
- UpdateTokens --> CompactMemoryIfNeeded
357
- CompactMemoryIfNeeded --> GenerateResponse
358
- GenerateResponse --> ObserveResponse
359
- ObserveResponse --> CheckToolExecution
360
- CheckToolExecution --> TaskComplete: Tool Executed (task_complete)
361
- CheckToolExecution --> UpdatePrompt: Tool Not Executed
362
- UpdatePrompt --> UpdateTokens
363
- TaskComplete --> EmitTaskCompleteEvent
364
- EmitTaskCompleteEvent --> [*]
365
- }
366
-
367
- state CompactMemoryIfNeeded {
368
- [*] --> CheckMemoryOccupancy
369
- CheckMemoryOccupancy --> CompactMemory: Memory Occupancy > MAX_OCCUPANCY
370
- CheckMemoryOccupancy --> [*]: Memory Occupancy <= MAX_OCCUPANCY
371
- CompactMemory --> [*]
372
- }
373
-
374
- state ObserveResponse {
375
- [*] --> ProcessResponse
376
- ProcessResponse --> ExecuteTool: Tool Identified
377
- ProcessResponse --> UpdateAnswer: No Tool Identified
378
- ExecuteTool --> UpdateAnswer
379
- UpdateAnswer --> [*]
380
- }
381
-
382
-
383
-
384
- Idle --> [*]: Task Completed
385
- SolveTask --> Idle: Task Completed
386
- ```
387
-
388
- The following sequence diagram illustrates the workflow of a ReAct agent as it processes and solves a task:
389
-
390
- ```mermaid
391
- sequenceDiagram
392
- participant User
393
- participant Agent
394
- participant ToolManager
395
- participant Memory
396
-
397
- User->>Agent: Submit task
398
- Agent->>Memory: Store task details
399
- Agent->>ToolManager: Retrieve tools
400
- ToolManager-->>Agent: Provide available tools
401
- Agent->>Agent: Prepare prompt for task
402
- Agent->>Agent: Analyze input and generate response
403
- Agent->>ToolManager: Execute required tool
404
- ToolManager-->>Agent: Return tool execution result
405
- Agent->>User: Present final result
406
- ```
407
-
408
- ### Key Components Explained
409
-
410
- 1. **User Input**: The agent begins by receiving a task or question from the user, which initiates the interaction.
411
- 2. **Memory Management**: Before tackling the task, the agent logs relevant task details into its memory, ensuring it has the necessary context for processing.
412
- 3. **Tool Retrieval**: The agent communicates with the ToolManager to inquire about available tools that can facilitate the required actions.
413
- 4. **Prompt Generation**: The agent constructs a prompt that outlines the task specifics, available tools, and any other pertinent context information.
414
- 5. **Analysis and Response Generation**: The agent uses its generative model to analyze the task input and formulate a response.
415
- 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.
416
- 7. **Output to User**: Finally, the agent compiles and presents the results back to the user.
417
-
418
- ### Tool System
419
-
420
- 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:
421
-
422
- 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.
423
-
424
- 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.
425
-
426
- 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.
427
-
428
- 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.
429
-
430
- 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.
431
-
432
- 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.
433
-
434
- 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.
435
-
436
-
437
-
438
- ### Tools Documentation
439
-
440
-
441
-
442
- #### Overview of Tools
443
-
444
- | Category | Tools |
445
- |-----------------------|---------------------------------------------------------------------------------------------------|
446
- | 1. Search Tools | 1.1 SerpAPI Search Tool, 1.2 Wikipedia Search Tool |
447
- | 2. Task Automation | Agent Tool, Task Complete Tool, Input Question Tool, Execute Bash Command Tool |
448
- | 3. Script Execution | Python Tool, Node.js Tool, Elixir Tool |
449
- | 4. File Operations | Read File Tool, Write File Tool, Edit Whole Content Tool, Replace In File Tool |
450
- | 5. Code Analysis | Search Definition Names Tool, Ripgrep Tool |
451
- | 6. Content Generation | LLM Tool, LLMVisionTool |
452
- | 7. Utility & Management| Download HTTP File Tool, List Directory Tool, Markitdown Tool, Unified Diff Tool |
453
-
454
- ---
455
-
456
- #### 1. Agent Tool
457
-
458
- The **Agent Tool** enables task delegation to another agent, providing specialized functionality for handling tasks.
459
-
460
- ##### Parameters
461
-
462
- | Parameter | Type | Description | Example |
463
- |--------------|--------|-------------------------------------------------------------------------------------|---------------------------------|
464
- | `agent_role` | string | The role of the agent (e.g., expert, assistant) | `expert` |
465
- | `agent` | Any | The agent to delegate tasks to | `Agent` object |
466
- | `task` | string | The task to delegate to the specified agent. | `Summarize the latest news.` |
467
-
468
- ##### Example Usage
469
- ```python
470
- agent_tool = AgentTool(agent_role="expert", agent=some_agent)
471
- result = agent_tool.execute(task="Summarize the latest news.")
472
- print(result)
473
- ```
474
-
475
- ---
476
-
477
- #### 2. Task Complete Tool
478
-
479
- The **Task Complete Tool** is used to respond to users after a task has been completed.
480
-
481
- ##### Parameters
482
-
483
- | Parameter | Type | Description | Example |
484
- |-----------|--------|-------------------------------------------------|--------------------------------------|
485
- | `answer` | string | The answer to the user. | `"The answer to the meaning of life"`|
486
-
487
- ##### Example Usage
488
- ```python
489
- task_tool = TaskCompleteTool()
490
- response = task_tool.execute(answer="The answer is 42.")
491
- print(response)
492
- ```
493
-
494
- ---
495
-
496
- #### 3. Input Question Tool
497
-
498
- The **Input Question Tool** prompts the user with a question and captures their input.
499
-
500
- ##### Parameters
501
-
502
- | Parameter | Type | Description | Example |
503
- |-----------|--------|-----------------------------------------------------|-------------------------------|
504
- | `question`| string | The question to ask the user. | `What is your favorite color?`|
505
- | `default` | string | Optional default value if no input is provided. | `blue` |
506
-
507
- ##### Example Usage
508
- ```python
509
- input_tool = InputQuestionTool()
510
- user_response = input_tool.execute(question="What is your favorite color?", default="blue")
511
- print("User Response:", user_response)
512
- ```
513
-
514
- ---
515
-
516
- #### 4. Execute Bash Command Tool
517
-
518
- The **Execute Bash Command Tool** allows for the execution of bash commands and captures their output.
519
-
520
- ##### Parameters
521
-
522
- | Parameter | Type | Description | Example |
523
- |-----------------|---------|----------------------------------------------------------------------|---------------------------|
524
- | `command` | string | The bash command to execute. | `ls -la` |
525
- | `working_dir` | string | The working directory where the command will be executed. | `/path/to/directory` |
526
- | `timeout` | int | Maximum time in seconds to wait for the command to complete. | `60` |
527
-
528
- ##### Example Usage
529
- ```python
530
- bash_tool = ExecuteBashCommandTool()
531
- output = bash_tool.execute(command="ls -la")
532
- print(output)
533
- ```
534
-
535
- ---
536
-
537
- #### 5. Python Tool
538
-
539
- The **Python Tool** executes Python scripts in an isolated Docker environment.
540
-
541
- ##### Parameters
542
-
543
- | Parameter | Type | Description | Example |
544
- |-------------------|---------|------------------------------------------------------------------------------------|--------------------------------------------|
545
- | `install_commands` | string | Commands to install Python packages before running the script. | `pip install rich requests` |
546
- | `script` | string | The Python script to execute. | `print("Hello, World!")` |
547
- | `version` | string | The Python version to use in the Docker container. | `3.11` |
548
- | `host_dir` | string | The absolute path on the host machine to mount for file access. | `./demo01/` |
549
- | `memory_limit` | string | Optional memory limit for the Docker container. | `1g` |
550
- | `environment_vars`| string | Environment variables to set inside the Docker container. | `ENV=production DEBUG=False` |
551
-
552
- #### Example Usage
553
- ```python
554
- python_tool = PythonTool()
555
- output = python_tool.execute(
556
- install_commands="pip install rich requests",
557
- script='print("Hello, World!")',
558
- version="3.12",
559
- host_dir="./demo01/",
560
- )
561
- print("Script Output:", output)
562
- ```
563
-
564
- ---
565
-
566
- ### 6. Node.js Tool
567
-
568
- The **Node.js Tool** executes Node.js scripts in an isolated Docker environment.
569
-
570
- #### Parameters
571
-
572
- | Parameter | Type | Description | Example |
573
- |-------------------|---------|-------------------------------------------------------------------------------|--------------------------------------------|
574
- | `install_commands`| string | Commands to install Node.js packages before running the script. | `npm install chalk` |
575
- | `script` | string | The Node.js script to execute. | `console.log('Hello, World!');` |
576
- | `version` | string | The Node.js version to use in the Docker container. | `20` |
577
- | `host_dir` | string | The absolute path on the host machine to mount for file access. | `./project/` |
578
- | `memory_limit` | string | Optional memory limit for the Docker container. | `1g` |
579
- | `module_type` | string | The module system to use: 'esm' for ECMAScript Modules or 'commonjs' for CommonJS. | `esm` |
580
-
581
- #### Example Usage
582
- ```python
583
- node_tool = NodeJsTool()
584
- output = node_tool.execute(
585
- install_commands="npm install chalk",
586
- script='console.log("Hello, Node.js World!");',
587
- version="20",
588
- host_dir="./project/"
589
- )
590
- print("Node.js Output:", output)
591
- ```
592
-
593
- ---
594
-
595
- ### 7. Elixir Tool
596
-
597
- The **Elixir Tool** executes Elixir code in an isolated Docker environment with Mix support.
598
-
599
- #### Parameters
600
-
601
- | Parameter | Type | Description | Example |
602
- |------------------|---------|-----------------------------------------------------------------------------|-------------------------------------------|
603
- | `mix_commands` | string | Mix commands to run before executing the script. | `mix deps.get && mix compile` |
604
- | `script` | string | Elixir code to execute. | `IO.puts("Hello from Elixir!")` |
605
- | `version` | string | The Elixir version to use. | `1.15` |
606
- | `host_dir` | string | Host directory to mount. | `./elixir_project/` |
607
- | `memory_limit` | string | Container memory limit. | `512m` |
608
- | `environment_vars`| string | Environment variables to set. | `MIX_ENV=prod` |
609
-
610
- #### Example Usage
611
- ```python
612
- elixir_tool = ElixirTool()
613
- output = elixir_tool.execute(script='IO.puts("Hello from Elixir!")')
614
- print("Elixir Output:", output)
615
- ```
616
-
617
- ---
618
-
619
- ### 8. Read File Tool
620
-
621
- The **Read File Tool** reads content from a specified file.
622
-
623
- #### Parameters
624
-
625
- | Parameter | Type | Description | Example |
626
- |--------------|--------|-------------------------------------------------|--------------------------------------|
627
- | `file_path` | string | The path of the file to read. | `/path/to/file.txt` |
628
-
629
- #### Example Usage
630
- ```python
631
- read_tool = ReadFileTool()
632
- content = read_tool.execute(file_path="/path/to/file.txt")
633
- print("File Content:", content)
634
- ```
635
-
636
- ---
637
-
638
- ### 9. Write File Tool
639
-
640
- The **Write File Tool** writes content to a specified file.
641
-
642
- #### Parameters
643
-
644
- | Parameter | Type | Description | Example |
645
- |-------------|--------|-------------------------------------------------|--------------------------------------|
646
- | `file_path` | string | The path of the file to write to. | `/path/to/file.txt` |
647
- | `content` | string | The content to write. | `Hello, World!` |
648
-
649
- #### Example Usage
650
- ```python
651
- write_tool = WriteFileTool()
652
- result = write_tool.execute(file_path="/path/to/file.txt", content="Hello, World!")
653
- print(result)
654
- ```
655
-
656
- ---
657
-
658
- ### 10. Edit Whole Content Tool
659
-
660
- The **Edit Whole Content Tool** replaces the entire content of a specified file.
661
-
662
- #### Parameters
663
-
664
- | Parameter | Type | Description | Example |
665
- |-------------|--------|-------------------------------------------------|--------------------------------------|
666
- | `file_path` | string | The path to the file to edit. | `/path/to/file.txt` |
667
- | `content` | string | The new content to write to the file. | `New Content Here!` |
668
-
669
- #### Example Usage
670
- ```python
671
- edit_tool = EditWholeContentTool()
672
- result = edit_tool.execute(file_path="/path/to/file.txt", content="New Content Here!")
673
- print(result)
674
- ```
675
-
676
- ---
677
-
678
- ### 11. Replace In File Tool
679
-
680
- The **Replace In File Tool** replaces specific content in a file with new content.
681
-
682
- #### Parameters
683
-
684
- | Parameter | Type | Description | Example |
685
- |-------------|--------|-------------------------------------------------|--------------------------------------|
686
- | `file_path` | string | The path of the file to edit. | `/path/to/file.txt` |
687
- | `search` | string | The string to search for in the file. | `Old Content` |
688
- | `replace` | string | The string to replace the searched content. | `New Content` |
689
-
690
- #### Example Usage
691
- ```python
692
- replace_tool = ReplaceInFileTool()
693
- result = replace_tool.execute(file_path="/path/to/file.txt", search="Old Content", replace="New Content")
694
- print(result)
695
- ```
696
-
697
- ---
698
-
699
- ### 12. Search Definition Names Tool
700
-
701
- The **Search Definition Names Tool** searches for definition names in a directory using Tree-sitter.
702
-
703
- #### Parameters
704
-
705
- | Parameter | Type | Description | Example |
706
- |----------------|--------|-----------------------------------------------------------|-------------------------------|
707
- | `directory_path`| string | The path to the directory to search in. | `./path/to` |
708
- | `language_name`| string | The Tree-sitter language name (python, js, etc.). | `python` |
709
- | `file_pattern` | string | Optional glob pattern to filter files (default: '*'). | `**/*.py` |
710
-
711
- #### Example Usage
712
- ```python
713
- search_tool = SearchDefinitionNames()
714
- results = search_tool.execute(directory_path="./my_project", language_name="python", file_pattern="**/*.py")
715
- print("Found Definitions:", results)
716
- ```
717
-
718
- ---
719
-
720
- ### 13. Ripgrep Tool
721
-
722
- The **Ripgrep Tool** searches for text blocks in files using ripgrep.
723
-
724
- #### Parameters
725
-
726
- | Parameter | Type | Description | Example |
727
- |------------------|---------|------------------------------------------------------------------------------|-------------------------------|
728
- | `cwd` | string | Base path for relative searches | `.` |
729
- | `directory_path` | string | The directory path to search in. | `./src` |
730
- | `regex_rust_syntax`| string| The regex pattern to search for (in Rust syntax). | `r"\bfunction\b"` |
731
- | `file_pattern` | string | Optional glob pattern to filter files. | `**/*.js` |
732
- | `context_lines` | string | Number of context lines to include before and after matches. | `2` |
733
-
734
- #### Example Usage
735
- ```python
736
- ripgrep_tool = RipgrepTool()
737
- output = ripgrep_tool.execute(
738
- directory_path="./my_project",
739
- regex_rust_syntax=r"\bfunction\b",
740
- context_lines="2"
741
- )
742
- print("Ripgrep Results:", output)
743
- ```
744
-
745
- ---
746
-
747
- #### 14. LLMVisionTool
748
-
749
- The **LLMVisionTool** enables processing of visual inputs using vision-language models.
750
-
751
- ##### Parameters
752
-
753
- | Parameter | Type | Description | Example |
754
- |----------------|---------|------------------------------------------------------------------------|--------------------------------------------|
755
- | `image_path` | string | Path to the image file to process | `./path/to/image.png` |
756
- | `prompt` | string | The question or instruction for the vision model | `Describe the contents of this image` |
757
- | `temperature` | float | Sampling temperature between 0.0 and 1.0 | `0.7` |
758
-
759
- ##### Example Usage
760
- ```python
761
- vision_tool = LLMVisionTool()
762
- response = vision_tool.execute(
763
- image_path="./path/to/image.png",
764
- prompt="Describe the contents of this image",
765
- temperature=0.7
766
- )
767
- print("Vision Model Response:", response)
768
- ```
769
-
770
- #### 15. LLM Tool
771
-
772
- The **LLM Tool** generates answers using a specified language model.
773
-
774
- #### Parameters
775
-
776
- | Parameter | Type | Description | Example |
777
- |----------------|---------|------------------------------------------------------------------------|--------------------------------------------|
778
- | `system_prompt`| string | The persona or system prompt to guide the language model's behavior. | `You are a helpful assistant.` |
779
- | `prompt` | string | The question to ask the language model. | `What is the meaning of life?` |
780
- | `temperature` | string | Sampling temperature between 0.0 and 1.0. | `0.5` |
781
-
782
- #### Example Usage
783
- ```python
784
- llm_tool = LLMTool(model_name="gpt-4")
785
- response = llm_tool.execute(
786
- system_prompt="You are a knowledgeable assistant.",
787
- prompt="What is the meaning of life?",
788
- temperature="0.7"
789
- )
790
- print("LLM Response:", response)
791
- ```
792
-
793
- ---
794
-
795
- ### 16. Download HTTP File Tool
796
-
797
- The **Download HTTP File Tool** downloads a file from a specified HTTP URL.
798
-
799
- #### Parameters
800
-
801
- | Parameter | Type | Description | Example |
802
- |---------------|--------|------------------------------------------------|------------------------------------|
803
- | `url` | string | The URL of the file to download. | `http://example.com/file.txt` |
804
- | `destination` | string | The path where the file should be saved. | `/path/to/save/file.txt` |
805
-
806
- #### Example Usage
807
- ```python
808
- download_tool = DownloadHttpFileTool()
809
- result = download_tool.execute(url="http://example.com/file.txt", destination="/path/to/save/file.txt")
810
- print(result)
811
- ```
812
-
813
- ---
814
-
815
- ### 17. List Directory Tool
816
-
817
- The **List Directory Tool** lists files in a specified directory.
818
-
819
- #### Parameters
820
-
821
- | Parameter | Type | Description | Example |
822
- |------------------|---------|------------------------------------------------|------------------------|
823
- | `directory_path` | string | The path of the directory to list files from. | `./path/to/directory` |
824
-
825
- #### Example Usage
826
- ```python
827
- list_tool = ListDirectoryTool()
828
- result = list_tool.execute(directory_path="./path/to/directory")
829
- print("Directory Files:", result)
830
- ```
831
-
832
- ---
833
-
834
- ### 18. Markitdown Tool
835
-
836
- The **Markitdown Tool** processes markdown files, possibly for conversion or rendering.
837
-
838
- #### Parameters
839
-
840
- | Parameter | Type | Description | Example |
841
- |------------------|---------|------------------------------------------------|------------------------|
842
- | `markdown_path` | string | The path of the markdown file to process. | `./path/to/file.md` |
843
-
844
- #### Example Usage
845
- ```python
846
- markitdown_tool = MarkitdownTool()
847
- result = markitdown_tool.execute(markdown_path="./path/to/file.md")
848
- print("Processed Markdown Output:", result)
849
- ```
850
-
851
- ---
852
-
853
- ### 19. SerpAPI Search Tool
854
-
855
- The **SerpAPI Search Tool** allows agents to perform web searches using the SerpAPI service.
856
-
857
- ##### Parameters
858
- | Parameter | Type | Description | Example |
859
- |-----------|--------|---------------------------------|-----------------------------|
860
- | query | string | The search query to execute | "latest AI research papers" |
861
- | location | string | Geographic location for results | "United States" |
862
- | num | int | Number of results to return | 5 |
863
-
864
- ##### Example Usage
865
- ```python
866
- from quantalogic.tools import SerpAPISearchTool
867
-
868
- search_tool = SerpAPISearchTool()
869
- results = search_tool.execute(query="latest AI research", location="United States", num=5)
870
- print(results)
871
- ```
872
-
873
- ---
874
-
875
- ### 20. Wikipedia Search Tool
876
-
877
- The **Wikipedia Search Tool** enables agents to search and retrieve information from Wikipedia.
878
-
879
- ##### Parameters
880
-
881
- | Parameter | Type | Description | Example |
882
- |-----------|--------|---------------------------------|-----------------------------|
883
- | query | string | The search query to execute | "Artificial Intelligence" |
884
- | lang | string | Language code for results | "en" |
885
- | sentences | int | Number of summary sentences | 3 |
886
-
887
- ##### Example Usage
888
- ```python
889
- from quantalogic.tools import WikipediaSearchTool
890
-
891
- wiki_tool = WikipediaSearchTool()
892
- results = wiki_tool.execute(query="Artificial Intelligence", lang="en", sentences=3)
893
- print(results)
894
- ```
895
- ```
896
-
897
- ```
898
- ### Project Documentation
899
-
900
- ```python
901
- from quantalogic import Agent
902
- from quantalogic.tools import MarkitdownTool, ReadFileTool
903
-
904
- agent = Agent(
905
- model_name="openrouter/deepseek/deepseek-chat",
906
- tools=[MarkitdownTool(), ReadFileTool()]
907
- )
908
-
909
- result = agent.solve_task("""
910
- Generate a comprehensive documentation for:
911
-
912
- 1. Navigate and Read https://api.nasa.gov/ documentation
913
- 2. Write an API reference for https://api.nasa.gov/
914
- 2. Examples how to use the API using curl
915
- 3. Examples how to use the API from Python
916
- """)
917
- ```
918
-
919
-
920
- ## 🔧 Development
921
-
922
- ### Setup Development Environment
923
-
924
- ```bash
925
- # Clone repository
926
- git clone https://github.com/quantalogic/quantalogic.git
927
- cd quantalogic
928
-
929
- # Create virtual environment
930
- python -m venv venv
931
- source venv/bin/activate # Windows: venv\Scripts\activate
932
-
933
- # Install dependencies
934
- poetry install
935
-
936
- ```
937
-
938
- ### Run Tests
939
-
940
- ```bash
941
- # Run all tests
942
- pytest
943
-
944
- # With coverage
945
- pytest --cov=quantalogic
946
-
947
- # Run specific tests
948
- pytest tests/unit
949
- ```
950
-
951
- ### Code Quality
952
-
953
- ```bash
954
- # Format code
955
- ruff format
956
-
957
- # Type checking
958
- mypy quantalogic
959
-
960
- # Linting
961
- ruff check quantalogic
962
- ```
963
-
964
- ## 🤝 Contributing
965
-
966
- 1. Fork the repository
967
- 2. Create a feature branch
968
- 3. Write tests
969
- 4. Implement changes
970
- 5. Submit pull request
971
-
972
- See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed guidelines.
973
-
974
- ## 📄 License
975
-
976
- Copyright 2024 QuantaLogic Contributors
977
-
978
- Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for details.
979
-
980
- ## Project Growth
981
- [![Star History Chart](https://api.star-history.com/svg?repos=quantalogic/quantalogic&type=Date)](https://star-history.com/#quantalogic/quantalogic&Date)
982
-
983
- Initiated with ❤️ by Raphaël MANSUY. Founder of [Quantalogic](https://www.quantalogic.app).
984
-