quantalogic 0.50.28__py3-none-any.whl → 0.51.0__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.
@@ -0,0 +1,700 @@
1
+ Metadata-Version: 2.1
2
+ Name: quantalogic
3
+ Version: 0.51.0
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: beautifulsoup4 (>=4.12.3,<5.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: faker (>=36.1.1,<37.0.0)
15
+ Requires-Dist: fuzzywuzzy (>=0.18.0,<0.19.0)
16
+ Requires-Dist: google-search-results (>=2.4.2,<3.0.0)
17
+ Requires-Dist: html2text (>=2024.2.26,<2025.0.0)
18
+ Requires-Dist: instructor (>=1.7.2,<2.0.0)
19
+ Requires-Dist: jinja2 (>=3.1.5,<4.0.0)
20
+ Requires-Dist: litellm (>=1.56.4,<2.0.0)
21
+ Requires-Dist: loguru (>=0.7.3,<0.8.0)
22
+ Requires-Dist: markdownify (>=0.14.1,<0.15.0)
23
+ Requires-Dist: markitdown (>=0.0.1a3,<0.0.2)
24
+ Requires-Dist: networkx (>=3.2.1,<4.0.0)
25
+ Requires-Dist: pathspec (>=0.12.1,<0.13.0)
26
+ Requires-Dist: prompt-toolkit (>=3.0.48,<4.0.0)
27
+ Requires-Dist: pydantic (>=2.10.4,<3.0.0)
28
+ Requires-Dist: python-dotenv (>=1.0.1,<2.0.0)
29
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
30
+ Requires-Dist: rich (>=13.9.4,<14.0.0)
31
+ Requires-Dist: serpapi (>=0.1.5,<0.2.0)
32
+ Requires-Dist: sqlalchemy (>=2.0.25,<3.0.0)
33
+ Requires-Dist: tenacity (>=9.0.0,<10.0.0)
34
+ Requires-Dist: tree-sitter (>=0.23.2,<0.24.0)
35
+ Requires-Dist: tree-sitter-c (>=0.23.4,<0.24.0)
36
+ Requires-Dist: tree-sitter-cpp (>=0.23.4,<0.24.0)
37
+ Requires-Dist: tree-sitter-go (>=0.23.4,<0.24.0)
38
+ Requires-Dist: tree-sitter-java (>=0.23.5,<0.24.0)
39
+ Requires-Dist: tree-sitter-javascript (>=0.23.1,<0.24.0)
40
+ Requires-Dist: tree-sitter-python (>=0.23.6,<0.24.0)
41
+ Requires-Dist: tree-sitter-rust (>=0.23.2,<0.24.0)
42
+ Requires-Dist: tree-sitter-scala (>=0.23.4,<0.24.0)
43
+ Requires-Dist: tree-sitter-typescript (>=0.23.2,<0.24.0)
44
+ Requires-Dist: types-pyyaml (>=6.0.12.20241230,<7.0.0.0)
45
+ Description-Content-Type: text/markdown
46
+
47
+ # QuantaLogic
48
+
49
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
50
+ [![Python](https://img.shields.io/badge/Python-3.12+-blue.svg)](https://www.python.org/downloads/)
51
+ [![Documentation](https://img.shields.io/badge/docs-latest-brightgreen.svg)](https://quantalogic.github.io/quantalogic/)
52
+
53
+ Hey there, welcome to **QuantaLogic**—your cosmic toolkit for crafting AI agents and workflows that shine! Whether you’re coding up a storm, automating a business process, or dreaming up something wild, QuantaLogic is here to make it happen. We’re talking **large language models (LLMs)** fused with a stellar toolset, featuring two powerhouse approaches: the **ReAct framework** for dynamic problem-solving and the dazzling new **Flow module** for structured brilliance.
54
+
55
+ Picture this: a CLI that’s as easy as a snap, a Python API that’s pure magic, and a framework that scales from quick hacks to galactic enterprises. Ready to launch? Let’s blast off!
56
+
57
+ [ Full Docs](https://quantalogic.github.io/quantalogic/) | [ How-To Guide](./docs/howto/howto.md)
58
+
59
+ ![Video Demo](./examples/generated_tutorials/python/quantalogic_8s.gif)
60
+
61
+ ---
62
+
63
+ ## Why QuantaLogic?
64
+
65
+ At [QuantaLogic](https://www.quantalogic.app), we spotted a black hole: amazing AI models from OpenAI, Anthropic, and DeepSeek weren’t fully lighting up real-world tasks. Our mission? Ignite that spark! We’re here to make generative AI a breeze for developers, businesses, and dreamers alike—turning ideas into action, one brilliant solution at a time.
66
+
67
+ > "AI should be your co-pilot, not a puzzle. QuantaLogic makes it happen—fast, fun, and fearless!"
68
+
69
+ ---
70
+
71
+ ## Key Features
72
+
73
+ - **ReAct Framework**: Reasoning + action = unstoppable agents!
74
+ - **Flow Module**: Structured workflows that flow like a river.
75
+ - **LLM Galaxy**: Tap into OpenAI, DeepSeek, and more via LiteLLM.
76
+ - **Secure Tools**: Docker-powered safety for code and files.
77
+ - **Live Monitoring**: Watch it unfold with a web interface and SSE.
78
+ - **Memory Magic**: Smart context keeps things snappy.
79
+ - **Enterprise-Ready**: Logs, error handling, and validation—rock solid.
80
+
81
+ ---
82
+
83
+ ## Table of Contents
84
+
85
+ - [Why QuantaLogic?](#why-quantalogic)
86
+ - [Key Features](#key-features)
87
+ - [Installation](#installation)
88
+ - [Quick Start](#quick-start)
89
+ - [ReAct Framework: Dynamic Agents](#react-framework-dynamic-agents)
90
+ - [Flow Module: Structured Workflows](#flow-module-structured-workflows)
91
+ - [ReAct vs. Flow: Pick Your Power](#react-vs-flow-pick-your-power)
92
+ - [Using the CLI](#using-the-cli)
93
+ - [Examples That Spark Joy](#examples-that-spark-joy)
94
+ - [Core Components](#core-components)
95
+ - [Developing with QuantaLogic](#developing-with-quantalogic)
96
+ - [Contributing](#contributing)
97
+ - [License](#license)
98
+ - [Project Growth](#project-growth)
99
+ - [API Keys and Environment Configuration](#api-keys-and-environment-configuration)
100
+
101
+ ---
102
+
103
+ ## Installation
104
+
105
+ Let’s get QuantaLogic orbiting your system—it’s as easy as 1-2-3!
106
+
107
+ ### What You’ll Need
108
+ - **Python 3.12+**: The fuel for our rocket.
109
+ - **Docker** (optional): Locks down code execution in a safe pod.
110
+
111
+ ### Option 1: pip—Fast and Simple
112
+ ```bash
113
+ pip install quantalogic
114
+ ```
115
+
116
+ ### Option 2: pipx—Isolated Stardust
117
+ ```bash
118
+ pipx install quantalogic
119
+ ```
120
+
121
+ ### Option 3: Source—For Space Explorers
122
+ ```bash
123
+ git clone https://github.com/quantalogic/quantalogic.git
124
+ cd quantalogic
125
+ python -m venv .venv
126
+ source .venv/bin/activate # Windows: .venv\Scripts\activate
127
+ poetry install
128
+ ```
129
+ > **Tip**: No Poetry? Grab it with `pip install poetry` and join the crew!
130
+
131
+ ---
132
+
133
+ ## Quick Start
134
+
135
+ Ready to see the magic? Here’s your launchpad:
136
+
137
+ ### CLI: Instant Action
138
+ ```bash
139
+ quantalogic task "Write a Python function for Fibonacci numbers"
140
+ ```
141
+ > Boom! ReAct whips up a solution in seconds.
142
+
143
+ ### Python: ReAct Agent
144
+ ```python
145
+ from quantalogic import Agent
146
+
147
+ agent = Agent(model_name="deepseek/deepseek-chat")
148
+ result = agent.solve_task("Code a Fibonacci function")
149
+ print(result)
150
+ # Output: "def fib(n): return [0, 1] if n <= 2 else fib(n-1) + [fib(n-1)[-1] + fib(n-1)[-2]]"
151
+ ```
152
+
153
+ ### Synchronous Agent Example
154
+
155
+ ```python
156
+ from quantalogic import Agent
157
+
158
+ # Create a synchronous agent
159
+ agent = Agent(model_name="gpt-4o")
160
+
161
+ # Solve a task synchronously
162
+ result = agent.solve_task(
163
+ task="Write a Python function to calculate Fibonacci numbers",
164
+ max_iterations=10 # Optional: limit iterations
165
+ )
166
+
167
+ print(result)
168
+ ```
169
+
170
+ ### Async Agent Example 🌊
171
+
172
+ ```python
173
+ import asyncio
174
+ from quantalogic import Agent
175
+
176
+ async def main():
177
+ # Create an async agent
178
+ agent = Agent(model_name="gpt-4o")
179
+
180
+ # Solve a task asynchronously with streaming
181
+ result = await agent.async_solve_task(
182
+ task="Write a Python script to scrape top GitHub repositories",
183
+ max_iterations=15, # Optional: limit iterations
184
+ streaming=True # Optional: stream the response
185
+ )
186
+
187
+ print(result)
188
+
189
+ # Run the async function
190
+ asyncio.run(main())
191
+ ```
192
+
193
+ ### Event Monitoring Examples 🔍
194
+
195
+ #### Synchronous Event Monitoring with Finance Tools
196
+ ```python
197
+ from quantalogic import Agent
198
+ from quantalogic.console_print_events import console_print_events
199
+ from quantalogic.console_print_token import console_print_token
200
+ from quantalogic.tools import (
201
+ DuckDuckGoSearchTool,
202
+ TechnicalAnalysisTool,
203
+ YFinanceTool
204
+ )
205
+
206
+ # Create an agent with finance-related tools
207
+ agent = Agent(
208
+ model_name="gpt-4o",
209
+ tools=[
210
+ DuckDuckGoSearchTool(), # Web search tool
211
+ TechnicalAnalysisTool(), # Stock technical analysis
212
+ YFinanceTool() # Stock data retrieval
213
+ ]
214
+ )
215
+
216
+ # Set up comprehensive event listeners
217
+ agent.event_emitter.on(
218
+ event=[
219
+ "task_complete",
220
+ "task_think_start",
221
+ "task_think_end",
222
+ "tool_execution_start",
223
+ "tool_execution_end",
224
+ "error_max_iterations_reached",
225
+ "memory_full",
226
+ "memory_compacted"
227
+ ],
228
+ listener=console_print_events
229
+ )
230
+
231
+ # Optional: Monitor streaming tokens
232
+ agent.event_emitter.on(
233
+ event=["stream_chunk"],
234
+ listener=console_print_token
235
+ )
236
+
237
+ # Execute a multi-step financial analysis task
238
+ result = agent.solve_task(
239
+ "1. Find the top 3 tech stocks for Q3 2024 "
240
+ "2. Retrieve historical stock data for each "
241
+ "3. Calculate 50-day and 200-day moving averages "
242
+ "4. Provide a brief investment recommendation",
243
+ streaming=True # Enable streaming for detailed output
244
+ )
245
+ print(result)
246
+ ```
247
+
248
+ #### Async Event Monitoring with Finance Tools
249
+ ```python
250
+ import asyncio
251
+ from quantalogic import Agent
252
+ from quantalogic.console_print_events import console_print_events
253
+ from quantalogic.console_print_token import console_print_token
254
+ from quantalogic.tools import (
255
+ DuckDuckGoSearchTool,
256
+ TechnicalAnalysisTool,
257
+ YFinanceTool
258
+ )
259
+
260
+ async def main():
261
+ # Create an async agent with finance-related tools
262
+ agent = Agent(
263
+ model_name="gpt-4o",
264
+ tools=[
265
+ DuckDuckGoSearchTool(), # Web search tool
266
+ TechnicalAnalysisTool(), # Stock technical analysis
267
+ YFinanceTool() # Stock data retrieval
268
+ ]
269
+ )
270
+
271
+ # Set up comprehensive event listeners
272
+ agent.event_emitter.on(
273
+ event=[
274
+ "task_complete",
275
+ "task_think_start",
276
+ "task_think_end",
277
+ "tool_execution_start",
278
+ "tool_execution_end",
279
+ "error_max_iterations_reached",
280
+ "memory_full",
281
+ "memory_compacted"
282
+ ],
283
+ listener=console_print_events
284
+ )
285
+
286
+ # Optional: Monitor streaming tokens
287
+ agent.event_emitter.on(
288
+ event=["stream_chunk"],
289
+ listener=console_print_token
290
+ )
291
+
292
+ # Execute a multi-step financial analysis task asynchronously
293
+ result = await agent.async_solve_task(
294
+ "1. Find emerging AI technology startups "
295
+ "2. Analyze their recent funding rounds "
296
+ "3. Compare market potential and growth indicators "
297
+ "4. Provide an investment trend report",
298
+ streaming=True # Enable streaming for detailed output
299
+ )
300
+ print(result)
301
+
302
+ # Run the async function
303
+ asyncio.run(main())
304
+ ```
305
+
306
+ ### Python: Flow Workflow
307
+ ```python
308
+ from quantalogic.flow import Workflow, Nodes
309
+
310
+ @Nodes.define(output="greeting")
311
+ def greet(name: str) -> str:
312
+ return f"Hello, {name}!"
313
+
314
+ workflow = Workflow("greet").build()
315
+ result = await workflow.run({"name": "Luna"})
316
+ print(result["greeting"]) # "Hello, Luna!"
317
+ ```
318
+
319
+ ---
320
+
321
+ ## ReAct Framework: Dynamic Agents
322
+
323
+ The **ReAct** framework is your AI sidekick—think fast, act smart. It pairs LLM reasoning with tool-powered action, perfect for tasks that need a bit of improvisation.
324
+
325
+ ### How It Rolls
326
+ 1. **You Say**: "Write me a script."
327
+ 2. **It Thinks**: LLM plots the course.
328
+ 3. **It Acts**: Tools like `PythonTool` get to work.
329
+ 4. **It Loops**: Keeps going until it’s done.
330
+
331
+ Check this out:
332
+
333
+ ```mermaid
334
+ graph TD
335
+ A[You: 'Write a script'] --> B[ReAct Agent]
336
+ B --> C{Reason with LLM}
337
+ C --> D[Call Tools]
338
+ D --> E[Get Results]
339
+ E --> F{Task Done?}
340
+ F -->|No| C
341
+ F -->|Yes| G[Deliver Answer]
342
+ G --> H[You: Happy!]
343
+ style A fill:#f9f,stroke:#333
344
+ style H fill:#bbf,stroke:#333
345
+ ```
346
+
347
+ ### Example: Code Generator
348
+ ```bash
349
+ quantalogic task "Create a Python script to sort a list"
350
+ ```
351
+ > ReAct figures it out, writes the code, and hands it over—smooth as silk!
352
+
353
+ ### Why It’s Cool
354
+ Perfect for coding, debugging, or answering wild questions on the fly.
355
+
356
+ ---
357
+
358
+ ## Flow Module: Structured Workflows
359
+
360
+ The **Flow module** is your architect—building workflows that hum with precision. It’s all about nodes, transitions, and a steady rhythm, ideal for repeatable missions.
361
+
362
+ ### The Building Blocks
363
+ - **Nodes**: Tasks like functions or LLM calls.
364
+ - **Transitions**: Paths with optional conditions.
365
+ - **Engine**: Runs the show with flair.
366
+ - **Observers**: Peek at progress with events.
367
+
368
+ ### Example: Story Weaver
369
+ ```python
370
+ from quantalogic.flow import Workflow, Nodes
371
+
372
+ @Nodes.llm_node(model="openai/gpt-4o-mini", output="chapter")
373
+ async def write_chapter(ctx: dict) -> str:
374
+ return f"Chapter 1: {ctx['theme']}"
375
+
376
+ workflow = (
377
+ Workflow("write_chapter")
378
+ .then("end", condition="lambda ctx: True")
379
+ .add_observer(lambda e: print(f" {e.event_type}"))
380
+ )
381
+ engine = workflow.build()
382
+ result = await engine.run({"theme": "Cosmic Quest"})
383
+ print(result["chapter"])
384
+ ```
385
+
386
+ ### Example: Story Generator Agent
387
+
388
+ Here's a more complex example showing a complete story generation workflow using the Flow module:
389
+
390
+ ```python
391
+ from typing import List
392
+ import anyio
393
+ from loguru import logger
394
+ from quantalogic.flow import Nodes, Workflow
395
+
396
+ # Define node functions with decorators
397
+ @Nodes.validate_node(output="validation_result")
398
+ async def validate_input(genre: str, num_chapters: int) -> str:
399
+ """Validate input parameters."""
400
+ if not (1 <= num_chapters <= 20 and genre.lower() in ["science fiction", "fantasy", "mystery", "romance"]):
401
+ raise ValueError("Invalid input: genre must be one of science fiction, fantasy, mystery, romance")
402
+ return "Input validated"
403
+
404
+ @Nodes.llm_node(
405
+ model="gemini/gemini-2.0-flash",
406
+ system_prompt="You are a creative writer specializing in story titles.",
407
+ prompt_template="Generate a creative title for a {{ genre }} story. Output only the title.",
408
+ output="title",
409
+ )
410
+ async def generate_title(genre: str) -> str:
411
+ """Generate a title based on the genre (handled by llm_node)."""
412
+ pass # Logic handled by llm_node decorator
413
+
414
+ @Nodes.define(output="manuscript")
415
+ async def compile_book(title: str, outline: str, chapters: List[str]) -> str:
416
+ """Compile the full manuscript from title, outline, and chapters."""
417
+ return f"Title: {title}\n\nOutline:\n{outline}\n\n" + "\n\n".join(
418
+ f"Chapter {i}:\n{chap}" for i, chap in enumerate(chapters, 1)
419
+ )
420
+
421
+ # Define the workflow with conditional branching
422
+ workflow = (
423
+ Workflow("validate_input")
424
+ .then("generate_title")
425
+ .then("generate_outline")
426
+ .then("generate_chapter")
427
+ .then("update_chapter_progress")
428
+ .then("generate_chapter", condition=lambda ctx: ctx["completed_chapters"] < ctx["num_chapters"])
429
+ .then("compile_book", condition=lambda ctx: ctx["completed_chapters"] >= ctx["num_chapters"])
430
+ .then("quality_check")
431
+ .then("end")
432
+ )
433
+
434
+ # Run the workflow
435
+ async def main():
436
+ initial_context = {
437
+ "genre": "science fiction",
438
+ "num_chapters": 3,
439
+ "chapters": [],
440
+ "completed_chapters": 0,
441
+ }
442
+ engine = workflow.build()
443
+ result = await engine.run(initial_context)
444
+ ```
445
+
446
+ This example demonstrates:
447
+ - Input validation with `@Nodes.validate_node`
448
+ - LLM integration with `@Nodes.llm_node`
449
+ - Custom processing with `@Nodes.define`
450
+ - Conditional branching for iterative chapter generation
451
+ - Context management for tracking progress
452
+
453
+ The full example is available at [examples/flow/story_generator_agent.py](./examples/flow/story_generator_agent.py).
454
+
455
+ ### Flow Visualized
456
+ ```mermaid
457
+ graph LR
458
+ A[Start] --> B[WriteChapter]
459
+ B -->|Condition: True| C[End]
460
+ subgraph WriteChapter
461
+ D[Call LLM] --> E[Save Chapter]
462
+ end
463
+ A -->|Observer| F[Log: NODE_STARTED]
464
+ B -->|Observer| G[Log: NODE_COMPLETED]
465
+ style A fill:#dfd,stroke:#333
466
+ style C fill:#dfd,stroke:#333
467
+ style B fill:#ffb,stroke:#333
468
+ ```
469
+
470
+ ### Example: Data Pipeline
471
+ ```python
472
+ @Nodes.define(output="processed")
473
+ def clean_data(data: str) -> str:
474
+ return data.strip().upper()
475
+
476
+ workflow = Workflow("clean_data").build()
477
+ result = await workflow.run({"data": " hello "})
478
+ print(result["processed"]) # "HELLO"
479
+ ```
480
+
481
+ ### Why It Rocks
482
+ Think content pipelines, automation flows, or any multi-step task that needs order.
483
+
484
+ ---
485
+
486
+ ## ReAct vs. Flow: Pick Your Power
487
+
488
+ Both are stellar, but here’s the scoop:
489
+
490
+ | Feature | ReAct Framework | Flow Module |
491
+ |---------------------|--------------------------------|--------------------------------|
492
+ | **Vibe** | Free-spirited, adaptive | Organized, predictable |
493
+ | **Flow** | Loops ‘til it’s solved | Follows a roadmap |
494
+ | **Sweet Spot** | Creative chaos (coding, Q&A) | Steady workflows (pipelines) |
495
+ | **State** | Memory keeps it loose | Nodes lock it down |
496
+ | **Tools** | Grabbed as needed | Baked into nodes |
497
+ | **Watch It** | Events like `task_complete` | Observers like `NODE_STARTED` |
498
+
499
+ ### When to Choose
500
+ - **ReAct**: Code on-the-fly, explore answers, debug like a pro.
501
+ - **Flow**: Build a pipeline, automate a process, keep it tight.
502
+
503
+ ---
504
+
505
+ ## Using the CLI
506
+
507
+ The CLI is your command center—fast, flexible, and fun!
508
+
509
+ ### Syntax
510
+ ```bash
511
+ quantalogic [OPTIONS] COMMAND [ARGS]...
512
+ ```
513
+
514
+ ### Description
515
+ QuantaLogic AI Assistant - A powerful AI tool for various tasks.
516
+
517
+ ### Environment Variables
518
+ - **OpenAI**: Set `OPENAI_API_KEY` to your OpenAI API key
519
+ - **Anthropic**: Set `ANTHROPIC_API_KEY` to your Anthropic API key
520
+ - **DeepSeek**: Set `DEEPSEEK_API_KEY` to your DeepSeek API key
521
+
522
+ Use a `.env` file or export these variables in your shell for seamless integration.
523
+
524
+ ### Commands
525
+ - **`task`**: Kick off a mission.
526
+ ```bash
527
+ quantalogic task "Summarize this file" --file notes.txt
528
+ ```
529
+ - **`list-models`**: List supported LiteLLM models with optional fuzzy search.
530
+ ```bash
531
+ quantalogic list-models --search "gpt"
532
+ ```
533
+
534
+ ### Options
535
+ - **`--model-name TEXT`**: Specify the model to use (litellm format). Examples:
536
+ - `openai/gpt-4o-mini`
537
+ - `openai/gpt-4o`
538
+ - `anthropic/claude-3.5-sonnet`
539
+ - `deepseek/deepseek-chat`
540
+ - `deepseek/deepseek-reasoner`
541
+ - `openrouter/deepseek/deepseek-r1`
542
+ - `openrouter/openai/gpt-4o`
543
+ - **`--mode [code|basic|interpreter|full|code-basic|search|search-full]`**: Agent mode
544
+ - **`--vision-model-name TEXT`**: Specify the vision model to use (litellm format)
545
+ - **`--log [info|debug|warning]`**: Set logging level
546
+ - **`--verbose`**: Enable verbose output
547
+ - **`--max-iterations INTEGER`**: Maximum number of iterations (default: 30)
548
+ - **`--max-tokens-working-memory INTEGER`**: Set the maximum tokens allowed in working memory
549
+ - **`--compact-every-n-iteration INTEGER`**: Set the frequency of memory compaction
550
+ - **`--thinking-model TEXT`**: The thinking model to use
551
+ - **`--version`**: Show version information
552
+
553
+ > **Tip**: Run `quantalogic --help` for the complete command reference!
554
+
555
+ ---
556
+
557
+ ## Examples That Spark Joy
558
+
559
+ Let’s light up your imagination with these gems:
560
+
561
+ ### Video Magic
562
+ [![Tutorial Demo](./examples/generated_tutorials/python/quantalogic_long.mp4)](./examples/generated_tutorials/python/quantalogic_long.mp4)
563
+
564
+ ### Hands-On Examples
565
+ | Name | What’s It Do? | File |
566
+ |-------------------|------------------------------------|--------------------------------------------|
567
+ | Simple Agent | Basic ReAct agent demo | [01-simple-agent.py](./examples/01-simple-agent.py) |
568
+ | Event Monitoring | Agent with event tracking | [02-agent-with-event-monitoring.py](./examples/02-agent-with-event-monitoring.py) |
569
+ | Interpreter Mode | Agent with interpreter | [03-agent-with-interpreter.py](./examples/03-agent-with-interpreter.py) |
570
+ | Agent Summary | Task summary generation | [04-agent-summary-task.py](./examples/04-agent-summary-task.py) |
571
+ | Code Generation | Basic code generation | [05-code.py](./examples/05-code.py) |
572
+ | Code Screen | Advanced code generation | [06-code-screen.py](./examples/06-code-screen.py) |
573
+ | Tutorial Writer | Write technical tutorials | [07-write-tutorial.py](./examples/07-write-tutorial.py) |
574
+ | PRD Writer | Product Requirements Document | [08-prd-writer.py](./examples/08-prd-writer.py) |
575
+ | Story Generator | Flow-based story creation | [story_generator_agent.py](./examples/flow/story_generator_agent.py) |
576
+ | SQL Query | Database query generation | [09-sql-query.py](./examples/09-sql-query.py) |
577
+ | Finance Agent | Financial analysis and tasks | [10-finance-agent.py](./examples/10-finance-agent.py) |
578
+ | Textual Interface | Agent with textual UI | [11-textual-agent-interface.py](./examples/11-textual-agent-interface.py) |
579
+ | Composio Test | Composio integration demo | [12-composio-test.py](./examples/12-composio-test.py) |
580
+ | Synchronous Agent | Synchronous agent demo | [13-synchronous-agent.py](./examples/13-synchronous-agent.py) |
581
+ | Async Agent | Async agent demo | [14-async-agent.py](./examples/14-async-agent.py) |
582
+
583
+ ### Bonus: Math Whiz
584
+ ```bash
585
+ quantalogic task "Solve 2x + 5 = 15"
586
+ ```
587
+ > Output: "Let’s solve it! 2x + 5 = 15 → 2x = 10 → x = 5. Done!"
588
+
589
+ ---
590
+
591
+ ## Core Components
592
+
593
+ ### ReAct Agents
594
+ - **Brain**: LLMs power the thinking.
595
+ - **Hands**: Tools like `PythonTool` do the work.
596
+ - **Memory**: Ties it all together.
597
+
598
+ ### Flow Workflows
599
+ - **Nodes**: Your task blocks.
600
+ - **Engine**: The maestro of execution.
601
+
602
+ ### Tools Arsenal
603
+ - **Code**: `PythonTool`, `NodeJsTool`.
604
+ - **Files**: `ReadFileTool`, `WriteFileTool`.
605
+ - More in [REFERENCE_TOOLS.md](./REFERENCE_TOOLS.md).
606
+
607
+ ---
608
+
609
+ ## Developing with QuantaLogic
610
+
611
+ ### Setup Your Lab
612
+ ```bash
613
+ git clone https://github.com/quantalogic/quantalogic.git
614
+ cd quantalogic
615
+ python -m venv venv
616
+ source venv/bin/activate
617
+ poetry install
618
+ ```
619
+
620
+ ### Test the Cosmos
621
+ ```bash
622
+ pytest --cov=quantalogic
623
+ ```
624
+
625
+ ### Polish It Up
626
+ ```bash
627
+ ruff format # Shine that code
628
+ mypy quantalogic # Check types
629
+ ruff check quantalogic # Lint it
630
+ ```
631
+
632
+ ---
633
+
634
+ ## Contributing
635
+
636
+ Join the QuantaLogic galaxy!
637
+ 1. Fork it.
638
+ 2. Branch: `git checkout -b feature/epic-thing`.
639
+ 3. Code + test.
640
+ 4. PR it!
641
+
642
+ See [CONTRIBUTING.md](./CONTRIBUTING.md) for the full scoop.
643
+
644
+ ---
645
+
646
+ ## License
647
+
648
+ 2024 QuantaLogic Contributors. **Apache 2.0**—free and open. Check [LICENSE](./LICENSE).
649
+
650
+ Dreamed up by Raphaël MANSUY, founder of [QuantaLogic](https://www.quantalogic.app).
651
+
652
+ ---
653
+
654
+ ## Project Growth
655
+ [![Star History Chart](https://api.star-history.com/svg?repos=quantalogic/quantalogic&type=Date)](https://star-history.com/#quantalogic/quantalogic&Date)
656
+
657
+ ---
658
+
659
+ ## API Keys and Environment Configuration
660
+
661
+ QuantaLogic links to LLMs via API keys—here’s your guide to unlocking the universe!
662
+
663
+ ### Setting Up Keys
664
+ Store keys in a `.env` file or export them:
665
+ ```bash
666
+ echo "OPENAI_API_KEY=sk-your-openai-key" > .env
667
+ echo "DEEPSEEK_API_KEY=ds-your-deepseek-key" >> .env
668
+ source .env
669
+ ```
670
+
671
+ ### The Key Vault: Supported Models
672
+ | Model Name | Key Variable | What’s It Good For? |
673
+ |-----------------------------------------|--------------------------|-----------------------------------------------|
674
+ | `openai/gpt-4o-mini` | `OPENAI_API_KEY` | Speedy, budget-friendly tasks |
675
+ | `openai/gpt-4o` | `OPENAI_API_KEY` | Heavy-duty reasoning |
676
+ | `anthropic/claude-3.5-sonnet` | `ANTHROPIC_API_KEY` | Balanced brilliance |
677
+ | `deepseek/deepseek-chat` | `DEEPSEEK_API_KEY` | Chatty and versatile |
678
+ | `deepseek/deepseek-reasoner` | `DEEPSEEK_API_KEY` | Deep problem-solving |
679
+ | `openrouter/deepseek/deepseek-r1` | `OPENROUTER_API_KEY` | Research-grade via OpenRouter |
680
+ | `mistral/mistral-large-2407` | `MISTRAL_API_KEY` | Multilingual mastery |
681
+ | `dashscope/qwen-max` | `DASHSCOPE_API_KEY` | Alibaba’s power player |
682
+ | `lm_studio/mistral-small-24b-instruct-2501` | `LM_STUDIO_API_KEY` | Local LLM action |
683
+
684
+ ### Local Setup (e.g., LM Studio)
685
+ ```bash
686
+ export LM_STUDIO_API_BASE="http://localhost:1234/v1"
687
+ export LM_STUDIO_API_KEY="lm-your-key"
688
+ ```
689
+
690
+ ### Pro Tips
691
+ - **Security**: Keep keys in `.env`, not code!
692
+ - **Extras**: Add `OPENROUTER_REFERRER` for OpenRouter flair.
693
+ - **More**: Dig into [LiteLLM Docs](https://docs.litellm.ai/docs/).
694
+
695
+ ---
696
+
697
+ ## Final Boost
698
+
699
+ QuantaLogic is your ticket to AI awesomeness. Install it, play with it, and let’s build something unforgettable together!
700
+