lenzcom commited on
Commit
709049e
Β·
verified Β·
1 Parent(s): e706de2

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +117 -106
README.md CHANGED
@@ -1,7 +1,16 @@
 
 
 
 
 
 
 
 
 
1
  > **Read the full interactive version:**
2
- > This repository is part of **AI Agents From Scratch** - a hands-on learning series where we build AI agents *step by step*, explain every design decision, and visualize what’s happening under the hood.
3
  >
4
- > πŸ‘‰ **https://agentsfromscratch.com**
5
  >
6
  > If you prefer **long-form explanations, diagrams, and conceptual deep dives**, start there - then come back here to explore the code.
7
 
@@ -38,7 +47,7 @@ Learn AI product development fundamentals with local LLMs. Covers prompt enginee
38
  ## Next Phase: Build LangChain & LangGraph Concepts From Scratch
39
 
40
  > After mastering the fundamentals, the next stage of this project walks you through **re-implementing the core parts of LangChain and LangGraph** in plain JavaScript using local models.
41
- > This is **not** about building a new framework, it’s about understanding *how frameworks work*.
42
 
43
  ## Phase 1: Agent Fundamentals - From LLMs to ReAct
44
 
@@ -170,7 +179,7 @@ Follow these examples in order to build understanding progressively:
170
  `react-agent/` | [Code](examples/09_react-agent/react-agent.js) | [Code Explanation](examples/09_react-agent/CODE.md) | [Concepts](examples/09_react-agent/CONCEPT.md)
171
 
172
  **What you'll learn:**
173
- - ReAct pattern (Reason β†’ Act β†’ Observe)
174
  - Iterative problem solving
175
  - Step-by-step tool use
176
  - Self-correction loops
@@ -216,52 +225,52 @@ Each example folder contains:
216
 
217
  ```
218
  AI Agent = LLM + System Prompt + Tools + Memory + Reasoning Pattern
219
- ─┬─ ──────┬────── ──┬── ──┬─── ────────┬────────
220
- β”‚ β”‚ β”‚ β”‚ β”‚
221
  Brain Identity Hands State Strategy
222
  ```
223
 
224
  ### Evolution of Capabilities
225
 
226
  ```
227
- 1. intro β†’ Basic LLM usage
228
- 2. translation β†’ Specialized behavior (system prompts)
229
- 3. think β†’ Reasoning ability
230
- 4. batch β†’ Parallel processing
231
- 5. coding β†’ Streaming & control
232
- 6. simple-agent β†’ Tool use (function calling)
233
- 7. memory-agent β†’ Persistent state
234
- 8. react-agent β†’ Strategic reasoning + tool use
235
  ```
236
 
237
  ### Architecture Patterns
238
 
239
  **Simple Agent (Steps 1-5)**
240
  ```
241
- User β†’ LLM β†’ Response
242
  ```
243
 
244
  **Tool-Using Agent (Step 6)**
245
  ```
246
- User β†’ LLM ⟷ Tools β†’ Response
247
  ```
248
 
249
  **Memory Agent (Step 7)**
250
  ```
251
- User β†’ LLM ⟷ Tools β†’ Response
252
- ↕
253
  Memory
254
  ```
255
 
256
  **ReAct Agent (Step 8)**
257
  ```
258
- User β†’ LLM β†’ Think β†’ Act β†’ Observe
259
- ↑ ↓ ↓ ↓
260
- β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”˜
261
  Iterate until solved
262
  ```
263
 
264
- ## ️ Helper Utilities
265
 
266
  ### PromptDebugger
267
  `helper/prompt-debugger.js`
@@ -274,53 +283,53 @@ Utility for debugging prompts sent to the LLM. Shows exactly what the model sees
274
 
275
  Usage example in `simple-agent/simple-agent.js`
276
 
277
- ## ️ Project Structure - Fundamentals
278
 
