Upload folder using huggingface_hub
Browse files
README.md
CHANGED
@@ -10,178 +10,84 @@ sdk_version: 5.38.1
|
|
10 |
|
11 |
# AnkiGen - Anki Card Generator
|
12 |
|
13 |
-
AnkiGen is a Gradio-based web application that generates high-quality Anki
|
14 |
|
15 |
## Features
|
16 |
|
17 |
-
- **Multi-Agent Card Generation**: Utilizes specialized agents for subject expertise, pedagogical guidance, and content structuring
|
18 |
-
- **Quality Assurance System**: Multiple judge agents evaluate cards for accuracy, clarity, pedagogical value, and completeness
|
19 |
-
- **Adaptive Enhancement**: Revision and enhancement agents improve cards based on judge feedback
|
20 |
- Generate Anki cards for various subjects or from provided text/URLs
|
21 |
-
-
|
|
|
22 |
- Customizable number of topics and cards per topic
|
23 |
-
-
|
24 |
-
-
|
25 |
-
- Advanced OpenAI Agents SDK integration with structured outputs
|
26 |
-
|
27 |
-
## How It Works
|
28 |
-
|
29 |
-
```mermaid
|
30 |
-
graph TD
|
31 |
-
A[User Input] --> B[Generation Coordinator]
|
32 |
-
B --> C[Subject Expert Agent]
|
33 |
-
B --> D[Pedagogical Agent]
|
34 |
-
B --> E[Content Structuring Agent]
|
35 |
-
|
36 |
-
C --> F[Generated Cards]
|
37 |
-
D --> F
|
38 |
-
E --> F
|
39 |
-
|
40 |
-
F --> G[Judge Coordinator]
|
41 |
-
G --> H[Content Accuracy Judge]
|
42 |
-
G --> I[Pedagogical Judge]
|
43 |
-
G --> J[Clarity Judge]
|
44 |
-
G --> K[Technical Judge]
|
45 |
-
G --> L[Completeness Judge]
|
46 |
-
|
47 |
-
H --> M{60% Consensus?}
|
48 |
-
I --> M
|
49 |
-
J --> M
|
50 |
-
K --> M
|
51 |
-
L --> M
|
52 |
-
|
53 |
-
M -->|No| N[Revision Agent]
|
54 |
-
N --> O[Enhancement Agent]
|
55 |
-
O --> B
|
56 |
-
|
57 |
-
M -->|Yes| P[Final High-Quality Cards]
|
58 |
-
P --> Q[Export to CSV/APKG]
|
59 |
-
```
|
60 |
-
|
61 |
-
## Installation for Local Use
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
1. Clone this repository:
|
66 |
|
67 |
-
|
68 |
-
git clone https://github.com/brickfrog/ankigen.git
|
69 |
-
cd ankigen
|
70 |
-
uv venv
|
71 |
-
source .venv/bin/activate # Activate the virtual environment
|
72 |
-
```
|
73 |
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
79 |
|
80 |
-
3.
|
81 |
-
|
82 |
-
|
83 |
-
- The application will load this key automatically.
|
84 |
-
- **Note**: This application requires OpenAI API access and uses the `openai-agents` SDK for advanced multi-agent functionality.
|
85 |
|
86 |
## Usage
|
87 |
|
88 |
-
1.
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
```bash
|
93 |
-
uv run python app.py
|
94 |
-
```
|
95 |
-
*(Note: The `gradio app.py` command might also work but using `python app.py` within the `uv run` context is recommended.)*
|
96 |
|
97 |
-
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
- Click "Generate Cards" or "Analyze Learning Path".
|
105 |
|
106 |
-
|
107 |
|
108 |
-
|
109 |
|
110 |
## Project Structure
|
111 |
|
112 |
-
|
113 |
-
|
114 |
-
-
|
115 |
-
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
- `config.py`: Agent configuration management
|
121 |
-
- `schemas.py`: Pydantic schemas for structured agent outputs
|
122 |
-
- `templates/`: Jinja2 templates for agent prompts
|
123 |
-
- `models.py`: Pydantic models for data structures.
|
124 |
-
- `utils.py`: Logging, caching, web fetching utilities.
|
125 |
-
- `llm_interface.py`: OpenAI API client management.
|
126 |
-
- `card_generator.py`: Integration layer for agent-based card generation.
|
127 |
-
- `learning_path.py`: Logic for the learning path analysis feature.
|
128 |
-
- `exporters.py`: Functions for exporting data to CSV and `.apkg`.
|
129 |
-
- `ui_logic.py`: Functions handling UI component updates and visibility.
|
130 |
-
- `tests/`: Contains unit and integration tests.
|
131 |
-
- `unit/`: Tests for individual modules in `ankigen_core`.
|
132 |
-
- `integration/`: Tests for interactions between modules and the app.
|
133 |
-
- `pyproject.toml`: Defines project metadata, dependencies, and build system configuration.
|
134 |
-
- `README.md`: This file.
|
135 |
-
|
136 |
-
## Agent System Architecture
|
137 |
-
|
138 |
-
AnkiGen employs a sophisticated multi-agent system built on the OpenAI Agents SDK that ensures high-quality flashcard generation through specialized roles and quality control:
|
139 |
-
|
140 |
-
### Generator Agent
|
141 |
-
- **SubjectExpertAgent**: Provides domain-specific expertise for accurate content creation, followed by a single lightweight quality review that can revise or drop weak cards.
|
142 |
-
|
143 |
-
### Orchestration
|
144 |
-
- **AgentOrchestrator**: Main system controller that initializes the simplified agent pipeline and runs self-review before returning cards.
|
145 |
-
|
146 |
-
This architecture ensures that every generated flashcard undergoes rigorous quality control and iterative improvement, resulting in superior learning materials.
|
147 |
|
148 |
## Development
|
149 |
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
2. **Install Development Dependencies:**
|
155 |
-
```bash
|
156 |
-
uv pip install -e ".[dev]"
|
157 |
-
```
|
158 |
-
|
159 |
-
3. **Running Tests:**
|
160 |
-
- To run all tests:
|
161 |
-
```bash
|
162 |
-
uv run pytest tests/
|
163 |
-
```
|
164 |
-
- To run with coverage:
|
165 |
-
```bash
|
166 |
-
uv run pytest --cov=ankigen_core tests/
|
167 |
-
```
|
168 |
-
*(Current test coverage target is >= 80%. As of the last run, coverage was ~89%.)*
|
169 |
-
|
170 |
-
4. **Code Style:** Please use `black` and `ruff` for formatting and linting (configured in `pyproject.toml` implicitly via dev dependencies, can be run manually).
|
171 |
-
|
172 |
-
5. **Making Changes:**
|
173 |
-
- Core logic changes should primarily be made within the `ankigen_core` modules.
|
174 |
-
- UI layout and event wiring are in `app.py`.
|
175 |
-
- Add or update tests in the `tests/` directory for any new or modified functionality.
|
176 |
|
177 |
-
|
|
|
|
|
|
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
- [ ] Add custom agent configuration UI
|
184 |
-
- [ ] Expand subject-specific agent templates
|
185 |
|
186 |
## License
|
187 |
|
@@ -189,6 +95,6 @@ BSD 2-Clause License
|
|
189 |
|
190 |
## Acknowledgments
|
191 |
|
192 |
-
-
|
193 |
-
-
|
194 |
-
- Card
|
|
|
10 |
|
11 |
# AnkiGen - Anki Card Generator
|
12 |
|
13 |
+
AnkiGen is a Gradio-based web application that generates high-quality Anki flashcards using OpenAI's GPT models. It creates CSV and `.apkg` deck files with intelligent subject-specific card generation and quality review.
|
14 |
|
15 |
## Features
|
16 |
|
|
|
|
|
|
|
17 |
- Generate Anki cards for various subjects or from provided text/URLs
|
18 |
+
- Create structured learning paths for complex topics
|
19 |
+
- Export to CSV or `.apkg` format with default styling
|
20 |
- Customizable number of topics and cards per topic
|
21 |
+
- Built-in quality review system
|
22 |
+
- User-friendly Gradio interface
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
## Installation
|
|
|
|
|
25 |
|
26 |
+
Preferred usage: [uv](https://github.com/astral-sh/uv)
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
1. Clone this repository:
|
29 |
+
```bash
|
30 |
+
git clone https://github.com/brickfrog/ankigen.git
|
31 |
+
cd ankigen
|
32 |
+
uv venv
|
33 |
+
source .venv/bin/activate
|
34 |
+
```
|
35 |
|
36 |
+
2. Install dependencies:
|
37 |
+
```bash
|
38 |
+
uv pip install -e .
|
39 |
+
```
|
40 |
|
41 |
+
3. Set up your OpenAI API key:
|
42 |
+
- Create a `.env` file in the project root
|
43 |
+
- Add: `OPENAI_API_KEY="your_api_key_here"`
|
|
|
|
|
44 |
|
45 |
## Usage
|
46 |
|
47 |
+
1. Run the application:
|
48 |
+
```bash
|
49 |
+
uv run python app.py
|
50 |
+
```
|
|
|
|
|
|
|
|
|
51 |
|
52 |
+
2. Open your browser to `http://127.0.0.1:7860`
|
53 |
|
54 |
+
3. Select a generation mode:
|
55 |
+
- Single Subject: Generate cards for a specific topic
|
56 |
+
- Learning Path: Create a structured learning curriculum
|
57 |
+
- From Text: Generate cards from pasted text
|
58 |
+
- From Web: Generate cards from a URL
|
|
|
59 |
|
60 |
+
4. Configure parameters and click "Generate Cards"
|
61 |
|
62 |
+
5. Export results as CSV or `.apkg` file
|
63 |
|
64 |
## Project Structure
|
65 |
|
66 |
+
- `app.py`: Main Gradio application
|
67 |
+
- `ankigen_core/`: Core logic modules
|
68 |
+
- `agents/`: Agent system implementation
|
69 |
+
- `card_generator.py`: Card generation orchestration
|
70 |
+
- `learning_path.py`: Learning path analysis
|
71 |
+
- `exporters.py`: CSV and `.apkg` export functionality
|
72 |
+
- `models.py`: Data structures
|
73 |
+
- `tests/`: Unit and integration tests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
## Development
|
76 |
|
77 |
+
1. Install development dependencies:
|
78 |
+
```bash
|
79 |
+
uv pip install -e ".[dev]"
|
80 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
+
2. Run tests:
|
83 |
+
```bash
|
84 |
+
uv run pytest tests/
|
85 |
+
```
|
86 |
|
87 |
+
3. Run with coverage:
|
88 |
+
```bash
|
89 |
+
uv run pytest --cov=ankigen_core tests/
|
90 |
+
```
|
|
|
|
|
91 |
|
92 |
## License
|
93 |
|
|
|
95 |
|
96 |
## Acknowledgments
|
97 |
|
98 |
+
- Gradio library for the web interface
|
99 |
+
- OpenAI for GPT models
|
100 |
+
- Card design principles from ["An Opinionated Guide to Using Anki Correctly"](https://www.lesswrong.com/posts/7Q7DPSk4iGFJd8DRk/an-opinionated-guide-to-using-anki-correctly)
|