Spaces:
Sleeping
Sleeping
Mituvinci commited on
Commit Β·
213fb21
1
Parent(s): 2e8d6bf
Add HF Spaces config, requirements, and architecture image
Browse files- README.md +13 -102
- images/study_agent_langraph.png +0 -0
- requirements.txt +8 -0
README.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Adaptive Study Agent
|
| 2 |
|
| 3 |
A single-agent self-directed learning system built with LangGraph that ingests documents, quizzes itself, evaluates its own answers, and iterates until mastery.
|
|
@@ -16,75 +28,7 @@ The connection is conceptual and motivational. There is no shared infrastructure
|
|
| 16 |
|
| 17 |
The agent operates as a LangGraph state machine with conditional branching. After evaluating each answer, the agent decides whether to re-read weak material, continue to the next question, or finalize the session.
|
| 18 |
|
| 19 |
-
|
| 20 |
-
+-----------------------------+
|
| 21 |
-
| START |
|
| 22 |
-
| User provides document |
|
| 23 |
-
+--------------+--------------+
|
| 24 |
-
|
|
| 25 |
-
v
|
| 26 |
-
+-----------------------------+
|
| 27 |
-
| INGEST |
|
| 28 |
-
| Parse document |
|
| 29 |
-
| Chunk into passages |
|
| 30 |
-
| Embed -> ChromaDB |
|
| 31 |
-
+--------------+--------------+
|
| 32 |
-
|
|
| 33 |
-
v
|
| 34 |
-
+-----------------------------+
|
| 35 |
-
| GENERATE QUESTION |
|
| 36 |
-
| Query ChromaDB for a chunk |
|
| 37 |
-
| LLM generates question |
|
| 38 |
-
| from retrieved passage |
|
| 39 |
-
+--------------+--------------+
|
| 40 |
-
|
|
| 41 |
-
v
|
| 42 |
-
+-----------------------------+
|
| 43 |
-
| ANSWER |
|
| 44 |
-
| Agent retrieves relevant |
|
| 45 |
-
| chunks from ChromaDB |
|
| 46 |
-
| LLM generates answer |
|
| 47 |
-
+--------------+--------------+
|
| 48 |
-
|
|
| 49 |
-
v
|
| 50 |
-
+-----------------------------+
|
| 51 |
-
| EVALUATE |
|
| 52 |
-
| LLM grades own answer |
|
| 53 |
-
| Score: 0.0 - 1.0 |
|
| 54 |
-
| Updates session state |
|
| 55 |
-
+--------------+--------------+
|
| 56 |
-
|
|
| 57 |
-
+---------+----------+
|
| 58 |
-
| Conditional edge |
|
| 59 |
-
| score < threshold? |
|
| 60 |
-
+---------+----------+
|
| 61 |
-
| |
|
| 62 |
-
YES NO
|
| 63 |
-
| |
|
| 64 |
-
v v
|
| 65 |
-
+--------------+ +------------------+
|
| 66 |
-
| RE-READ | | enough questions |
|
| 67 |
-
| Retrieve + | | answered? |
|
| 68 |
-
| re-study | +--------+---------+
|
| 69 |
-
| weak chunk | YES | NO
|
| 70 |
-
+------+-------+ | |
|
| 71 |
-
| v v
|
| 72 |
-
| +----------------+
|
| 73 |
-
+---------->| NEXT QUESTION|
|
| 74 |
-
+-------+--------+
|
| 75 |
-
|
|
| 76 |
-
(loop back to
|
| 77 |
-
GENERATE QUESTION)
|
| 78 |
-
|
|
| 79 |
-
mastery reached
|
| 80 |
-
|
|
| 81 |
-
v
|
| 82 |
-
+---------------+
|
| 83 |
-
| SUMMARIZE |
|
| 84 |
-
| Write session|
|
| 85 |
-
| report .md |
|
| 86 |
-
+---------------+
|
| 87 |
-
```
|
| 88 |
|
| 89 |
---
|
| 90 |
|
|
@@ -102,39 +46,6 @@ The agent operates as a LangGraph state machine with conditional branching. Afte
|
|
| 102 |
|
| 103 |
---
|
| 104 |
|
| 105 |
-
## Project Structure
|
| 106 |
-
|
| 107 |
-
```
|
| 108 |
-
adaptive_study_agent/
|
| 109 |
-
βββ pyproject.toml
|
| 110 |
-
βββ .env
|
| 111 |
-
βββ README.md
|
| 112 |
-
βββ app.py <- Gradio web interface
|
| 113 |
-
βββ src/
|
| 114 |
-
β βββ graph/
|
| 115 |
-
β β βββ state.py <- StudyState TypedDict
|
| 116 |
-
β β βββ nodes.py <- All node functions
|
| 117 |
-
β β βββ edges.py <- Conditional edge logic
|
| 118 |
-
β β βββ build_graph.py <- Assembles the StateGraph
|
| 119 |
-
β βββ tools/
|
| 120 |
-
β β βββ ingest.py <- PDF/text chunking + ChromaDB insert
|
| 121 |
-
β β βββ retriever.py <- ChromaDB query wrapper
|
| 122 |
-
β βββ prompts/
|
| 123 |
-
β β βββ question_prompt.py <- Generate question from passage
|
| 124 |
-
β β βββ answer_prompt.py <- Answer using retrieved context
|
| 125 |
-
β β βββ evaluate_prompt.py <- Grade answer 0.0-1.0 with reasoning
|
| 126 |
-
β βββ main.py <- CLI entry point
|
| 127 |
-
βββ output/
|
| 128 |
-
β βββ session_reports/ <- Markdown report per session
|
| 129 |
-
βββ data/
|
| 130 |
-
β βββ documents/ <- Drop PDFs or .txt files here
|
| 131 |
-
βββ tests/
|
| 132 |
-
βββ test_edges.py
|
| 133 |
-
βββ test_ingest.py
|
| 134 |
-
```
|
| 135 |
-
|
| 136 |
-
---
|
| 137 |
-
|
| 138 |
## Setup
|
| 139 |
|
| 140 |
**1. Install dependencies**
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Adaptive Study Agent
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: "4.0.0"
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
private: true
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
# Adaptive Study Agent
|
| 14 |
|
| 15 |
A single-agent self-directed learning system built with LangGraph that ingests documents, quizzes itself, evaluates its own answers, and iterates until mastery.
|
|
|
|
| 28 |
|
| 29 |
The agent operates as a LangGraph state machine with conditional branching. After evaluating each answer, the agent decides whether to re-read weak material, continue to the next question, or finalize the session.
|
| 30 |
|
| 31 |
+

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
---
|
| 34 |
|
|
|
|
| 46 |
|
| 47 |
---
|
| 48 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
## Setup
|
| 50 |
|
| 51 |
**1. Install dependencies**
|
images/study_agent_langraph.png
ADDED
|
requirements.txt
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
langgraph>=0.2.0
|
| 2 |
+
langchain-anthropic>=0.3.0
|
| 3 |
+
langchain-openai>=0.3.0
|
| 4 |
+
langchain-chroma>=0.2.0
|
| 5 |
+
chromadb>=0.5.0
|
| 6 |
+
pymupdf>=1.24.0
|
| 7 |
+
python-dotenv>=1.0.0
|
| 8 |
+
gradio>=4.0.0
|