279
  ```
280
  ai-agents/
281
- β”œβ”€β”€ README.md ← You are here
282
- β”œβ”€ examples/
283
- β”œβ”€β”€ 01_intro/
284
- β”‚ β”œβ”€β”€ intro.js
285
- β”‚ β”œβ”€β”€ CODE.md
286
- β”‚ └── CONCEPT.md
287
- β”œβ”€β”€ 02_openai-intro/
288
- β”‚ β”œβ”€β”€ openai-intro.js
289
- β”‚ β”œβ”€β”€ CODE.md
290
- β”‚ └── CONCEPT.md
291
- β”œβ”€β”€ 03_translation/
292
- β”‚ β”œβ”€β”€ translation.js
293
- β”‚ β”œβ”€β”€ CODE.md
294
- β”‚ └── CONCEPT.md
295
- β”œβ”€β”€ 04_think/
296
- β”‚ β”œβ”€β”€ think.js
297
- β”‚ β”œβ”€β”€ CODE.md
298
- β”‚ └── CONCEPT.md
299
- β”œβ”€β”€ 05_batch/
300
- β”‚ β”œβ”€β”€ batch.js
301
- β”‚ β”œβ”€β”€ CODE.md
302
- β”‚ └── CONCEPT.md
303
- β”œβ”€β”€ 06_coding/
304
- β”‚ β”œβ”€β”€ coding.js
305
- β”‚ β”œβ”€β”€ CODE.md
306
- β”‚ └── CONCEPT.md
307
- β”œβ”€β”€ 07_simple-agent/
308
- β”‚ β”œβ”€β”€ simple-agent.js
309
- β”‚ β”œβ”€β”€ CODE.md
310
- β”‚ └── CONCEPT.md
311
- β”œβ”€β”€ 08_simple-agent-with-memory/
312
- β”‚ β”œβ”€β”€ simple-agent-with-memory.js
313
- β”‚ β”œβ”€β”€ memory-manager.js
314
- β”‚ β”œβ”€β”€ CODE.md
315
- β”‚ └── CONCEPT.md
316
- β”œβ”€β”€ 09_react-agent/
317
- β”‚ β”œβ”€β”€ react-agent.js
318
- β”‚ β”œβ”€β”€ CODE.md
319
- β”‚ └── CONCEPT.md
320
- β”œβ”€β”€ helper/
321
- β”‚ └── prompt-debugger.js
322
- β”œβ”€β”€ models/ ← Place your GGUF models here
323
- └── logs/ ← Debug outputs
324
  ```
325
 
326
  ## Phase 2: Building a Production Framework (Tutorial)
@@ -348,46 +357,46 @@ A lightweight but complete agent framework with:
348
 
349
  ```
350
  tutorial/
351
- β”œβ”€β”€ 01-foundation/ # 1. Core Abstractions
352
- β”‚ β”œβ”€β”€ 01-runnable/
353
- β”‚ β”‚ β”œβ”€β”€ lesson.md # Why Runnable matters
354
- β”‚ β”‚ β”œβ”€β”€ exercises/ # Hands-on practice
355
- β”‚ β”‚ └── solutions/ # Reference implementations
356
- β”‚ β”œβ”€β”€ 02-messages/ # Structuring conversations
357
- β”‚ β”œβ”€β”€ 03-llm-wrapper/ # Wrapping node-llama-cpp
358
- β”‚ └── 04-context/ # Configuration & callbacks
359
- β”‚
360
- β”œβ”€β”€ 02-composition/ # 2. Building Chains
361
- β”‚ β”œβ”€β”€ 01-prompts/ # Template system
362
- β”‚ β”œβ”€β”€ 02-parsers/ # Structured outputs
363
- β”‚ β”œβ”€β”€ 03-llm-chain/ # Your first chain
364
- β”‚ β”œβ”€β”€ 04-piping/ # Composition patterns
365
- β”‚ └── 05-memory/ # Conversation state
366
- β”‚
367
- β”œβ”€β”€ 03-agency/ # 3. Tools & Agents
368
- β”‚ β”œβ”€β”€ 01-tools/ # Function definitions
369
- β”‚ β”œβ”€β”€ 02-tool-executor/ # Safe execution
370
- β”‚ β”œβ”€β”€ 03-simple-agent/ # Basic agent loop
371
- β”‚ β”œβ”€β”€ 04-react-agent/ # Reasoning + Acting
372
- β”‚ └── 05-structured-agent/ # JSON mode
373
- β”‚
374
- └── 04-graphs/ # 4. State Machines
375
- β”œβ”€β”€ 01-state-basics/ # Nodes & edges
376
- β”œβ”€β”€ 02-channels/ # State management
377
- β”œβ”€β”€ 03-conditional-edges/ # Dynamic routing
378
- β”œβ”€β”€ 04-executor/ # Running workflows
379
- β”œβ”€β”€ 05-checkpointing/ # Persistence
380
- └── 06-agent-graph/ # Agents as graphs
381
 
382
  src/
383
- β”œβ”€β”€ core/ # Runnable, Messages, Context
384
- β”œβ”€β”€ llm/ # LlamaCppLLM wrapper
385
- β”œβ”€β”€ prompts/ # Template system
386
- β”œβ”€β”€ chains/ # LLMChain, SequentialChain
387
- β”œβ”€β”€ tools/ # BaseTool, built-in tools
388
- β”œβ”€β”€ agents/ # AgentExecutor, ReActAgent
389
- β”œβ”€β”€ memory/ # BufferMemory, WindowMemory
390
- └── graph/ # StateGraph, CompiledGraph
391
  ```
