quantalogic 0.2.8__tar.gz → 0.2.12__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.
- {quantalogic-0.2.8 → quantalogic-0.2.12}/PKG-INFO +33 -27
- {quantalogic-0.2.8 → quantalogic-0.2.12}/README.md +31 -26
- {quantalogic-0.2.8 → quantalogic-0.2.12}/pyproject.toml +2 -1
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/agent.py +34 -3
- quantalogic-0.2.12/quantalogic/agent_config.py +169 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/coding_agent.py +7 -2
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/generative_model.py +62 -12
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/main.py +108 -25
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/print_event.py +3 -1
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/prompts.py +12 -19
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/server/agent_server.py +13 -13
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/server/state.py +5 -5
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tool_manager.py +4 -4
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/__init__.py +2 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/agent_tool.py +1 -1
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/elixir_tool.py +1 -1
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/llm_tool.py +14 -5
- quantalogic-0.2.12/quantalogic/tools/llm_vision_tool.py +127 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/nodejs_tool.py +2 -2
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/python_tool.py +2 -2
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/replace_in_file_tool.py +3 -3
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/ripgrep_tool.py +3 -3
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/tool.py +3 -3
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/unified_diff_tool.py +1 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/write_file_tool.py +1 -0
- quantalogic-0.2.12/quantalogic/utils/check_version.py +37 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/utils/download_http_file.py +4 -4
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/utils/read_http_text_content.py +2 -2
- quantalogic-0.2.12/quantalogic/version.py +5 -0
- quantalogic-0.2.8/quantalogic/agent_config.py +0 -136
- quantalogic-0.2.8/quantalogic/version.py +0 -4
- {quantalogic-0.2.8 → quantalogic-0.2.12}/LICENSE +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/__init__.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/event_emitter.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/interactive_text_editor.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/memory.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/model_names.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/server/__init__.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/server/models.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/server/routes.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/server/static/js/event_visualizer.js +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/server/static/js/quantalogic.js +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/server/templates/index.html +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/download_http_file_tool.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/edit_whole_content_tool.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/execute_bash_command_tool.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/input_question_tool.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/language_handlers/__init__.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/language_handlers/c_handler.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/language_handlers/cpp_handler.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/language_handlers/go_handler.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/language_handlers/java_handler.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/language_handlers/javascript_handler.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/language_handlers/python_handler.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/language_handlers/rust_handler.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/language_handlers/scala_handler.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/language_handlers/typescript_handler.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/list_directory_tool.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/markitdown_tool.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/read_file_block_tool.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/read_file_tool.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/search_definition_names.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/tools/task_complete_tool.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/utils/__init__.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/utils/ask_user_validation.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/utils/get_coding_environment.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/utils/get_environment.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/utils/get_quantalogic_rules_content.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/utils/git_ls.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/utils/read_file.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/xml_parser.py +0 -0
- {quantalogic-0.2.8 → quantalogic-0.2.12}/quantalogic/xml_tool_parser.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: quantalogic
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.12
|
4
4
|
Summary: QuantaLogic ReAct Agents
|
5
5
|
Author: Raphaël MANSUY
|
6
6
|
Author-email: raphael.mansuy@gmail.com
|
@@ -31,6 +31,7 @@ Requires-Dist: tree-sitter-python (>=0.23.6,<0.24.0)
|
|
31
31
|
Requires-Dist: tree-sitter-rust (>=0.23.2,<0.24.0)
|
32
32
|
Requires-Dist: tree-sitter-scala (>=0.23.4,<0.24.0)
|
33
33
|
Requires-Dist: tree-sitter-typescript (>=0.23.2,<0.24.0)
|
34
|
+
Requires-Dist: types-requests (>=2.32.0.20241016,<3.0.0.0)
|
34
35
|
Requires-Dist: uvicorn (>=0.34.0,<0.35.0)
|
35
36
|
Requires-Dist: websocket (>=0.2.1,<0.3.0)
|
36
37
|
Description-Content-Type: text/markdown
|
@@ -123,8 +124,10 @@ Usage: quantalogic [OPTIONS] COMMAND [ARGS]...
|
|
123
124
|
|
124
125
|
Options:
|
125
126
|
--version Show version information.
|
126
|
-
--model-name TEXT Specify the model to use (litellm format,
|
127
|
+
--model-name TEXT Specify the text model to use (litellm format,
|
127
128
|
e.g. "openrouter/deepseek-chat").
|
129
|
+
--vision-model-name TEXT Specify the vision model to use (litellm format,
|
130
|
+
e.g. "openrouter/A/gpt-4o-mini").
|
128
131
|
--log [info|debug|warning] Set logging level (info/debug/warning).
|
129
132
|
--verbose Enable verbose output.
|
130
133
|
--mode [code|basic|interpreter|full|code-basic]
|
@@ -385,7 +388,7 @@ By integrating these tools into its architecture, QuantaLogic allows agents to p
|
|
385
388
|
| Script Execution | Python Tool, Node.js Tool, Elixir Tool |
|
386
389
|
| File Operations | Read File Tool, Write File Tool, Edit Whole Content Tool, Replace In File Tool |
|
387
390
|
| Code Analysis | Search Definition Names Tool, Ripgrep Tool |
|
388
|
-
| Content Generation | LLM Tool
|
391
|
+
| Content Generation | LLM Tool, LLMVisionTool |
|
389
392
|
| Utility and Management | Download HTTP File Tool, List Directory Tool, Markitdown Tool, Unified Diff Tool |
|
390
393
|
|
391
394
|
---
|
@@ -681,7 +684,30 @@ print("Ripgrep Results:", output)
|
|
681
684
|
|
682
685
|
---
|
683
686
|
|
684
|
-
|
687
|
+
#### 14. LLMVisionTool
|
688
|
+
|
689
|
+
The **LLMVisionTool** enables processing of visual inputs using vision-language models.
|
690
|
+
|
691
|
+
##### Parameters
|
692
|
+
|
693
|
+
| Parameter | Type | Description | Example |
|
694
|
+
|----------------|---------|------------------------------------------------------------------------|--------------------------------------------|
|
695
|
+
| `image_path` | string | Path to the image file to process | `./path/to/image.png` |
|
696
|
+
| `prompt` | string | The question or instruction for the vision model | `Describe the contents of this image` |
|
697
|
+
| `temperature` | float | Sampling temperature between 0.0 and 1.0 | `0.7` |
|
698
|
+
|
699
|
+
##### Example Usage
|
700
|
+
```python
|
701
|
+
vision_tool = LLMVisionTool()
|
702
|
+
response = vision_tool.execute(
|
703
|
+
image_path="./path/to/image.png",
|
704
|
+
prompt="Describe the contents of this image",
|
705
|
+
temperature=0.7
|
706
|
+
)
|
707
|
+
print("Vision Model Response:", response)
|
708
|
+
```
|
709
|
+
|
710
|
+
#### 15. LLM Tool
|
685
711
|
|
686
712
|
The **LLM Tool** generates answers using a specified language model.
|
687
713
|
|
@@ -706,7 +732,7 @@ print("LLM Response:", response)
|
|
706
732
|
|
707
733
|
---
|
708
734
|
|
709
|
-
###
|
735
|
+
### 16. Download HTTP File Tool
|
710
736
|
|
711
737
|
The **Download HTTP File Tool** downloads a file from a specified HTTP URL.
|
712
738
|
|
@@ -726,7 +752,7 @@ print(result)
|
|
726
752
|
|
727
753
|
---
|
728
754
|
|
729
|
-
###
|
755
|
+
### 17. List Directory Tool
|
730
756
|
|
731
757
|
The **List Directory Tool** lists files in a specified directory.
|
732
758
|
|
@@ -745,7 +771,7 @@ print("Directory Files:", result)
|
|
745
771
|
|
746
772
|
---
|
747
773
|
|
748
|
-
###
|
774
|
+
### 18. Markitdown Tool
|
749
775
|
|
750
776
|
The **Markitdown Tool** processes markdown files, possibly for conversion or rendering.
|
751
777
|
|
@@ -762,26 +788,6 @@ result = markitdown_tool.execute(markdown_path="./path/to/file.md")
|
|
762
788
|
print("Processed Markdown Output:", result)
|
763
789
|
```
|
764
790
|
|
765
|
-
---
|
766
|
-
|
767
|
-
### 18. Unified Diff Tool
|
768
|
-
|
769
|
-
The **Unified Diff Tool** generates a unified diff between two texts or files.
|
770
|
-
|
771
|
-
#### Parameters
|
772
|
-
|
773
|
-
| Parameter | Type | Description | Example |
|
774
|
-
|--------------|--------|------------------------------------------------|------------------------|
|
775
|
-
| `original` | string | The original content or file path. | `old_text.txt` |
|
776
|
-
| `updated` | string | The updated content or file path. | `new_text.txt` |
|
777
|
-
|
778
|
-
#### Example Usage
|
779
|
-
```python
|
780
|
-
diff_tool = UnifiedDiffTool()
|
781
|
-
result = diff_tool.execute(original="old_text.txt", updated="new_text.txt")
|
782
|
-
print("Unified Diff Output:", result)
|
783
|
-
```
|
784
|
-
|
785
791
|
|
786
792
|
#### Creating Custom Tools
|
787
793
|
|
@@ -86,8 +86,10 @@ Usage: quantalogic [OPTIONS] COMMAND [ARGS]...
|
|
86
86
|
|
87
87
|
Options:
|
88
88
|
--version Show version information.
|
89
|
-
--model-name TEXT Specify the model to use (litellm format,
|
89
|
+
--model-name TEXT Specify the text model to use (litellm format,
|
90
90
|
e.g. "openrouter/deepseek-chat").
|
91
|
+
--vision-model-name TEXT Specify the vision model to use (litellm format,
|
92
|
+
e.g. "openrouter/A/gpt-4o-mini").
|
91
93
|
--log [info|debug|warning] Set logging level (info/debug/warning).
|
92
94
|
--verbose Enable verbose output.
|
93
95
|
--mode [code|basic|interpreter|full|code-basic]
|
@@ -348,7 +350,7 @@ By integrating these tools into its architecture, QuantaLogic allows agents to p
|
|
348
350
|
| Script Execution | Python Tool, Node.js Tool, Elixir Tool |
|
349
351
|
| File Operations | Read File Tool, Write File Tool, Edit Whole Content Tool, Replace In File Tool |
|
350
352
|
| Code Analysis | Search Definition Names Tool, Ripgrep Tool |
|
351
|
-
| Content Generation | LLM Tool
|
353
|
+
| Content Generation | LLM Tool, LLMVisionTool |
|
352
354
|
| Utility and Management | Download HTTP File Tool, List Directory Tool, Markitdown Tool, Unified Diff Tool |
|
353
355
|
|
354
356
|
---
|
@@ -644,7 +646,30 @@ print("Ripgrep Results:", output)
|
|
644
646
|
|
645
647
|
---
|
646
648
|
|
647
|
-
|
649
|
+
#### 14. LLMVisionTool
|
650
|
+
|
651
|
+
The **LLMVisionTool** enables processing of visual inputs using vision-language models.
|
652
|
+
|
653
|
+
##### Parameters
|
654
|
+
|
655
|
+
| Parameter | Type | Description | Example |
|
656
|
+
|----------------|---------|------------------------------------------------------------------------|--------------------------------------------|
|
657
|
+
| `image_path` | string | Path to the image file to process | `./path/to/image.png` |
|
658
|
+
| `prompt` | string | The question or instruction for the vision model | `Describe the contents of this image` |
|
659
|
+
| `temperature` | float | Sampling temperature between 0.0 and 1.0 | `0.7` |
|
660
|
+
|
661
|
+
##### Example Usage
|
662
|
+
```python
|
663
|
+
vision_tool = LLMVisionTool()
|
664
|
+
response = vision_tool.execute(
|
665
|
+
image_path="./path/to/image.png",
|
666
|
+
prompt="Describe the contents of this image",
|
667
|
+
temperature=0.7
|
668
|
+
)
|
669
|
+
print("Vision Model Response:", response)
|
670
|
+
```
|
671
|
+
|
672
|
+
#### 15. LLM Tool
|
648
673
|
|
649
674
|
The **LLM Tool** generates answers using a specified language model.
|
650
675
|
|
@@ -669,7 +694,7 @@ print("LLM Response:", response)
|
|
669
694
|
|
670
695
|
---
|
671
696
|
|
672
|
-
###
|
697
|
+
### 16. Download HTTP File Tool
|
673
698
|
|
674
699
|
The **Download HTTP File Tool** downloads a file from a specified HTTP URL.
|
675
700
|
|
@@ -689,7 +714,7 @@ print(result)
|
|
689
714
|
|
690
715
|
---
|
691
716
|
|
692
|
-
###
|
717
|
+
### 17. List Directory Tool
|
693
718
|
|
694
719
|
The **List Directory Tool** lists files in a specified directory.
|
695
720
|
|
@@ -708,7 +733,7 @@ print("Directory Files:", result)
|
|
708
733
|
|
709
734
|
---
|
710
735
|
|
711
|
-
###
|
736
|
+
### 18. Markitdown Tool
|
712
737
|
|
713
738
|
The **Markitdown Tool** processes markdown files, possibly for conversion or rendering.
|
714
739
|
|
@@ -725,26 +750,6 @@ result = markitdown_tool.execute(markdown_path="./path/to/file.md")
|
|
725
750
|
print("Processed Markdown Output:", result)
|
726
751
|
```
|
727
752
|
|
728
|
-
---
|
729
|
-
|
730
|
-
### 18. Unified Diff Tool
|
731
|
-
|
732
|
-
The **Unified Diff Tool** generates a unified diff between two texts or files.
|
733
|
-
|
734
|
-
#### Parameters
|
735
|
-
|
736
|
-
| Parameter | Type | Description | Example |
|
737
|
-
|--------------|--------|------------------------------------------------|------------------------|
|
738
|
-
| `original` | string | The original content or file path. | `old_text.txt` |
|
739
|
-
| `updated` | string | The updated content or file path. | `new_text.txt` |
|
740
|
-
|
741
|
-
#### Example Usage
|
742
|
-
```python
|
743
|
-
diff_tool = UnifiedDiffTool()
|
744
|
-
result = diff_tool.execute(original="old_text.txt", updated="new_text.txt")
|
745
|
-
print("Unified Diff Output:", result)
|
746
|
-
```
|
747
|
-
|
748
753
|
|
749
754
|
#### Creating Custom Tools
|
750
755
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "quantalogic"
|
3
|
-
version = "0.2.
|
3
|
+
version = "0.2.12"
|
4
4
|
description = "QuantaLogic ReAct Agents"
|
5
5
|
authors = ["Raphaël MANSUY <raphael.mansuy@gmail.com>"]
|
6
6
|
readme = "README.md"
|
@@ -33,6 +33,7 @@ google-auth = "^2.20.0"
|
|
33
33
|
pathspec = "^0.12.1"
|
34
34
|
click = "^8.1.8"
|
35
35
|
toml = "^0.10.2"
|
36
|
+
types-requests = "^2.32.0.20241016"
|
36
37
|
|
37
38
|
[tool.poetry.scripts]
|
38
39
|
quantalogic = "quantalogic.main:cli"
|
@@ -1,7 +1,5 @@
|
|
1
1
|
"""Enhanced QuantaLogic agent implementing the ReAct framework."""
|
2
2
|
|
3
|
-
import os
|
4
|
-
import sys
|
5
3
|
from collections.abc import Callable
|
6
4
|
from datetime import datetime
|
7
5
|
from typing import Any
|
@@ -64,6 +62,7 @@ class Agent(BaseModel):
|
|
64
62
|
event_emitter: EventEmitter = EventEmitter()
|
65
63
|
config: AgentConfig
|
66
64
|
task_to_solve: str
|
65
|
+
task_to_solve_summary: str = ""
|
67
66
|
ask_for_user_validation: Callable[[str], bool] = console_ask_for_user_validation
|
68
67
|
last_tool_call: dict[str, Any] = {} # Stores the last tool call information
|
69
68
|
total_tokens: int = 0 # Total tokens in the conversation
|
@@ -137,6 +136,9 @@ class Agent(BaseModel):
|
|
137
136
|
logger.debug(f"Solving task... {task}")
|
138
137
|
self._reset_session(task_to_solve=task, max_iterations=max_iterations)
|
139
138
|
|
139
|
+
# Generate task summary
|
140
|
+
self.task_to_solve_summary = self._generate_task_summary(task)
|
141
|
+
|
140
142
|
# Add system prompt to memory
|
141
143
|
self.memory.add(Message(role="system", content=self.config.system_prompt))
|
142
144
|
|
@@ -166,7 +168,7 @@ class Agent(BaseModel):
|
|
166
168
|
self._update_total_tokens(message_history=self.memory.memory, prompt=current_prompt)
|
167
169
|
|
168
170
|
# Emit event: Task Think Start after updating total tokens
|
169
|
-
self._emit_event("task_think_start")
|
171
|
+
self._emit_event("task_think_start", {"prompt": current_prompt})
|
170
172
|
|
171
173
|
self._compact_memory_if_needed(current_prompt)
|
172
174
|
|
@@ -443,6 +445,10 @@ class Agent(BaseModel):
|
|
443
445
|
"You must analyze this answer and evaluate what to do next to solve the task.\n"
|
444
446
|
"If the step failed, take a step back and rethink your approach.\n"
|
445
447
|
"\n"
|
448
|
+
"--- Task to solve summary ---\n"
|
449
|
+
"\n"
|
450
|
+
f"{self.task_to_solve_summary}"
|
451
|
+
"\n"
|
446
452
|
"--- Format ---\n"
|
447
453
|
"\n"
|
448
454
|
"You MUST respond with exactly two XML blocks formatted in markdown:\n"
|
@@ -546,6 +552,7 @@ class Agent(BaseModel):
|
|
546
552
|
"\n### Tools:\n"
|
547
553
|
"-----------------------------\n"
|
548
554
|
f"{self._get_tools_names_prompt()}\n"
|
555
|
+
"\n"
|
549
556
|
"### Variables:\n"
|
550
557
|
"-----------------------------\n"
|
551
558
|
f"{self._get_variable_prompt()}\n"
|
@@ -575,6 +582,8 @@ class Agent(BaseModel):
|
|
575
582
|
"Available variables:\n"
|
576
583
|
"\n"
|
577
584
|
f"{', '.join(self.variable_store.keys())}\n"
|
585
|
+
if len(self.variable_store.keys()) > 0
|
586
|
+
else "None\n"
|
578
587
|
)
|
579
588
|
return prompt_use_variables
|
580
589
|
|
@@ -619,6 +628,28 @@ class Agent(BaseModel):
|
|
619
628
|
self.memory.memory = memory_copy
|
620
629
|
return summary.response
|
621
630
|
|
631
|
+
def _generate_task_summary(self, content: str) -> str:
|
632
|
+
"""Generate a concise summary of the given content using the generative model.
|
633
|
+
|
634
|
+
Args:
|
635
|
+
content (str): The content to summarize
|
636
|
+
|
637
|
+
Returns:
|
638
|
+
str: Generated summary
|
639
|
+
"""
|
640
|
+
try:
|
641
|
+
prompt = (
|
642
|
+
"Rewrite this task in a precise, dense, and concise manner:\n"
|
643
|
+
f"{content}\n"
|
644
|
+
"Summary should be 2-3 sentences maximum. No extra comments should be added.\n"
|
645
|
+
)
|
646
|
+
result = self.model.generate(prompt=prompt)
|
647
|
+
logger.debug(f"Generated summary: {result.response}")
|
648
|
+
return result.response
|
649
|
+
except Exception as e:
|
650
|
+
logger.error(f"Error generating summary: {str(e)}")
|
651
|
+
return f"Summary generation failed: {str(e)}"
|
652
|
+
|
622
653
|
def _update_session_memory(self, user_content: str, assistant_content: str) -> None:
|
623
654
|
"""
|
624
655
|
Log session messages to memory and emit events.
|
@@ -0,0 +1,169 @@
|
|
1
|
+
"""Module for agent configuration and creation."""
|
2
|
+
|
3
|
+
# Standard library imports
|
4
|
+
|
5
|
+
# Local application imports
|
6
|
+
from quantalogic.agent import Agent
|
7
|
+
from quantalogic.coding_agent import create_coding_agent
|
8
|
+
from quantalogic.tools import (
|
9
|
+
AgentTool,
|
10
|
+
DownloadHttpFileTool,
|
11
|
+
EditWholeContentTool,
|
12
|
+
ExecuteBashCommandTool,
|
13
|
+
InputQuestionTool,
|
14
|
+
ListDirectoryTool,
|
15
|
+
LLMTool,
|
16
|
+
LLMVisionTool,
|
17
|
+
MarkitdownTool,
|
18
|
+
NodeJsTool,
|
19
|
+
PythonTool,
|
20
|
+
ReadFileBlockTool,
|
21
|
+
ReadFileTool,
|
22
|
+
ReplaceInFileTool,
|
23
|
+
RipgrepTool,
|
24
|
+
SearchDefinitionNames,
|
25
|
+
TaskCompleteTool,
|
26
|
+
WriteFileTool,
|
27
|
+
)
|
28
|
+
|
29
|
+
MODEL_NAME = "deepseek/deepseek-chat"
|
30
|
+
|
31
|
+
|
32
|
+
def create_agent(model_name: str, vision_model_name: str | None) -> Agent:
|
33
|
+
"""Create an agent with the specified model and tools.
|
34
|
+
|
35
|
+
Args:
|
36
|
+
model_name (str): Name of the model to use
|
37
|
+
vision_model_name (str | None): Name of the vision model to use
|
38
|
+
|
39
|
+
Returns:
|
40
|
+
Agent: An agent with the specified model and tools
|
41
|
+
"""
|
42
|
+
tools = [
|
43
|
+
TaskCompleteTool(),
|
44
|
+
ReadFileTool(),
|
45
|
+
ReadFileBlockTool(),
|
46
|
+
WriteFileTool(),
|
47
|
+
EditWholeContentTool(),
|
48
|
+
InputQuestionTool(),
|
49
|
+
ListDirectoryTool(),
|
50
|
+
ExecuteBashCommandTool(),
|
51
|
+
ReplaceInFileTool(),
|
52
|
+
RipgrepTool(),
|
53
|
+
SearchDefinitionNames(),
|
54
|
+
MarkitdownTool(),
|
55
|
+
LLMTool(model_name=model_name),
|
56
|
+
DownloadHttpFileTool(),
|
57
|
+
]
|
58
|
+
|
59
|
+
if vision_model_name:
|
60
|
+
tools.append(LLMVisionTool(model_name=vision_model_name))
|
61
|
+
|
62
|
+
return Agent(
|
63
|
+
model_name=model_name,
|
64
|
+
tools=tools,
|
65
|
+
)
|
66
|
+
|
67
|
+
|
68
|
+
def create_interpreter_agent(model_name: str, vision_model_name: str | None) -> Agent:
|
69
|
+
"""Create an interpreter agent with the specified model and tools.
|
70
|
+
|
71
|
+
Args:
|
72
|
+
model_name (str): Name of the model to use
|
73
|
+
vision_model_name (str | None): Name of the vision model to use
|
74
|
+
|
75
|
+
Returns:
|
76
|
+
Agent: An interpreter agent with the specified model and tools
|
77
|
+
"""
|
78
|
+
tools = [
|
79
|
+
TaskCompleteTool(),
|
80
|
+
ReadFileTool(),
|
81
|
+
ReadFileBlockTool(),
|
82
|
+
WriteFileTool(),
|
83
|
+
EditWholeContentTool(),
|
84
|
+
InputQuestionTool(),
|
85
|
+
ListDirectoryTool(),
|
86
|
+
ExecuteBashCommandTool(),
|
87
|
+
ReplaceInFileTool(),
|
88
|
+
RipgrepTool(),
|
89
|
+
PythonTool(),
|
90
|
+
NodeJsTool(),
|
91
|
+
SearchDefinitionNames(),
|
92
|
+
MarkitdownTool(),
|
93
|
+
LLMTool(model_name=model_name),
|
94
|
+
DownloadHttpFileTool(),
|
95
|
+
]
|
96
|
+
return Agent(model_name=model_name, tools=tools)
|
97
|
+
|
98
|
+
|
99
|
+
def create_full_agent(model_name: str, vision_model_name: str | None) -> Agent:
|
100
|
+
"""Create an agent with the specified model and many tools.
|
101
|
+
|
102
|
+
Args:
|
103
|
+
model_name (str): Name of the model to use
|
104
|
+
vision_model_name (str | None): Name of the vision model to use
|
105
|
+
|
106
|
+
Returns:
|
107
|
+
Agent: An agent with the specified model and tools
|
108
|
+
|
109
|
+
"""
|
110
|
+
tools = [
|
111
|
+
TaskCompleteTool(),
|
112
|
+
ReadFileTool(),
|
113
|
+
ReadFileBlockTool(),
|
114
|
+
WriteFileTool(),
|
115
|
+
EditWholeContentTool(),
|
116
|
+
InputQuestionTool(),
|
117
|
+
ListDirectoryTool(),
|
118
|
+
ExecuteBashCommandTool(),
|
119
|
+
ReplaceInFileTool(),
|
120
|
+
RipgrepTool(),
|
121
|
+
PythonTool(),
|
122
|
+
NodeJsTool(),
|
123
|
+
SearchDefinitionNames(),
|
124
|
+
MarkitdownTool(),
|
125
|
+
LLMTool(model_name=model_name),
|
126
|
+
DownloadHttpFileTool(),
|
127
|
+
]
|
128
|
+
|
129
|
+
if vision_model_name:
|
130
|
+
tools.append(LLMVisionTool(model_name=vision_model_name))
|
131
|
+
|
132
|
+
return Agent(
|
133
|
+
model_name=model_name,
|
134
|
+
tools=tools,
|
135
|
+
)
|
136
|
+
|
137
|
+
|
138
|
+
def create_orchestrator_agent(model_name: str, vision_model_name: str | None = None) -> Agent:
|
139
|
+
"""Create an agent with the specified model and tools.
|
140
|
+
|
141
|
+
Args:
|
142
|
+
model_name (str): Name of the model to use
|
143
|
+
vision_model_name (str | None): Name of the vision model to use
|
144
|
+
|
145
|
+
Returns:
|
146
|
+
Agent: An agent with the specified model and tools
|
147
|
+
"""
|
148
|
+
# Rebuild AgentTool to resolve forward references
|
149
|
+
AgentTool.model_rebuild()
|
150
|
+
|
151
|
+
coding_agent_instance = create_coding_agent(model_name)
|
152
|
+
|
153
|
+
tools = [
|
154
|
+
TaskCompleteTool(),
|
155
|
+
ListDirectoryTool(),
|
156
|
+
ReadFileBlockTool(),
|
157
|
+
RipgrepTool(),
|
158
|
+
SearchDefinitionNames(),
|
159
|
+
LLMTool(model_name=MODEL_NAME),
|
160
|
+
AgentTool(agent=coding_agent_instance, agent_role="software expert", name="coder_agent_tool"),
|
161
|
+
]
|
162
|
+
|
163
|
+
if vision_model_name:
|
164
|
+
tools.append(LLMVisionTool(model_name=vision_model_name))
|
165
|
+
|
166
|
+
return Agent(
|
167
|
+
model_name=model_name,
|
168
|
+
tools=tools,
|
169
|
+
)
|
@@ -5,6 +5,7 @@ from quantalogic.tools import (
|
|
5
5
|
InputQuestionTool,
|
6
6
|
ListDirectoryTool,
|
7
7
|
LLMTool,
|
8
|
+
LLMVisionTool,
|
8
9
|
ReadFileBlockTool,
|
9
10
|
ReadFileTool,
|
10
11
|
ReplaceInFileTool,
|
@@ -17,11 +18,12 @@ from quantalogic.utils import get_coding_environment
|
|
17
18
|
from quantalogic.utils.get_quantalogic_rules_content import get_quantalogic_rules_file_content
|
18
19
|
|
19
20
|
|
20
|
-
def create_coding_agent(model_name: str, basic: bool = False) -> Agent:
|
21
|
+
def create_coding_agent(model_name: str, vision_model_name: str | None = None, basic: bool = False) -> Agent:
|
21
22
|
"""Creates and configures a coding agent with a comprehensive set of tools.
|
22
23
|
|
23
24
|
Args:
|
24
25
|
model_name (str): Name of the language model to use for the agent's core capabilities
|
26
|
+
vision_model_name (str | None): Name of the vision model to use for the agent's core capabilities
|
25
27
|
basic (bool, optional): If True, the agent will be configured with a basic set of tools.
|
26
28
|
|
27
29
|
Returns:
|
@@ -59,12 +61,15 @@ def create_coding_agent(model_name: str, basic: bool = False) -> Agent:
|
|
59
61
|
InputQuestionTool(),
|
60
62
|
]
|
61
63
|
|
64
|
+
if vision_model_name:
|
65
|
+
tools.append(LLMVisionTool(model_name=vision_model_name))
|
66
|
+
|
62
67
|
if not basic:
|
63
68
|
tools.append(
|
64
69
|
LLMTool(
|
65
70
|
model_name=model_name,
|
66
71
|
system_prompt="You are a software expert, your role is to answer coding questions.",
|
67
|
-
name="coding_consultant", # Handles implementation-level coding questions
|
72
|
+
name="coding_consultant", # Handles implementation-level coding questions
|
68
73
|
)
|
69
74
|
)
|
70
75
|
tools.append(
|