quantalogic 0.2.15__py3-none-any.whl → 0.2.16__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 +3 -3
- quantalogic/coding_agent.py +3 -1
- quantalogic/main.py +43 -16
- quantalogic/prompts.py +1 -0
- quantalogic/search_agent.py +15 -7
- {quantalogic-0.2.15.dist-info → quantalogic-0.2.16.dist-info}/METADATA +4 -2
- {quantalogic-0.2.15.dist-info → quantalogic-0.2.16.dist-info}/RECORD +10 -10
- {quantalogic-0.2.15.dist-info → quantalogic-0.2.16.dist-info}/LICENSE +0 -0
- {quantalogic-0.2.15.dist-info → quantalogic-0.2.16.dist-info}/WHEEL +0 -0
- {quantalogic-0.2.15.dist-info → quantalogic-0.2.16.dist-info}/entry_points.txt +0 -0
quantalogic/agent.py
CHANGED
@@ -406,7 +406,7 @@ class Agent(BaseModel):
|
|
406
406
|
|
407
407
|
formatted_response = (
|
408
408
|
"\n"
|
409
|
-
f"--- Observations for iteration {iteration} ---\n"
|
409
|
+
f"--- Observations for iteration {iteration} / max {self.max_iterations} ---\n"
|
410
410
|
"\n"
|
411
411
|
f"\n --- Tool execution result stored in variable ${variable_name}$ --- \n"
|
412
412
|
"\n"
|
@@ -428,7 +428,7 @@ class Agent(BaseModel):
|
|
428
428
|
# Format the response message
|
429
429
|
formatted_response = (
|
430
430
|
"\n"
|
431
|
-
f"--- Observations for iteration {iteration} ---\n"
|
431
|
+
f"--- Observations for iteration {iteration} / max {self.max_iterations} ---\n"
|
432
432
|
"\n"
|
433
433
|
f"\n --- Tool execution result stored in variable ${variable_name}$ --- \n"
|
434
434
|
"\n"
|
@@ -440,7 +440,7 @@ class Agent(BaseModel):
|
|
440
440
|
"\n"
|
441
441
|
f"--- Variables --- \n"
|
442
442
|
"\n"
|
443
|
-
f"{self._get_variable_prompt()}"
|
443
|
+
f"{self._get_variable_prompt()}\n"
|
444
444
|
"\n"
|
445
445
|
"You must analyze this answer and evaluate what to do next to solve the task.\n"
|
446
446
|
"If the step failed, take a step back and rethink your approach.\n"
|
quantalogic/coding_agent.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
from quantalogic.agent import Agent
|
2
2
|
from quantalogic.tools import (
|
3
|
+
DuckDuckGoSearchTool,
|
3
4
|
EditWholeContentTool,
|
4
5
|
ExecuteBashCommandTool,
|
5
6
|
InputQuestionTool,
|
@@ -59,6 +60,7 @@ def create_coding_agent(model_name: str, vision_model_name: str | None = None, b
|
|
59
60
|
ReadFileTool(),
|
60
61
|
ExecuteBashCommandTool(),
|
61
62
|
InputQuestionTool(),
|
63
|
+
DuckDuckGoSearchTool(),
|
62
64
|
]
|
63
65
|
|
64
66
|
if vision_model_name:
|
@@ -69,7 +71,7 @@ def create_coding_agent(model_name: str, vision_model_name: str | None = None, b
|
|
69
71
|
LLMTool(
|
70
72
|
model_name=model_name,
|
71
73
|
system_prompt="You are a software expert, your role is to answer coding questions.",
|
72
|
-
name="coding_consultant", # Handles implementation-level coding questions
|
74
|
+
name="coding_consultant", # Handles implementation-level coding questions
|
73
75
|
)
|
74
76
|
)
|
75
77
|
tools.append(
|
quantalogic/main.py
CHANGED
@@ -32,9 +32,9 @@ from quantalogic.agent_config import ( # noqa: E402
|
|
32
32
|
)
|
33
33
|
from quantalogic.interactive_text_editor import get_multiline_input # noqa: E402
|
34
34
|
from quantalogic.print_event import console_print_events # noqa: E402
|
35
|
-
from quantalogic.search_agent import create_search_agent
|
35
|
+
from quantalogic.search_agent import create_search_agent # noqa: E402
|
36
36
|
|
37
|
-
AGENT_MODES = ["code", "basic", "interpreter", "full", "code-basic","search"]
|
37
|
+
AGENT_MODES = ["code", "basic", "interpreter", "full", "code-basic", "search", "search-full"]
|
38
38
|
|
39
39
|
|
40
40
|
def create_agent_for_mode(mode: str, model_name: str, vision_model_name: str | None) -> Agent:
|
@@ -53,9 +53,12 @@ def create_agent_for_mode(mode: str, model_name: str, vision_model_name: str | N
|
|
53
53
|
return create_interpreter_agent(model_name, vision_model_name)
|
54
54
|
elif mode == "search":
|
55
55
|
return create_search_agent(model_name)
|
56
|
+
if mode == "search-full":
|
57
|
+
return create_search_agent(model_name, mode_full=True)
|
56
58
|
else:
|
57
59
|
raise ValueError(f"Unknown agent mode: {mode}")
|
58
60
|
|
61
|
+
|
59
62
|
def check_new_version():
|
60
63
|
# Randomly check for updates (1 in 10 chance)
|
61
64
|
if random.randint(1, 10) == 1:
|
@@ -81,6 +84,7 @@ def check_new_version():
|
|
81
84
|
except Exception:
|
82
85
|
return
|
83
86
|
|
87
|
+
|
84
88
|
def configure_logger(log_level: str) -> None:
|
85
89
|
"""Configure the logger with the specified log level and format."""
|
86
90
|
logger.remove()
|
@@ -122,7 +126,9 @@ def get_task_from_file(file_path: str) -> str:
|
|
122
126
|
raise Exception(f"Unexpected error reading file: {e}")
|
123
127
|
|
124
128
|
|
125
|
-
def display_welcome_message(
|
129
|
+
def display_welcome_message(
|
130
|
+
console: Console, model_name: str, vision_model_name: str | None, max_iterations: int = 50
|
131
|
+
) -> None:
|
126
132
|
"""Display the welcome message and instructions."""
|
127
133
|
version = get_version()
|
128
134
|
console.print(
|
@@ -135,7 +141,8 @@ def display_welcome_message(console: Console, model_name: str, vision_model_name
|
|
135
141
|
f"[yellow] 🤖 System Info:[/yellow]\n\n"
|
136
142
|
"\n"
|
137
143
|
f"- Model: {model_name}\n"
|
138
|
-
f"- Vision Model: {vision_model_name}\n
|
144
|
+
f"- Vision Model: {vision_model_name}\n"
|
145
|
+
f"- Max Iterations: {max_iterations}\n\n"
|
139
146
|
"[bold magenta]💡 Pro Tips:[/bold magenta]\n\n"
|
140
147
|
"- Be as specific as possible in your task description to get the best results!\n"
|
141
148
|
"- Use clear and concise language when describing your task\n"
|
@@ -167,6 +174,12 @@ def display_welcome_message(console: Console, model_name: str, vision_model_name
|
|
167
174
|
default=None,
|
168
175
|
help='Specify the vision model to use (litellm format, e.g. "openrouter/A/gpt-4o-mini").',
|
169
176
|
)
|
177
|
+
@click.option(
|
178
|
+
"--max-iterations",
|
179
|
+
type=int,
|
180
|
+
default=30,
|
181
|
+
help="Maximum number of iterations for task solving (default: 30).",
|
182
|
+
)
|
170
183
|
@click.pass_context
|
171
184
|
def cli(
|
172
185
|
ctx: click.Context,
|
@@ -176,6 +189,7 @@ def cli(
|
|
176
189
|
mode: str,
|
177
190
|
log: str,
|
178
191
|
vision_model_name: str | None,
|
192
|
+
max_iterations: int,
|
179
193
|
) -> None:
|
180
194
|
"""QuantaLogic AI Assistant - A powerful AI tool for various tasks."""
|
181
195
|
if version:
|
@@ -184,7 +198,13 @@ def cli(
|
|
184
198
|
sys.exit(0)
|
185
199
|
if ctx.invoked_subcommand is None:
|
186
200
|
ctx.invoke(
|
187
|
-
task,
|
201
|
+
task,
|
202
|
+
model_name=model_name,
|
203
|
+
verbose=verbose,
|
204
|
+
mode=mode,
|
205
|
+
log=log,
|
206
|
+
vision_model_name=vision_model_name,
|
207
|
+
max_iterations=max_iterations,
|
188
208
|
)
|
189
209
|
|
190
210
|
|
@@ -208,6 +228,12 @@ def cli(
|
|
208
228
|
default=None,
|
209
229
|
help='Specify the vision model to use (litellm format, e.g. "openrouter/openai/gpt-4o-mini").',
|
210
230
|
)
|
231
|
+
@click.option(
|
232
|
+
"--max-iterations",
|
233
|
+
type=int,
|
234
|
+
default=30,
|
235
|
+
help="Maximum number of iterations for task solving (default: 30).",
|
236
|
+
)
|
211
237
|
@click.argument("task", required=False)
|
212
238
|
def task(
|
213
239
|
file: Optional[str],
|
@@ -217,12 +243,12 @@ def task(
|
|
217
243
|
log: str,
|
218
244
|
vision_model_name: str | None,
|
219
245
|
task: Optional[str],
|
246
|
+
max_iterations: int,
|
220
247
|
) -> None:
|
221
248
|
"""Execute a task with the QuantaLogic AI Assistant."""
|
222
249
|
console = Console()
|
223
250
|
switch_verbose(verbose, log)
|
224
251
|
|
225
|
-
|
226
252
|
try:
|
227
253
|
if file:
|
228
254
|
task_content = get_task_from_file(file)
|
@@ -231,7 +257,7 @@ def task(
|
|
231
257
|
check_new_version()
|
232
258
|
task_content = task
|
233
259
|
else:
|
234
|
-
display_welcome_message(console, model_name, vision_model_name)
|
260
|
+
display_welcome_message(console, model_name, vision_model_name, max_iterations=max_iterations)
|
235
261
|
check_new_version()
|
236
262
|
logger.debug("Waiting for user input...")
|
237
263
|
task_content = get_multiline_input(console).strip()
|
@@ -241,14 +267,13 @@ def task(
|
|
241
267
|
console.print("[yellow]No task provided. Exiting...[/yellow]")
|
242
268
|
sys.exit(2)
|
243
269
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
border_style="blue",
|
250
|
-
)
|
270
|
+
console.print(
|
271
|
+
Panel.fit(
|
272
|
+
f"[bold]Task to be submitted:[/bold]\n{task_content}",
|
273
|
+
title="[bold]Task Preview[/bold]",
|
274
|
+
border_style="blue",
|
251
275
|
)
|
276
|
+
)
|
252
277
|
if not Confirm.ask("[bold]Are you sure you want to submit this task?[/bold]"):
|
253
278
|
console.print("[yellow]Task submission cancelled. Exiting...[/yellow]")
|
254
279
|
sys.exit(0)
|
@@ -284,8 +309,10 @@ def task(
|
|
284
309
|
logger.debug("Registered event handlers for agent events with events: {events}")
|
285
310
|
|
286
311
|
logger.debug(f"Solving task with agent: {task_content}")
|
287
|
-
|
288
|
-
|
312
|
+
if max_iterations < 1:
|
313
|
+
raise ValueError("max_iterations must be greater than 0")
|
314
|
+
result = agent.solve_task(task=task_content, max_iterations=max_iterations)
|
315
|
+
logger.debug(f"Task solved with result: {result} using {max_iterations} iterations")
|
289
316
|
|
290
317
|
console.print(
|
291
318
|
Panel.fit(
|
quantalogic/prompts.py
CHANGED
quantalogic/search_agent.py
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
from quantalogic.agent import Agent
|
2
2
|
from quantalogic.tools import (
|
3
|
+
DuckDuckGoSearchTool,
|
3
4
|
InputQuestionTool,
|
5
|
+
MarkitdownTool,
|
6
|
+
ReadFileBlockTool,
|
7
|
+
ReadFileTool,
|
8
|
+
RipgrepTool,
|
4
9
|
SerpApiSearchTool,
|
5
|
-
DuckDuckGoSearchTool,
|
6
10
|
TaskCompleteTool,
|
7
11
|
WikipediaSearchTool,
|
8
|
-
ReadFileBlockTool,
|
9
|
-
ReadFileTool,
|
10
|
-
MarkitdownTool,
|
11
|
-
RipgrepTool
|
12
12
|
)
|
13
13
|
|
14
14
|
|
15
|
-
def create_search_agent(model_name: str) -> Agent:
|
15
|
+
def create_search_agent(model_name: str, mode_full: bool = False) -> Agent:
|
16
16
|
"""Creates and configures a search agent with web, knowledge, and privacy-focused search tools.
|
17
17
|
|
18
18
|
Args:
|
19
19
|
model_name (str): Name of the language model to use for the agent's core capabilities
|
20
|
+
mode_full (bool, optional): If True, the agent will be configured with a full set of tools.
|
20
21
|
|
21
22
|
Returns:
|
22
23
|
Agent: A fully configured search agent instance with:
|
@@ -31,7 +32,6 @@ def create_search_agent(model_name: str) -> Agent:
|
|
31
32
|
|
32
33
|
tools = [
|
33
34
|
# Search tools
|
34
|
-
SerpApiSearchTool(), # Web search capabilities
|
35
35
|
DuckDuckGoSearchTool(), # Privacy-focused web search
|
36
36
|
WikipediaSearchTool(), # Knowledge search capabilities
|
37
37
|
# Basic interaction tools
|
@@ -45,6 +45,14 @@ def create_search_agent(model_name: str) -> Agent:
|
|
45
45
|
RipgrepTool(), # Code search capabilities
|
46
46
|
]
|
47
47
|
|
48
|
+
if mode_full:
|
49
|
+
tools.extend(
|
50
|
+
[
|
51
|
+
# Search tools
|
52
|
+
SerpApiSearchTool(), # Web search capabilities
|
53
|
+
]
|
54
|
+
)
|
55
|
+
|
48
56
|
return Agent(
|
49
57
|
model_name=model_name,
|
50
58
|
tools=tools,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: quantalogic
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.16
|
4
4
|
Summary: QuantaLogic ReAct Agents
|
5
5
|
Author: Raphaël MANSUY
|
6
6
|
Author-email: raphael.mansuy@gmail.com
|
@@ -133,7 +133,8 @@ Options:
|
|
133
133
|
e.g. "openrouter/A/gpt-4o-mini").
|
134
134
|
--log [info|debug|warning] Set logging level (info/debug/warning).
|
135
135
|
--verbose Enable verbose output.
|
136
|
-
--
|
136
|
+
--max-iterations INTEGER Maximum iterations for task solving (default: 30).
|
137
|
+
--mode [code|basic|interpreter|full|code-basic|search|search-full]
|
137
138
|
Agent mode (code/search/full).
|
138
139
|
--help Show this message and exit.
|
139
140
|
|
@@ -154,6 +155,7 @@ task Execute a task with the QuantaLogic AI Assistant
|
|
154
155
|
- interpreter: Interactive code execution agent
|
155
156
|
- full: Full-featured agent with all capabilities
|
156
157
|
- code-basic: Coding agent with basic reasoning
|
158
|
+
- search: Web search agent with Wikipedia, DuckDuckGo and SERPApi integration
|
157
159
|
|
158
160
|
#### Task Execution
|
159
161
|
|
@@ -1,16 +1,16 @@
|
|
1
1
|
quantalogic/__init__.py,sha256=HFk7_19UzHzYwvPzb9QTQ4w_lPwTTPda61AYb8qggZY,686
|
2
|
-
quantalogic/agent.py,sha256=
|
2
|
+
quantalogic/agent.py,sha256=uKY0y1ruJUUvnXmEyQASIFQbmoGZEj08w4T--eduEpQ,26711
|
3
3
|
quantalogic/agent_config.py,sha256=RWXnRpZeT_twtDIFVHY0K7EdHLmEbb8LvVGRr0oc3Q8,4634
|
4
|
-
quantalogic/coding_agent.py,sha256=
|
4
|
+
quantalogic/coding_agent.py,sha256=xKrkf-d3BDQRaeD6ODKDwgtpmWFmZxwP_IaNY6Py9Ew,3528
|
5
5
|
quantalogic/event_emitter.py,sha256=jqot2g4JRXc88K6PW837Oqxbf7shZfO-xdPaUWmzupk,7901
|
6
6
|
quantalogic/generative_model.py,sha256=pDbjwPfOQEtuZBk8o9uT8vxjauFfXwTM7GkMco73jfU,11787
|
7
7
|
quantalogic/interactive_text_editor.py,sha256=kYeTA2qej5kxtPvAUHy_Dr2MhrGQAyenLFpW9mU9Rmw,6855
|
8
|
-
quantalogic/main.py,sha256=
|
8
|
+
quantalogic/main.py,sha256=pMcJ7cLNcBWKsMRFFl7I1XVY52nmbXMcL_A4tNyU_Ts,11905
|
9
9
|
quantalogic/memory.py,sha256=zbtRuM05jaS2lJll-92dt5JfYVLERnF_m_9xqp2x-k0,6304
|
10
10
|
quantalogic/model_names.py,sha256=UZlz25zG9B2dpfwdw_e1Gw5qFsKQ7iME9FJh9Ts4u6s,938
|
11
11
|
quantalogic/print_event.py,sha256=nl1aRdYnsU72SRezafePF82zKtrqGfY8OoTx2QfbdE8,2206
|
12
|
-
quantalogic/prompts.py,sha256=
|
13
|
-
quantalogic/search_agent.py,sha256=
|
12
|
+
quantalogic/prompts.py,sha256=jRAm9YYvwx8KAx42Ak2H7y2p_1jIVuL1e3Wsd2Y81Cc,3548
|
13
|
+
quantalogic/search_agent.py,sha256=Jy-Zw77giZOlON_bDO0u3ppfRxv_O0EGcGmN4QuuLmQ,1944
|
14
14
|
quantalogic/server/__init__.py,sha256=8sz_PYAUCrkM6JM5EAUeIzNM4NPW6j6UT72JVkc21WQ,91
|
15
15
|
quantalogic/server/agent_server.py,sha256=38GEK_MpLp--CX_dCkopTFOU7KcGuOw4-GciwmRJyyg,22502
|
16
16
|
quantalogic/server/models.py,sha256=nVUGWElOsUw8QnRCGJylk25wCew_5gohe6nldYighUA,1322
|
@@ -68,8 +68,8 @@ quantalogic/utils/read_http_text_content.py,sha256=n3IayT5KcqctIVVF2gOQQAMf3Ow6e
|
|
68
68
|
quantalogic/version.py,sha256=ea_cRutaQk5_lwlLbUUvPFuOT7Of7-gAsDl7wdveS-g,107
|
69
69
|
quantalogic/xml_parser.py,sha256=cTRorr5sVfkIzH72M0C-GQ9ROGPiz2FTT66U9ndjzhE,9538
|
70
70
|
quantalogic/xml_tool_parser.py,sha256=lsVzClZBrZan7wjCuCKnGHWzksXI3VMy_vWthxu2_bo,3738
|
71
|
-
quantalogic-0.2.
|
72
|
-
quantalogic-0.2.
|
73
|
-
quantalogic-0.2.
|
74
|
-
quantalogic-0.2.
|
75
|
-
quantalogic-0.2.
|
71
|
+
quantalogic-0.2.16.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
72
|
+
quantalogic-0.2.16.dist-info/METADATA,sha256=38YNMH6-P_Sj7eUvqvsKfN1cgevdzcH2GFDCgwH-6As,41875
|
73
|
+
quantalogic-0.2.16.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
|
74
|
+
quantalogic-0.2.16.dist-info/entry_points.txt,sha256=wgSq5SRU98yvlRHGEZD1Xn7sS5CSjH2RfUtTa6Qy28Q,52
|
75
|
+
quantalogic-0.2.16.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|