392
 
393
  ### Why This Matters
@@ -407,7 +416,7 @@ src/
407
 
408
  ### Getting Started with Phase 2
409
 
410
- After completing the fundamentals (intro β†’ react-agent), start the tutorial:
411
 
412
  [Overview](tutorial/README.md)
413
 
@@ -497,8 +506,10 @@ Educational resource - use and modify as needed for learning.
497
 
498
  ---
499
 
500
- **Built with ❀️ for people who want to truly understand AI agents**
501
 
502
  Start with `intro/` and work your way through. Each example builds on the previous one. Read both CODE.md and CONCEPT.md for full understanding.
503
 
504
  Happy learning!
 
 
 
1
+ ο»Ώ---
2
+ title: Email Classifier Agent
3
+ emoji: πŸ€–
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: docker
7
+ pinned: false
8
+ app_port: 7860
9
+ ---
10
  > **Read the full interactive version:**
11
+ > This repository is part of **AI Agents From Scratch** - a hands-on learning series where we build AI agents *step by step*, explain every design decision, and visualize whatÒ€ℒs happening under the hood.
12
  >
13
+ > Γ°ΕΈβ€˜β€° **https://agentsfromscratch.com**
14
  >
15
  > If you prefer **long-form explanations, diagrams, and conceptual deep dives**, start there - then come back here to explore the code.
16
 
 
47
  ## Next Phase: Build LangChain & LangGraph Concepts From Scratch
48
 
49
  > After mastering the fundamentals, the next stage of this project walks you through **re-implementing the core parts of LangChain and LangGraph** in plain JavaScript using local models.
50
+ > This is **not** about building a new framework, itÒ€ℒs about understanding *how frameworks work*.
51
 
52
  ## Phase 1: Agent Fundamentals - From LLMs to ReAct
53
 
 
179
  `react-agent/` | [Code](examples/09_react-agent/react-agent.js) | [Code Explanation](examples/09_react-agent/CODE.md) | [Concepts](examples/09_react-agent/CONCEPT.md)
180
 
181
  **What you'll learn:**
182
+ - ReAct pattern (Reason Ò†’ Act Ò†’ Observe)
183
  - Iterative problem solving
184
  - Step-by-step tool use
185
  - Self-correction loops
 
225
 
226
  ```
227
  AI Agent = LLM + System Prompt + Tools + Memory + Reasoning Pattern
228
+ Ò”€Ò”¬Ò”€ Ò”€Ò”€Ò”€Ò”€Ò”€Ò”€Ò”¬Ò”€Ò”€Ò”€Ò”€Ò”€Ò”€ Ò”€Ò”€Ò”¬Ò”€Ò”€ Ò”€Ò”€Ò”¬Ò”€Ò”€Ò”€ Ò”€Ò”€Ò”€Ò”€Ò”€Ò”€Ò”€Ò”€Ò”¬Ò”€Ò”€Ò”€Ò”€Ò”€Ò”€Ò”€Ò”€
229
+ Γ’β€β€š Γ’β€β€š Γ’β€β€š Γ’β€β€š Γ’β€β€š
230
  Brain Identity Hands State Strategy
231
  ```
232
 
233
  ### Evolution of Capabilities
234
 
235
  ```
236
+ 1. intro Ò†’ Basic LLM usage
237
+ 2. translation Ò†’ Specialized behavior (system prompts)
238
+ 3. think Ò†’ Reasoning ability
239
+ 4. batch Ò†’ Parallel processing
240
+ 5. coding Ò†’ Streaming & control
241
+ 6. simple-agent Ò†’ Tool use (function calling)
242
+ 7. memory-agent Ò†’ Persistent state
243
+ 8. react-agent Ò†’ Strategic reasoning + tool use
244
  ```
245
 
246
  ### Architecture Patterns
247
 
248
  **Simple Agent (Steps 1-5)**
249
  ```
250
+ User Ò†’ LLM Ò†’ Response
251
  ```
252
 
253
  **Tool-Using Agent (Step 6)**
254
  ```
255
+ User Ò†’ LLM Γ’ΕΈΒ· Tools Ò†’ Response
256
  ```
257
 
258
  **Memory Agent (Step 7)**
