quantalogic 0.2.2__py3-none-any.whl → 0.2.4__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 CHANGED
@@ -21,12 +21,6 @@ from quantalogic.utils.ask_user_validation import console_ask_for_user_validatio
21
21
  from quantalogic.xml_parser import ToleranceXMLParser
22
22
  from quantalogic.xml_tool_parser import ToolParser
23
23
 
24
- # Configure logger based on environment variable
25
- log_level = os.getenv("LOG_LEVEL", "ERROR")
26
- logger.remove()
27
- logger.add(sys.stderr, level=log_level)
28
-
29
-
30
24
  # Maximum ratio occupancy of the occupied memory
31
25
  MAX_OCCUPANCY = 90.0
32
26
 
@@ -81,7 +75,7 @@ class Agent(BaseModel):
81
75
 
82
76
  def __init__(
83
77
  self,
84
- model_name: str = "ollama/qwen2.5-coder:14b",
78
+ model_name: str = "",
85
79
  memory: AgentMemory = AgentMemory(),
86
80
  tools: list[Tool] = [TaskCompleteTool()],
87
81
  ask_for_user_validation: Callable[[str], bool] = console_ask_for_user_validation,
@@ -91,6 +85,7 @@ class Agent(BaseModel):
91
85
  ):
92
86
  """Initialize the agent with model, memory, tools, and configurations."""
93
87
  try:
88
+ logger.debug("Initializing agent...")
94
89
  # Add TaskCompleteTool to the tools list if not already present
95
90
  if TaskCompleteTool() not in tools:
96
91
  tools.append(TaskCompleteTool())
@@ -119,7 +114,7 @@ class Agent(BaseModel):
119
114
  task_to_solve=task_to_solve,
120
115
  specific_expertise=specific_expertise,
121
116
  )
122
- logger.info("Agent initialized successfully.")
117
+ logger.debug("Agent initialized successfully.")
123
118
  except Exception as e:
124
119
  logger.error(f"Failed to initialize agent: {str(e)}")
125
120
  raise
@@ -135,6 +130,7 @@ class Agent(BaseModel):
135
130
  Returns:
136
131
  str: The final response after task completion.
137
132
  """
133
+ logger.debug(f"Solving task... {task}")
138
134
  self._reset_session(task_to_solve=task, max_iterations=max_iterations)
139
135
 
140
136
  # Add system prompt to memory
@@ -215,10 +211,13 @@ class Agent(BaseModel):
215
211
  # Emit event: Task Solve End
216
212
  self._emit_event("task_solve_end")
217
213
 
214
+ logger.debug(f"Task solved: {answer}")
215
+
218
216
  return answer
219
217
 
220
218
  def _reset_session(self, task_to_solve: str = "", max_iterations: int = 30):
221
219
  """Reset the agent's session."""
220
+ logger.debug("Resetting session...")
222
221
  self.task_to_solve = task_to_solve
223
222
  self.memory.reset()
224
223
  self.variable_store.reset()
quantalogic/main.py CHANGED
@@ -7,30 +7,37 @@ from typing import Optional
7
7
 
8
8
  # Third-party imports
9
9
  import click
10
- from rich.console import Console
11
- from rich.panel import Panel
12
- from rich.prompt import Confirm
10
+ from loguru import logger
13
11
 
14
- from quantalogic.agent import Agent
12
+ # Configure logger
13
+ logger.remove() # Remove default logger
14
+
15
+ from rich.console import Console # noqa: E402
16
+ from rich.panel import Panel # noqa: E402
17
+ from rich.prompt import Confirm # noqa: E402
18
+
19
+ from quantalogic.agent import Agent # noqa: E402
15
20
 
16
21
  # Local application imports
