quantalogic 0.2.17__py3-none-any.whl → 0.2.18__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.
- quantalogic/agent.py +37 -2
- quantalogic/agent_config.py +48 -5
- quantalogic/coding_agent.py +12 -1
- quantalogic/generative_model.py +6 -0
- quantalogic/main.py +58 -14
- quantalogic/prompts.py +2 -2
- quantalogic/search_agent.py +12 -1
- {quantalogic-0.2.17.dist-info → quantalogic-0.2.18.dist-info}/METADATA +47 -9
- {quantalogic-0.2.17.dist-info → quantalogic-0.2.18.dist-info}/RECORD +12 -12
- {quantalogic-0.2.17.dist-info → quantalogic-0.2.18.dist-info}/LICENSE +0 -0
- {quantalogic-0.2.17.dist-info → quantalogic-0.2.18.dist-info}/WHEEL +0 -0
- {quantalogic-0.2.17.dist-info → quantalogic-0.2.18.dist-info}/entry_points.txt +0 -0
quantalogic/agent.py
CHANGED
@@ -71,6 +71,8 @@ class Agent(BaseModel):
|
|
71
71
|
max_output_tokens: int = DEFAULT_MAX_OUTPUT_TOKENS
|
72
72
|
max_iterations: int = 30
|
73
73
|
system_prompt: str = ""
|
74
|
+
compact_every_n_iterations: int | None = None # Add this to the class attributes
|
75
|
+
max_tokens_working_memory: int | None = None # Add max_tokens_working_memory attribute
|
74
76
|
|
75
77
|
def __init__(
|
76
78
|
self,
|
@@ -81,6 +83,8 @@ class Agent(BaseModel):
|
|
81
83
|
task_to_solve: str = "",
|
82
84
|
specific_expertise: str = "General AI assistant with coding and problem-solving capabilities",
|
83
85
|
get_environment: Callable[[], str] = get_environment,
|
86
|
+
compact_every_n_iterations: int | None = None, # New parameter
|
87
|
+
max_tokens_working_memory: int | None = None, # New parameter to set max working memory tokens
|
84
88
|
):
|
85
89
|
"""Initialize the agent with model, memory, tools, and configurations."""
|
86
90
|
try:
|
@@ -121,6 +125,15 @@ class Agent(BaseModel):
|
|
121
125
|
specific_expertise=specific_expertise,
|
122
126
|
event_emitter=event_emitter,
|
123
127
|
)
|
128
|
+
|
129
|
+
# Set the new compact_every_n_iterations parameter
|
130
|
+
self.compact_every_n_iterations = compact_every_n_iterations or self.max_iterations
|
131
|
+
logger.debug(f"Memory will be compacted every {self.compact_every_n_iterations} iterations")
|
132
|
+
|
133
|
+
# Set the max_tokens_working_memory parameter
|
134
|
+
self.max_tokens_working_memory = max_tokens_working_memory
|
135
|
+
logger.debug(f"Max tokens for working memory set to: {self.max_tokens_working_memory}")
|
136
|
+
|
124
137
|
logger.debug("Agent initialized successfully.")
|
125
138
|
except Exception as e:
|
126
139
|
logger.error(f"Failed to initialize agent: {str(e)}")
|
@@ -265,9 +278,31 @@ class Agent(BaseModel):
|
|
265
278
|
self.total_tokens = self.model.token_counter_with_history(message_history, prompt)
|
266
279
|
|
267
280
|
def _compact_memory_if_needed(self, current_prompt: str = ""):
|
268
|
-
"""Compacts the memory if it exceeds the maximum occupancy."""
|
281
|
+
"""Compacts the memory if it exceeds the maximum occupancy or token limit."""
|
269
282
|
ratio_occupied = self._calculate_context_occupancy()
|
270
|
-
|
283
|
+
|
284
|
+
# Compact memory if any of these conditions are met:
|
285
|
+
# 1. Memory occupancy exceeds MAX_OCCUPANCY, or
|
286
|
+
# 2. Current iteration is a multiple of compact_every_n_iterations, or
|
287
|
+
# 3. Working memory exceeds max_tokens_working_memory (if set)
|
288
|
+
should_compact_by_occupancy = ratio_occupied >= MAX_OCCUPANCY
|
289
|
+
should_compact_by_iteration = (
|
290
|
+
self.compact_every_n_iterations is not None and
|
291
|
+
self.current_iteration > 0 and
|
292
|
+
self.current_iteration % self.compact_every_n_iterations == 0
|
293
|
+
)
|
294
|
+
should_compact_by_token_limit = (
|
295
|
+
self.max_tokens_working_memory is not None and
|
296
|
+
self.total_tokens > self.max_tokens_working_memory
|
297
|
+
)
|
298
|
+
|
299
|
+
if should_compact_by_occupancy or should_compact_by_iteration or should_compact_by_token_limit:
|
300
|
+
if should_compact_by_occupancy:
|
301
|
+
logger.debug(f"Memory compaction triggered: Occupancy {ratio_occupied}% exceeds {MAX_OCCUPANCY}%")
|
302
|
+
|
303
|
+
if should_compact_by_iteration:
|
304
|
+
logger.debug(f"Memory compaction triggered: Iteration {self.current_iteration} is a multiple of {self.compact_every_n_iterations}")
|
305
|
+
|
271
306
|
self._emit_event("memory_full")
|
272
307
|
self.memory.compact()
|
273
308
|
self.total_tokens = self.model.token_counter_with_history(self.memory.memory, current_prompt)
|
quantalogic/agent_config.py
CHANGED
@@ -32,13 +32,21 @@ from quantalogic.tools import (
|
|
32
32
|
MODEL_NAME = "deepseek/deepseek-chat"
|
33
33
|
|
34
34
|
|
35
|
-
def create_agent(
|
35
|
+
def create_agent(
|
36
|
+
model_name: str,
|
37
|
+
vision_model_name: str | None,
|
38
|
+
no_stream: bool = False,
|
39
|
+
compact_every_n_iteration: int | None = None,
|
40
|
+
max_tokens_working_memory: int | None = None
|
41
|
+
) -> Agent:
|
36
42
|
"""Create an agent with the specified model and tools.
|
37
43
|
|
38
44
|
Args:
|
39
45
|
model_name (str): Name of the model to use
|
40
46
|
vision_model_name (str | None): Name of the vision model to use
|
41
47
|
no_stream (bool, optional): If True, the agent will not stream results.
|
48
|
+
compact_every_n_iteration (int | None, optional): Frequency of memory compaction.
|
49
|
+
max_tokens_working_memory (int | None, optional): Maximum tokens for working memory.
|
42
50
|
|
43
51
|
Returns:
|
44
52
|
Agent: An agent with the specified model and tools
|
@@ -66,16 +74,26 @@ def create_agent(model_name: str, vision_model_name: str | None, no_stream: bool
|
|
66
74
|
return Agent(
|
67
75
|
model_name=model_name,
|
68
76
|
tools=tools,
|
77
|
+
compact_every_n_iterations=compact_every_n_iteration,
|
78
|
+
max_tokens_working_memory=max_tokens_working_memory,
|
69
79
|
)
|
70
80
|
|
71
81
|
|
72
|
-
def create_interpreter_agent(
|
82
|
+
def create_interpreter_agent(
|
83
|
+
model_name: str,
|
84
|
+
vision_model_name: str | None,
|
85
|
+
no_stream: bool = False,
|
86
|
+
compact_every_n_iteration: int | None = None,
|
87
|
+
max_tokens_working_memory: int | None = None
|
88
|
+
) -> Agent:
|
73
89
|
"""Create an interpreter agent with the specified model and tools.
|
74
90
|
|
75
91
|
Args:
|
76
92
|
model_name (str): Name of the model to use
|
77
93
|
vision_model_name (str | None): Name of the vision model to use
|
78
94
|
no_stream (bool, optional): If True, the agent will not stream results.
|
95
|
+
compact_every_n_iteration (int | None, optional): Frequency of memory compaction.
|
96
|
+
max_tokens_working_memory (int | None, optional): Maximum tokens for working memory.
|
79
97
|
|
80
98
|
Returns:
|
81
99
|
Agent: An interpreter agent with the specified model and tools
|
@@ -98,16 +116,29 @@ def create_interpreter_agent(model_name: str, vision_model_name: str | None, no_
|
|
98
116
|
LLMTool(model_name=model_name, on_token=console_print_token if not no_stream else None),
|
99
117
|
DownloadHttpFileTool(),
|
100
118
|
]
|
101
|
-
return Agent(
|
119
|
+
return Agent(
|
120
|
+
model_name=model_name,
|
121
|
+
tools=tools,
|
122
|
+
compact_every_n_iterations=compact_every_n_iteration,
|
123
|
+
max_tokens_working_memory=max_tokens_working_memory,
|
124
|
+
)
|
102
125
|
|
103
126
|
|
104
|
-
def create_full_agent(
|
127
|
+
def create_full_agent(
|
128
|
+
model_name: str,
|
129
|
+
vision_model_name: str | None,
|
130
|
+
no_stream: bool = False,
|
131
|
+
compact_every_n_iteration: int | None = None,
|
132
|
+
max_tokens_working_memory: int | None = None
|
133
|
+
) -> Agent:
|
105
134
|
"""Create an agent with the specified model and many tools.
|
106
135
|
|
107
136
|
Args:
|
108
137
|
model_name (str): Name of the model to use
|
109
138
|
vision_model_name (str | None): Name of the vision model to use
|
110
139
|
no_stream (bool, optional): If True, the agent will not stream results.
|
140
|
+
compact_every_n_iteration (int | None, optional): Frequency of memory compaction.
|
141
|
+
max_tokens_working_memory (int | None, optional): Maximum tokens for working memory.
|
111
142
|
|
112
143
|
Returns:
|
113
144
|
Agent: An agent with the specified model and tools
|
@@ -140,16 +171,26 @@ def create_full_agent(model_name: str, vision_model_name: str | None, no_stream:
|
|
140
171
|
return Agent(
|
141
172
|
model_name=model_name,
|
142
173
|
tools=tools,
|
174
|
+
compact_every_n_iterations=compact_every_n_iteration,
|
175
|
+
max_tokens_working_memory=max_tokens_working_memory,
|
143
176
|
)
|
144
177
|
|
145
178
|
|
146
|
-
def create_orchestrator_agent(
|
179
|
+
def create_orchestrator_agent(
|
180
|
+
model_name: str,
|
181
|
+
vision_model_name: str | None = None,
|
182
|
+
no_stream: bool = False,
|
183
|
+
compact_every_n_iteration: int | None = None,
|
184
|
+
max_tokens_working_memory: int | None = None
|
185
|
+
) -> Agent:
|
147
186
|
"""Create an agent with the specified model and tools.
|
148
187
|
|
149
188
|
Args:
|
150
189
|
model_name (str): Name of the model to use
|
151
190
|
vision_model_name (str | None): Name of the vision model to use
|
152
191
|
no_stream (bool, optional): If True, the agent will not stream results.
|
192
|
+
compact_every_n_iteration (int | None, optional): Frequency of memory compaction.
|
193
|
+
max_tokens_working_memory (int | None, optional): Maximum tokens for working memory.
|
153
194
|
|
154
195
|
Returns:
|
155
196
|
Agent: An agent with the specified model and tools
|
@@ -175,4 +216,6 @@ def create_orchestrator_agent(model_name: str, vision_model_name: str | None = N
|
|
175
216
|
return Agent(
|
176
217
|
model_name=model_name,
|
177
218
|
tools=tools,
|
219
|
+
compact_every_n_iterations=compact_every_n_iteration,
|
220
|
+
max_tokens_working_memory=max_tokens_working_memory,
|
178
221
|
)
|
quantalogic/coding_agent.py
CHANGED
@@ -20,7 +20,14 @@ from quantalogic.utils import get_coding_environment
|
|
20
20
|
from quantalogic.utils.get_quantalogic_rules_content import get_quantalogic_rules_file_content
|
21
21
|
|
22
22
|
|
23
|
-
def create_coding_agent(
|
23
|
+
def create_coding_agent(
|
24
|
+
model_name: str,
|
25
|
+
vision_model_name: str | None = None,
|
26
|
+
basic: bool = False,
|
27
|
+
no_stream: bool = False,
|
28
|
+
compact_every_n_iteration: int | None = None,
|
29
|
+
max_tokens_working_memory: int | None = None
|
30
|
+
) -> Agent:
|
24
31
|
"""Creates and configures a coding agent with a comprehensive set of tools.
|
25
32
|
|
26
33
|
Args:
|
@@ -28,6 +35,8 @@ def create_coding_agent(model_name: str, vision_model_name: str | None = None, b
|
|
28
35
|
vision_model_name (str | None): Name of the vision model to use for the agent's core capabilities
|
29
36
|
basic (bool, optional): If True, the agent will be configured with a basic set of tools.
|
30
37
|
no_stream (bool, optional): If True, the agent will not stream results.
|
38
|
+
compact_every_n_iteration (int | None, optional): Frequency of memory compaction.
|
39
|
+
max_tokens_working_memory (int | None, optional): Maximum tokens for working memory.
|
31
40
|
|
32
41
|
Returns:
|
33
42
|
Agent: A fully configured coding agent instance with:
|
@@ -91,4 +100,6 @@ def create_coding_agent(model_name: str, vision_model_name: str | None = None, b
|
|
91
100
|
tools=tools,
|
92
101
|
specific_expertise=specific_expertise,
|
93
102
|
get_environment=get_coding_environment,
|
103
|
+
compact_every_n_iterations=compact_every_n_iteration,
|
104
|
+
max_tokens_working_memory=max_tokens_working_memory,
|
94
105
|
)
|
quantalogic/generative_model.py
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
import functools
|
4
4
|
|
5
|
+
import litellm
|
5
6
|
import openai
|
6
7
|
from litellm import completion, exceptions, get_max_tokens, get_model_info, token_counter
|
7
8
|
from loguru import logger
|
@@ -12,6 +13,11 @@ from quantalogic.event_emitter import EventEmitter # Importing the EventEmitter
|
|
12
13
|
MIN_RETRIES = 1
|
13
14
|
|
14
15
|
|
16
|
+
|
17
|
+
litellm.suppress_debug_info = True # Very important to suppress prints don't remove
|
18
|
+
|
19
|
+
|
20
|
+
|
15
21
|
# Define the Message class for conversation handling
|
16
22
|
class Message(BaseModel):
|
17
23
|
"""Represents a message in a conversation with a specific role and content."""
|
quantalogic/main.py
CHANGED
@@ -11,7 +11,6 @@ import click
|
|
11
11
|
from loguru import logger
|
12
12
|
|
13
13
|
from quantalogic.console_print_events import console_print_events
|
14
|
-
from quantalogic.console_print_token import console_print_token
|
15
14
|
from quantalogic.utils.check_version import check_if_is_latest_version
|
16
15
|
from quantalogic.version import get_version
|
17
16
|
|
@@ -23,7 +22,6 @@ from threading import Lock # noqa: E402
|
|
23
22
|
from rich.console import Console # noqa: E402
|
24
23
|
from rich.panel import Panel # noqa: E402
|
25
24
|
from rich.prompt import Confirm # noqa: E402
|
26
|
-
from rich.spinner import Spinner # noqa: E402
|
27
25
|
|
28
26
|
from quantalogic.agent import Agent # noqa: E402
|
29
27
|
|
@@ -41,26 +39,28 @@ from quantalogic.search_agent import create_search_agent # noqa: E402
|
|
41
39
|
AGENT_MODES = ["code", "basic", "interpreter", "full", "code-basic", "search", "search-full"]
|
42
40
|
|
43
41
|
|
44
|
-
def create_agent_for_mode(mode: str, model_name: str, vision_model_name: str | None, no_stream: bool = False) -> Agent:
|
42
|
+
def create_agent_for_mode(mode: str, model_name: str, vision_model_name: str | None, no_stream: bool = False, compact_every_n_iteration: int | None = None, max_tokens_working_memory: int | None = None) -> Agent:
|
45
43
|
"""Create an agent based on the specified mode."""
|
46
44
|
logger.debug(f"Creating agent for mode: {mode} with model: {model_name}")
|
47
45
|
logger.debug(f"Using vision model: {vision_model_name}")
|
48
46
|
logger.debug(f"Using no_stream: {no_stream}")
|
47
|
+
logger.debug(f"Using compact_every_n_iteration: {compact_every_n_iteration}")
|
48
|
+
logger.debug(f"Using max_tokens_working_memory: {max_tokens_working_memory}")
|
49
49
|
if mode == "code":
|
50
50
|
logger.debug("Creating code agent without basic mode")
|
51
|
-
return create_coding_agent(model_name, vision_model_name, basic=False, no_stream=no_stream)
|
51
|
+
return create_coding_agent(model_name, vision_model_name, basic=False, no_stream=no_stream, compact_every_n_iteration=compact_every_n_iteration, max_tokens_working_memory=max_tokens_working_memory)
|
52
52
|
if mode == "code-basic":
|
53
|
-
return create_coding_agent(model_name, vision_model_name, basic=True, no_stream=no_stream)
|
53
|
+
return create_coding_agent(model_name, vision_model_name, basic=True, no_stream=no_stream, compact_every_n_iteration=compact_every_n_iteration, max_tokens_working_memory=max_tokens_working_memory)
|
54
54
|
elif mode == "basic":
|
55
|
-
return create_orchestrator_agent(model_name, vision_model_name, no_stream=no_stream)
|
55
|
+
return create_orchestrator_agent(model_name, vision_model_name, no_stream=no_stream, compact_every_n_iteration=compact_every_n_iteration, max_tokens_working_memory=max_tokens_working_memory)
|
56
56
|
elif mode == "full":
|
57
|
-
return create_full_agent(model_name, vision_model_name, no_stream=no_stream)
|
57
|
+
return create_full_agent(model_name, vision_model_name, no_stream=no_stream, compact_every_n_iteration=compact_every_n_iteration, max_tokens_working_memory=max_tokens_working_memory)
|
58
58
|
elif mode == "interpreter":
|
59
|
-
return create_interpreter_agent(model_name, vision_model_name, no_stream=no_stream)
|
59
|
+
return create_interpreter_agent(model_name, vision_model_name, no_stream=no_stream, compact_every_n_iteration=compact_every_n_iteration, max_tokens_working_memory=max_tokens_working_memory)
|
60
60
|
elif mode == "search":
|
61
|
-
return create_search_agent(model_name, no_stream=no_stream)
|
61
|
+
return create_search_agent(model_name, no_stream=no_stream, compact_every_n_iteration=compact_every_n_iteration, max_tokens_working_memory=max_tokens_working_memory)
|
62
62
|
if mode == "search-full":
|
63
|
-
return create_search_agent(model_name, mode_full=True, no_stream=no_stream)
|
63
|
+
return create_search_agent(model_name, mode_full=True, no_stream=no_stream, compact_every_n_iteration=compact_every_n_iteration, max_tokens_working_memory=max_tokens_working_memory)
|
64
64
|
else:
|
65
65
|
raise ValueError(f"Unknown agent mode: {mode}")
|
66
66
|
|
@@ -154,7 +154,12 @@ def stop_spinner(console: Console) -> None:
|
|
154
154
|
|
155
155
|
|
156
156
|
def display_welcome_message(
|
157
|
-
console: Console,
|
157
|
+
console: Console,
|
158
|
+
model_name: str,
|
159
|
+
vision_model_name: str | None,
|
160
|
+
max_iterations: int = 50,
|
161
|
+
compact_every_n_iteration: int | None = None,
|
162
|
+
max_tokens_working_memory: int | None = None
|
158
163
|
) -> None:
|
159
164
|
"""Display the welcome message and instructions."""
|
160
165
|
version = get_version()
|
@@ -169,7 +174,9 @@ def display_welcome_message(
|
|
169
174
|
"\n"
|
170
175
|
f"- Model: {model_name}\n"
|
171
176
|
f"- Vision Model: {vision_model_name}\n"
|
172
|
-
f"- Max Iterations: {max_iterations}\n
|
177
|
+
f"- Max Iterations: {max_iterations}\n"
|
178
|
+
f"- Memory Compact Frequency: {compact_every_n_iteration or 'Default (Max Iterations)'}\n"
|
179
|
+
f"- Max Working Memory Tokens: {max_tokens_working_memory or 'Default'}\n\n"
|
173
180
|
"[bold magenta]💡 Pro Tips:[/bold magenta]\n\n"
|
174
181
|
"- Be as specific as possible in your task description to get the best results!\n"
|
175
182
|
"- Use clear and concise language when describing your task\n"
|
@@ -182,6 +189,12 @@ def display_welcome_message(
|
|
182
189
|
|
183
190
|
|
184
191
|
@click.group(invoke_without_command=True)
|
192
|
+
@click.option(
|
193
|
+
"--compact-every-n-iteration",
|
194
|
+
type=int,
|
195
|
+
default=None,
|
196
|
+
help="Set the frequency of memory compaction for the agent (default: max_iterations)."
|
197
|
+
)
|
185
198
|
@click.option("--version", is_flag=True, help="Show version information.")
|
186
199
|
@click.option(
|
187
200
|
"--model-name",
|
@@ -207,6 +220,12 @@ def display_welcome_message(
|
|
207
220
|
default=30,
|
208
221
|
help="Maximum number of iterations for task solving (default: 30).",
|
209
222
|
)
|
223
|
+
@click.option(
|
224
|
+
"--max-tokens-working-memory",
|
225
|
+
type=int,
|
226
|
+
default=None,
|
227
|
+
help="Set the maximum number of tokens allowed in the working memory."
|
228
|
+
)
|
210
229
|
@click.pass_context
|
211
230
|
def cli(
|
212
231
|
ctx: click.Context,
|
@@ -217,6 +236,8 @@ def cli(
|
|
217
236
|
log: str,
|
218
237
|
vision_model_name: str | None,
|
219
238
|
max_iterations: int,
|
239
|
+
compact_every_n_iteration: int | None,
|
240
|
+
max_tokens_working_memory: int | None,
|
220
241
|
) -> None:
|
221
242
|
"""QuantaLogic AI Assistant - A powerful AI tool for various tasks."""
|
222
243
|
if version:
|
@@ -232,6 +253,8 @@ def cli(
|
|
232
253
|
log=log,
|
233
254
|
vision_model_name=vision_model_name,
|
234
255
|
max_iterations=max_iterations,
|
256
|
+
compact_every_n_iteration=compact_every_n_iteration,
|
257
|
+
max_tokens_working_memory=max_tokens_working_memory,
|
235
258
|
)
|
236
259
|
|
237
260
|
|
@@ -261,6 +284,18 @@ def cli(
|
|
261
284
|
default=30,
|
262
285
|
help="Maximum number of iterations for task solving (default: 30).",
|
263
286
|
)
|
287
|
+
@click.option(
|
288
|
+
"--compact-every-n-iteration",
|
289
|
+
type=int,
|
290
|
+
default=None,
|
291
|
+
help="Set the frequency of memory compaction for the agent (default: max_iterations)."
|
292
|
+
)
|
293
|
+
@click.option(
|
294
|
+
"--max-tokens-working-memory",
|
295
|
+
type=int,
|
296
|
+
default=None,
|
297
|
+
help="Set the maximum number of tokens allowed in the working memory."
|
298
|
+
)
|
264
299
|
@click.option(
|
265
300
|
"--no-stream",
|
266
301
|
is_flag=True,
|
@@ -276,6 +311,8 @@ def task(
|
|
276
311
|
vision_model_name: str | None,
|
277
312
|
task: Optional[str],
|
278
313
|
max_iterations: int,
|
314
|
+
compact_every_n_iteration: int | None,
|
315
|
+
max_tokens_working_memory: int | None,
|
279
316
|
no_stream: bool,
|
280
317
|
) -> None:
|
281
318
|
"""Execute a task with the QuantaLogic AI Assistant."""
|
@@ -290,7 +327,14 @@ def task(
|
|
290
327
|
check_new_version()
|
291
328
|
task_content = task
|
292
329
|
else:
|
293
|
-
display_welcome_message(
|
330
|
+
display_welcome_message(
|
331
|
+
console,
|
332
|
+
model_name,
|
333
|
+
vision_model_name,
|
334
|
+
max_iterations=max_iterations,
|
335
|
+
compact_every_n_iteration=compact_every_n_iteration,
|
336
|
+
max_tokens_working_memory=max_tokens_working_memory
|
337
|
+
)
|
294
338
|
check_new_version()
|
295
339
|
logger.debug("Waiting for user input...")
|
296
340
|
task_content = get_multiline_input(console).strip()
|
@@ -322,7 +366,7 @@ def task(
|
|
322
366
|
logger.debug(
|
323
367
|
f"Creating agent for mode: {mode} with model: {model_name}, vision model: {vision_model_name}, no_stream: {no_stream}"
|
324
368
|
)
|
325
|
-
agent = create_agent_for_mode(mode, model_name, vision_model_name=vision_model_name, no_stream=no_stream)
|
369
|
+
agent = create_agent_for_mode(mode, model_name, vision_model_name=vision_model_name, no_stream=no_stream, compact_every_n_iteration=compact_every_n_iteration, max_tokens_working_memory=max_tokens_working_memory)
|
326
370
|
logger.debug(
|
327
371
|
f"Created agent for mode: {mode} with model: {model_name}, vision model: {vision_model_name}, no_stream: {no_stream}"
|
328
372
|
)
|
quantalogic/prompts.py
CHANGED
@@ -17,7 +17,7 @@ Every response must contain exactly two XML blocks:
|
|
17
17
|
1. Analysis Block:
|
18
18
|
```xml
|
19
19
|
<thinking>
|
20
|
-
<!--
|
20
|
+
<!-- Must follow this precise format, concise, dense, use abreviations, emojis, unicode characters to make it denser -->
|
21
21
|
<task_analysis_if_no_history>
|
22
22
|
Only if no conversation history:
|
23
23
|
* Rewrite the <task> and its context with your own words in detailed, clear, and specific manner.
|
@@ -51,7 +51,7 @@ Every response must contain exactly two XML blocks:
|
|
51
51
|
</last_observation>
|
52
52
|
<progess_analysis>
|
53
53
|
<!-- if there is a conversation history -->
|
54
|
-
* Detail each step failed and completed so far.
|
54
|
+
* Detail each step failed and completed so far, be concise.
|
55
55
|
* Identify and evaluate any blockers or challenges to the progress of global task.
|
56
56
|
* Identify repetitions: if repeated steps, take a step back and rethink your approach.
|
57
57
|
* Provide potential solutions, and if needed, suggest reevaluating the approach and the plan.
|
quantalogic/search_agent.py
CHANGED
@@ -12,12 +12,21 @@ from quantalogic.tools import (
|
|
12
12
|
)
|
13
13
|
|
14
14
|
|
15
|
-
def create_search_agent(
|
15
|
+
def create_search_agent(
|
16
|
+
model_name: str,
|
17
|
+
mode_full: bool = False,
|
18
|
+
no_stream: bool = False,
|
19
|
+
compact_every_n_iteration: int | None = None,
|
20
|
+
max_tokens_working_memory: int | None = None
|
21
|
+
) -> Agent:
|
16
22
|
"""Creates and configures a search agent with web, knowledge, and privacy-focused search tools.
|
17
23
|
|
18
24
|
Args:
|
19
25
|
model_name (str): Name of the language model to use for the agent's core capabilities
|
20
26
|
mode_full (bool, optional): If True, the agent will be configured with a full set of tools.
|
27
|
+
no_stream (bool, optional): If True, the agent will not stream results.
|
28
|
+
compact_every_n_iteration (int | None, optional): Frequency of memory compaction.
|
29
|
+
max_tokens_working_memory (int | None, optional): Maximum tokens for working memory.
|
21
30
|
|
22
31
|
Returns:
|
23
32
|
Agent: A fully configured search agent instance with:
|
@@ -57,4 +66,6 @@ def create_search_agent(model_name: str, mode_full: bool = False) -> Agent:
|
|
57
66
|
model_name=model_name,
|
58
67
|
tools=tools,
|
59
68
|
specific_expertise=specific_expertise,
|
69
|
+
compact_every_n_iterations=compact_every_n_iteration,
|
70
|
+
max_tokens_working_memory=max_tokens_working_memory,
|
60
71
|
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: quantalogic
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.18
|
4
4
|
Summary: QuantaLogic ReAct Agents
|
5
5
|
Author: Raphaël MANSUY
|
6
6
|
Author-email: raphael.mansuy@gmail.com
|
@@ -81,6 +81,8 @@ We created [QuantaLogic](https://www.quantalogic.app) because we saw a significa
|
|
81
81
|
|
82
82
|
## 📋 Table of Contents
|
83
83
|
|
84
|
+
- [Release Notes](#release-notes)
|
85
|
+
|
84
86
|
- [Installation](#-installation)
|
85
87
|
- [Quick Start](#-quickstart)
|
86
88
|
- [Key Components](#-key-components)
|
@@ -93,6 +95,12 @@ We created [QuantaLogic](https://www.quantalogic.app) because we saw a significa
|
|
93
95
|
- [License](#-license)
|
94
96
|
- [Documentation Development](#-documentation-development)
|
95
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
|
+
|
96
104
|
## 📦 Installation
|
97
105
|
|
98
106
|
### Prerequisites
|
@@ -134,20 +142,18 @@ The QuantaLogic CLI provides powerful command-line capabilities:
|
|
134
142
|
|
135
143
|
```bash
|
136
144
|
Usage: quantalogic [OPTIONS] COMMAND [ARGS]...
|
137
|
-
|
138
145
|
QuantaLogic AI Assistant - A powerful AI tool for various tasks.
|
139
146
|
|
140
147
|
Options:
|
141
148
|
--version Show version information.
|
142
|
-
--model-name TEXT Specify the
|
143
|
-
|
144
|
-
--vision-model-name TEXT Specify the vision model to use (litellm format,
|
145
|
-
e.g. "openrouter/openai/gpt-4o-mini").
|
146
|
-
--log [info|debug|warning] Set logging level (info/debug/warning).
|
149
|
+
--model-name TEXT Specify the model (litellm format, e.g., "openrouter/deepseek/deepseek-chat").
|
150
|
+
--log [info|debug|warning] Set logging level.
|
147
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").
|
148
154
|
--max-iterations INTEGER Maximum iterations for task solving (default: 30).
|
149
|
-
--
|
150
|
-
|
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).
|
151
157
|
--help Show this message and exit.
|
152
158
|
|
153
159
|
Commands:
|
@@ -157,6 +163,38 @@ Commands:
|
|
157
163
|
### Commands
|
158
164
|
task Execute a task with the QuantaLogic AI Assistant
|
159
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
|
+
|
160
198
|
|
161
199
|
|
162
200
|
### Detailed Usage
|
@@ -1,18 +1,18 @@
|
|
1
1
|
quantalogic/__init__.py,sha256=kX0c_xmD9OslWnAE92YHMGuD7xZcTo8ZOF_5R64HKps,784
|
2
|
-
quantalogic/agent.py,sha256=
|
3
|
-
quantalogic/agent_config.py,sha256=
|
4
|
-
quantalogic/coding_agent.py,sha256=
|
2
|
+
quantalogic/agent.py,sha256=KiONndkTQ_xTjlmwA2NcFwt4VGlBxSt40yHrL8Xrlms,29997
|
3
|
+
quantalogic/agent_config.py,sha256=H-YkaNkVglBlnN00Htrs3bPPoD2hirBfGBpoSbKgdMU,7232
|
4
|
+
quantalogic/coding_agent.py,sha256=viKePGtDbD3tzbc6RIPslINeRqOkLYwDWXDsw4TF18Y,4328
|
5
5
|
quantalogic/console_print_events.py,sha256=KB-DGi52As8M96eUs1N_vgNqKIFtqv_H8NTOd3TLTgQ,2163
|
6
6
|
quantalogic/console_print_token.py,sha256=qSU-3kmoZk4T5-1ybrEBi8tIXDPcz7eyWKhGh3E8uIg,395
|
7
7
|
quantalogic/docs_cli.py,sha256=3giVbUpespB9ZdTSJ955A3BhcOaBl5Lwsn1AVy9XAeY,1663
|
8
8
|
quantalogic/event_emitter.py,sha256=jqot2g4JRXc88K6PW837Oqxbf7shZfO-xdPaUWmzupk,7901
|
9
|
-
quantalogic/generative_model.py,sha256=
|
9
|
+
quantalogic/generative_model.py,sha256=s94heYFPSA2IO4E3ay3CF1k9hXKNAzX1KVmxHlQgF_8,12397
|
10
10
|
quantalogic/interactive_text_editor.py,sha256=kYeTA2qej5kxtPvAUHy_Dr2MhrGQAyenLFpW9mU9Rmw,6855
|
11
|
-
quantalogic/main.py,sha256=
|
11
|
+
quantalogic/main.py,sha256=nyqwQwrzmiurCwR5gkkx16BNW9XN69fTHvqOZ_qK9CU,16655
|
12
12
|
quantalogic/memory.py,sha256=zbtRuM05jaS2lJll-92dt5JfYVLERnF_m_9xqp2x-k0,6304
|
13
13
|
quantalogic/model_names.py,sha256=UZlz25zG9B2dpfwdw_e1Gw5qFsKQ7iME9FJh9Ts4u6s,938
|
14
|
-
quantalogic/prompts.py,sha256=
|
15
|
-
quantalogic/search_agent.py,sha256=
|
14
|
+
quantalogic/prompts.py,sha256=CW4CRgW1hTpXeWdeJNbPaRPUeUm-xKuGHJrT8mOtvkw,3602
|
15
|
+
quantalogic/search_agent.py,sha256=EA_FAPP0dVuUbJ_lAGKfYq1FIJ6oLYzGMgKLMvBL4ZQ,2472
|
16
16
|
quantalogic/server/__init__.py,sha256=8sz_PYAUCrkM6JM5EAUeIzNM4NPW6j6UT72JVkc21WQ,91
|
17
17
|
quantalogic/server/agent_server.py,sha256=JNginXlkgBfJLqgKffoTBSvBWI8ZO1uXUgTOqLINk_g,22517
|
18
18
|
quantalogic/server/models.py,sha256=nVUGWElOsUw8QnRCGJylk25wCew_5gohe6nldYighUA,1322
|
@@ -70,8 +70,8 @@ quantalogic/utils/read_http_text_content.py,sha256=n3IayT5KcqctIVVF2gOQQAMf3Ow6e
|
|
70
70
|
quantalogic/version.py,sha256=ea_cRutaQk5_lwlLbUUvPFuOT7Of7-gAsDl7wdveS-g,107
|
71
71
|
quantalogic/xml_parser.py,sha256=uMLQNHTRCg116FwcjRoquZmSwVtE4LEH-6V2E3RD-dA,11466
|
72
72
|
quantalogic/xml_tool_parser.py,sha256=lsVzClZBrZan7wjCuCKnGHWzksXI3VMy_vWthxu2_bo,3738
|
73
|
-
quantalogic-0.2.
|
74
|
-
quantalogic-0.2.
|
75
|
-
quantalogic-0.2.
|
76
|
-
quantalogic-0.2.
|
77
|
-
quantalogic-0.2.
|
73
|
+
quantalogic-0.2.18.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
74
|
+
quantalogic-0.2.18.dist-info/METADATA,sha256=W9clERsCPJHiuK25qx_dhiS3eitzGjzNHl8eA99kN2s,40514
|
75
|
+
quantalogic-0.2.18.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
76
|
+
quantalogic-0.2.18.dist-info/entry_points.txt,sha256=h74O_Q3qBRCrDR99qvwB4BpBGzASPUIjCfxHq6Qnups,183
|
77
|
+
quantalogic-0.2.18.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|