259
  ```
260
+ User Ò†’ LLM Γ’ΕΈΒ· Tools Ò†’ Response
261
+ Ò†‒
262
  Memory
263
  ```
264
 
265
  **ReAct Agent (Step 8)**
266
  ```
267
+ User Ò†’ LLM Ò†’ Think Ò†’ Act Ò†’ Observe
268
+ Γ’β€ β€˜ Γ’β€ β€œ Γ’β€ β€œ Γ’β€ β€œ
269
+ Γ’β€β€Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€Β΄Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€Β΄Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€β‚¬Γ’β€Λœ
270
  Iterate until solved
271
  ```
272
 
273
+ ## ️ Helper Utilities
274
 
275
  ### PromptDebugger
276
  `helper/prompt-debugger.js`
 
283
 
284
  Usage example in `simple-agent/simple-agent.js`
285
 
286
+ ## ️ Project Structure - Fundamentals
287
 
288
  ```
289
  ai-agents/
290
+ Ò”œÒ”€Ò”€ README.md Ò† You are here
291
+ Ò”œÒ”€ examples/
292
+ Ò”œÒ”€Ò”€ 01_intro/
293
+ Γ’β€β€š Ò”œÒ”€Ò”€ intro.js
294
+ Γ’β€β€š Ò”œÒ”€Ò”€ CODE.md
295
+ Γ’β€β€š Ò””Ò”€Ò”€ CONCEPT.md
296
+ Ò”œÒ”€Ò”€ 02_openai-intro/
297
+ Γ’β€β€š Ò”œÒ”€Ò”€ openai-intro.js
298
+ Γ’β€β€š Ò”œÒ”€Ò”€ CODE.md
299
+ Γ’β€β€š Ò””Ò”€Ò”€ CONCEPT.md
300
+ Ò”œÒ”€Ò”€ 03_translation/
301
+ Γ’β€β€š Ò”œÒ”€Ò”€ translation.js
302
+ Γ’β€β€š Ò”œÒ”€Ò”€ CODE.md
303
+ Γ’β€β€š Ò””Ò”€Ò”€ CONCEPT.md
304
+ Ò”œÒ”€Ò”€ 04_think/
305
+ Γ’β€β€š Ò”œÒ”€Ò”€ think.js
306
+ Γ’β€β€š Ò”œÒ”€Ò”€ CODE.md
307
+ Γ’β€β€š Ò””Ò”€Ò”€ CONCEPT.md
308
+ Ò”œÒ”€Ò”€ 05_batch/
309
+ Γ’β€β€š Ò”œÒ”€Ò”€ batch.js
310
+ Γ’β€β€š Ò”œÒ”€Ò”€ CODE.md
311
+ Γ’β€β€š Ò””Ò”€Ò”€ CONCEPT.md
312
+ Ò”œÒ”€Ò”€ 06_coding/
313
+ Γ’β€β€š Ò”œÒ”€Ò”€ coding.js
314
+ Γ’β€β€š Ò”œÒ”€Ò”€ CODE.md
315
+ Γ’β€β€š Ò””Ò”€Ò”€ CONCEPT.md
316
+ Ò”œÒ”€Ò”€ 07_simple-agent/
317
+ Γ’β€β€š Ò”œÒ”€Ò”€ simple-agent.js
318
+ Γ’β€β€š Ò”œÒ”€Ò”€ CODE.md
319
+ Γ’β€β€š Ò””Ò”€Ò”€ CONCEPT.md
320
+ Ò”œÒ”€Ò”€ 08_simple-agent-with-memory/
321
+ Γ’β€β€š Ò”œÒ”€Ò”€ simple-agent-with-memory.js
322
+ Γ’β€β€š Ò”œÒ”€Ò”€ memory-manager.js
323
+ Γ’β€β€š Ò”œÒ”€Ò”€ CODE.md
324
+ Γ’β€β€š Ò””Ò”€Ò”€ CONCEPT.md
325
+ Ò”œÒ”€Ò”€ 09_react-agent/
326
+ Γ’β€β€š Ò”œÒ”€Ò”€ react-agent.js
327
+ Γ’β€β€š Ò”œÒ”€Ò”€ CODE.md
328
+ Γ’β€β€š Ò””Ò”€Ò”€ CONCEPT.md
329
+ Ò”œÒ”€Ò”€ helper/
330
+ Γ’β€β€š Ò””Ò”€Ò”€ prompt-debugger.js
331
+ Ò”œÒ”€Ò”€ models/ Ò† Place your GGUF models here
332
+ Ò””Ò”€Ò”€ logs/ Ò† Debug outputs
333
  ```