17
- from quantalogic.agent_config import (
22
+ from quantalogic.agent_config import ( # noqa: E402
18
23
  MODEL_NAME,
19
24
  create_coding_agent,
20
25
  create_full_agent,
21
26
  create_interpreter_agent,
22
27
  create_orchestrator_agent,
23
28
  )
24
- from quantalogic.interactive_text_editor import get_multiline_input
25
- from quantalogic.print_event import console_print_events
26
- from quantalogic.version import get_version
29
+ from quantalogic.interactive_text_editor import get_multiline_input # noqa: E402
30
+ from quantalogic.print_event import console_print_events # noqa: E402
31
+ from quantalogic.version import get_version # noqa: E402
27
32
 
28
33
  AGENT_MODES = ["code", "basic", "interpreter", "full", "code-basic"]
29
34
 
30
35
 
31
36
  def create_agent_for_mode(mode: str, model_name: str) -> Agent:
32
37
  """Create an agent based on the specified mode."""
38
+ logger.debug(f"Creating agent for mode: {mode} with model: {model_name}")
33
39
  if mode == "code":
40
+ logger.debug("Creating code agent without basic mode")
34
41
  return create_coding_agent(model_name, basic=False)
35
42
  if mode == "code-basic":
36
43
  return create_coding_agent(model_name, basic=True)
@@ -47,6 +54,13 @@ def create_agent_for_mode(mode: str, model_name: str) -> Agent:
47
54
  def switch_verbose(verbose_mode: bool) -> None:
48
55
  import litellm
49
56
 
57
+ if verbose_mode:
58
+ logger.add(sys.stderr, level="DEBUG", format="{time} | {level} | {message}")
59
+ logger.info("Verbose mode enabled.")
60
+ else:
61
+ logger.info("Verbose mode disabled.")
62
+ logger.remove()
63
+
50
64
  litellm.set_verbose = verbose_mode
51
65
 
52
66
 
@@ -123,8 +137,11 @@ def task(file: Optional[str], model_name: str, verbose: bool, mode: str, task: O
123
137
  task_content = task
124
138
  else:
125
139
  display_welcome_message(console, model_name)
140
+ logger.info("Waiting for user input...")
126
141
  task_content = get_multiline_input(console).strip()
142
+ logger.info(f"User input received. Task content: {task_content}")
127
143
  if not task_content:
144
+ logger.info("No task provided. Exiting...")
128
145
  console.print("[yellow]No task provided. Exiting...[/yellow]")
129
146
  sys.exit(2)
130
147
 
@@ -140,23 +157,31 @@ def task(file: Optional[str], model_name: str, verbose: bool, mode: str, task: O
140
157
  console.print("[yellow]Task submission cancelled. Exiting...[/yellow]")
141
158
  sys.exit(0)
142
159
 
160
+ logger.debug(f"Creating agent for mode: {mode} with model: {model_name}")
143
161
  agent = create_agent_for_mode(mode, model_name)
162
+ logger.debug(f"Created agent for mode: {mode} with model: {model_name}")
163
+
164
+ events = [
165
+ "task_start",
166
+ "task_think_start",
167
+ "task_think_end",
168
+ "task_complete",
169
+ "tool_execution_start",
170
+ "tool_execution_end",
171
+ "error_max_iterations_reached",
172
+ "memory_full",
173
+ "memory_compacted",
174
+ "memory_summary",
175
+ ]
144
176
  agent.event_emitter.on(
145
- [
146
- "task_complete",
147
- "task_think_start",
148
- "task_think_end",
149
- "tool_execution_start",
150
- "tool_execution_end",
151
- "error_max_iterations_reached",
152
- "memory_full",
153
- "memory_compacted",
154
- "memory_summary",
155
- ],
156
- console_print_events,
177
+ event=events,
178
+ listener=console_print_events,
157
179
  )
180
+ logger.debug("Registered event handlers for agent events with events: {events}")
158
181
 
182
+ logger.debug(f"Solving task with agent: {task_content}")
159
183
  result = agent.solve_task(task=task_content, max_iterations=300)
184
+ logger.debug(f"Task solved with result: {result}")
160
185
 
161
186
  console.print(
162
187
  Panel.fit(
@@ -166,6 +191,7 @@ def task(file: Optional[str], model_name: str, verbose: bool, mode: str, task: O
166
191
 
167
192
  except Exception as e:
168
193
  console.print(f"[red]{str(e)}[/red]")
194
+ logger.error(f"Error in task execution: {e}", exc_info=True)
169
195
  sys.exit(1)
170
196
 
171
197
 
quantalogic/version.py CHANGED
@@ -1,4 +1,4 @@
1
1
 
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.4"
3
3
  def get_version() -> str:
4
4
  return VERSION
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quantalogic
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: QuantaLogic ReAct Agents
5
5
  Author: Raphaël MANSUY
6
6
  Author-email: raphael.mansuy@gmail.com
@@ -1,11 +1,11 @@
1
1
  quantalogic/__init__.py,sha256=HFk7_19UzHzYwvPzb9QTQ4w_lPwTTPda61AYb8qggZY,686
2
- quantalogic/agent.py,sha256=TzSnVWatyAcfIPo-hESubB-0nlhr82-7fIneajaIG3M,25179
2
+ quantalogic/agent.py,sha256=pvXwJepJMRvkn5DX01b2R77mBSpfQI57mi81s4SN0xY,25196
3
3
  quantalogic/agent_config.py,sha256=sNuZ0Y02h3ra2hcjAE3-8Tt-NE8QSarRsTB0auTLgn0,3595
4
4
  quantalogic/coding_agent.py,sha256=ivHBn3hIDEt9V1LDXI4l-COeGXYVp_v_rrx9ng8sP2A,3214
5
5
  quantalogic/event_emitter.py,sha256=jqot2g4JRXc88K6PW837Oqxbf7shZfO-xdPaUWmzupk,7901
6
6
  quantalogic/generative_model.py,sha256=JkZz7YBd-v9n5EURidKUddkCLNvNZaqMzo5PgE_ugmc,8398
7
7
  quantalogic/interactive_text_editor.py,sha256=kYeTA2qej5kxtPvAUHy_Dr2MhrGQAyenLFpW9mU9Rmw,6855
8
- quantalogic/main.py,sha256=lN2lOQeZSIFBZOkgJ8CmHA_TWrGj6OM_dB8OqNrIkhY,6317
8
+ quantalogic/main.py,sha256=PvSf_V-BSQpFSCKSgDIB6DaUCab8ECDd0QWgnWbw0Js,7564
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=-4qZmFI2BTkXuGE9DoKm6Vs-GzK1F9WJGt9GqpRQlQQ,2175
@@ -59,11 +59,11 @@ quantalogic/utils/get_quantalogic_rules_content.py,sha256=fnEFTyClXzpI0MLaM-gB9R
59
59
  quantalogic/utils/git_ls.py,sha256=_aXg2TwqYv9CoOrhQ1gqHCqu1j8wOVigQNWbGncSDlM,4361
60
60
  quantalogic/utils/read_file.py,sha256=tSRVHk8dIP4nNLL89v5kRki4hOTjVyjbmuEb2zwvwCY,2077
61
61
  quantalogic/utils/read_http_text_content.py,sha256=1nRLQ9DHP_fKrm0rIEJBF0ROmB78e4lct2hUzD2PAUk,4408
62
- quantalogic/version.py,sha256=KCMp_VO1Gh1okgz_ysyGPoR0Sw0FpFSFimW1hvAms6s,64
62
+ quantalogic/version.py,sha256=H_M9VsTe7G2HeD8XedH6FDu8L351L1RYdBHbbXQpNL8,64
63
63
  quantalogic/xml_parser.py,sha256=cTRorr5sVfkIzH72M0C-GQ9ROGPiz2FTT66U9ndjzhE,9538
64
64
  quantalogic/xml_tool_parser.py,sha256=lsVzClZBrZan7wjCuCKnGHWzksXI3VMy_vWthxu2_bo,3738
65
- quantalogic-0.2.2.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
66
- quantalogic-0.2.2.dist-info/METADATA,sha256=nK98IudCDiahREJnwwdiLI-B7flWMhYrpHtVTphpFYY,38601
67
- quantalogic-0.2.2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
68
- quantalogic-0.2.2.dist-info/entry_points.txt,sha256=wgSq5SRU98yvlRHGEZD1Xn7sS5CSjH2RfUtTa6Qy28Q,52
69
- quantalogic-0.2.2.dist-info/RECORD,,
65
+ quantalogic-0.2.4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
66
+ quantalogic-0.2.4.dist-info/METADATA,sha256=d93jsS31zo9A5kTwe3PsSLyvLvwRw_pnIEwC7wziHV8,38601
67
+ quantalogic-0.2.4.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
68
+ quantalogic-0.2.4.dist-info/entry_points.txt,sha256=wgSq5SRU98yvlRHGEZD1Xn7sS5CSjH2RfUtTa6Qy28Q,52
69
+ quantalogic-0.2.4.dist-info/RECORD,,