334
 
335
  ## Phase 2: Building a Production Framework (Tutorial)
 
357
 
358
  ```
359
  tutorial/
360
+ Ò”œÒ”€Ò”€ 01-foundation/ # 1. Core Abstractions
361
+ Γ’β€β€š Ò”œÒ”€Ò”€ 01-runnable/
362
+ Γ’β€β€š Γ’β€β€š Ò”œÒ”€Ò”€ lesson.md # Why Runnable matters
363
+ Γ’β€β€š Γ’β€β€š Ò”œÒ”€Ò”€ exercises/ # Hands-on practice
364
+ Γ’β€β€š Γ’β€β€š Ò””Ò”€Ò”€ solutions/ # Reference implementations
365
+ Γ’β€β€š Ò”œÒ”€Ò”€ 02-messages/ # Structuring conversations
366
+ Γ’β€β€š Ò”œÒ”€Ò”€ 03-llm-wrapper/ # Wrapping node-llama-cpp
367
+ Γ’β€β€š Ò””Ò”€Ò”€ 04-context/ # Configuration & callbacks
368
+ Γ’β€β€š
369
+ Ò”œÒ”€Ò”€ 02-composition/ # 2. Building Chains
370
+ Γ’β€β€š Ò”œÒ”€Ò”€ 01-prompts/ # Template system
371
+ Γ’β€β€š Ò”œÒ”€Ò”€ 02-parsers/ # Structured outputs
372
+ Γ’β€β€š Ò”œÒ”€Ò”€ 03-llm-chain/ # Your first chain
373
+ Γ’β€β€š Ò”œÒ”€Ò”€ 04-piping/ # Composition patterns
374
+ Γ’β€β€š Ò””Ò”€Ò”€ 05-memory/ # Conversation state
375
+ Γ’β€β€š
376
+ Ò”œÒ”€Ò”€ 03-agency/ # 3. Tools & Agents
377
+ Γ’β€β€š Ò”œÒ”€Ò”€ 01-tools/ # Function definitions
378
+ Γ’β€β€š Ò”œÒ”€Ò”€ 02-tool-executor/ # Safe execution
379
+ Γ’β€β€š Ò”œÒ”€Ò”€ 03-simple-agent/ # Basic agent loop
380
+ Γ’β€β€š Ò”œÒ”€Ò”€ 04-react-agent/ # Reasoning + Acting
381
+ Γ’β€β€š Ò””Ò”€Ò”€ 05-structured-agent/ # JSON mode
382
+ Γ’β€β€š
383
+ Ò””Ò”€Ò”€ 04-graphs/ # 4. State Machines
384
+ Ò”œÒ”€Ò”€ 01-state-basics/ # Nodes & edges
385
+ Ò”œÒ”€Ò”€ 02-channels/ # State management
386
+ Ò”œÒ”€Ò”€ 03-conditional-edges/ # Dynamic routing
387
+ Ò”œÒ”€Ò”€ 04-executor/ # Running workflows
388
+ Ò”œÒ”€Ò”€ 05-checkpointing/ # Persistence
389
+ Ò””Ò”€Ò”€ 06-agent-graph/ # Agents as graphs
390
 
391
  src/
392
+ Ò”œÒ”€Ò”€ core/ # Runnable, Messages, Context
393
+ Ò”œÒ”€Ò”€ llm/ # LlamaCppLLM wrapper
394
+ Ò”œÒ”€Ò”€ prompts/ # Template system
395
+ Ò”œÒ”€Ò”€ chains/ # LLMChain, SequentialChain
396
+ Ò”œÒ”€Ò”€ tools/ # BaseTool, built-in tools
397
+ Ò”œÒ”€Ò”€ agents/ # AgentExecutor, ReActAgent
398
+ Ò”œÒ”€Ò”€ memory/ # BufferMemory, WindowMemory
399
+ Ò””Ò”€Ò”€ graph/ # StateGraph, CompiledGraph
400
  ```
401
 
402
  ### Why This Matters
 
416
 
417
  ### Getting Started with Phase 2
418
 
419
+ After completing the fundamentals (intro Ò†’ react-agent), start the tutorial:
420
 
421
  [Overview](tutorial/README.md)
422
 
 
506
 
507
  ---
508
 
509
+ **Built with ҝ€ï¸ for people who want to truly understand AI agents**
510
 
511
  Start with `intro/` and work your way through. Each example builds on the previous one. Read both CODE.md and CONCEPT.md for full understanding.
512
 
513
  Happy learning!
514
+
515
+