brickfrog commited on
Commit
2eb64de
Β·
verified Β·
1 Parent(s): 7e2bb59

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. README.md +3 -9
  2. app.py +38 -13
README.md CHANGED
@@ -5,7 +5,7 @@ app_file: app.py
5
  requirements: requirements.txt
6
  python_version: 3.12
7
  sdk: gradio
8
- sdk_version: 5.49.1
9
  ---
10
 
11
  # AnkiGen - Anki Card Generator
@@ -14,9 +14,8 @@ AnkiGen generates Anki flashcards using OpenAI's GPT models. Available as both a
14
 
15
  ## Features
16
 
17
- - Generate Anki cards for various subjects or from provided text/URLs
18
  - AI-powered auto-configuration (intelligently determines topics, card counts, and models)
19
- - Create structured learning paths for complex topics
20
  - Export to CSV or `.apkg` format with default styling
21
  - Customizable number of topics and cards per topic
22
  - Built-in quality review system
@@ -92,11 +91,7 @@ uv run python -m ankigen_core.cli -p "Python Lists" --no-confirm
92
 
93
  2. Open your browser to `http://127.0.0.1:7860`
94
 
95
- 3. Select a generation mode:
96
- - Single Subject: Generate cards for a specific topic
97
- - Learning Path: Create a structured learning curriculum
98
- - From Text: Generate cards from pasted text
99
- - From Web: Generate cards from a URL
100
 
101
  4. Configure parameters and click "Generate Cards"
102
 
@@ -110,7 +105,6 @@ uv run python -m ankigen_core.cli -p "Python Lists" --no-confirm
110
  - `agents/`: Agent system implementation
111
  - `card_generator.py`: Card generation orchestration
112
  - `auto_config.py`: AI-powered auto-configuration
113
- - `learning_path.py`: Learning path analysis
114
  - `exporters.py`: CSV and `.apkg` export functionality
115
  - `models.py`: Data structures
116
  - `tests/`: Unit and integration tests
 
5
  requirements: requirements.txt
6
  python_version: 3.12
7
  sdk: gradio
8
+ sdk_version: 6.0.2
9
  ---
10
 
11
  # AnkiGen - Anki Card Generator
 
14
 
15
  ## Features
16
 
17
+ - Generate Anki cards for various subjects with automatic topic decomposition
18
  - AI-powered auto-configuration (intelligently determines topics, card counts, and models)
 
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
 
91
 
92
  2. Open your browser to `http://127.0.0.1:7860`
93
 
94
+ 3. Enter a subject and optionally click "Auto-fill" to configure settings
 
 
 
 
95
 
96
  4. Configure parameters and click "Generate Cards"
97
 
 
105
  - `agents/`: Agent system implementation
106
  - `card_generator.py`: Card generation orchestration
107
  - `auto_config.py`: AI-powered auto-configuration
 
108
  - `exporters.py`: CSV and `.apkg` export functionality
109
  - `models.py`: Data structures
110
  - `tests/`: Unit and integration tests
app.py CHANGED
@@ -141,10 +141,19 @@ def get_recent_logs(logger_name="ankigen") -> str:
141
  return f"Error reading logs: {e!s}"
142
 
143
 
144
- def create_ankigen_interface():
145
  logger.info("Creating AnkiGen Gradio interface...")
146
- # Note: theme, css, and js moved to .launch() for Gradio 6 compatibility
147
- with gr.Blocks(title="AnkiGen") as ankigen:
 
 
 
 
 
 
 
 
 
148
  with gr.Column(elem_classes="contain"):
149
  gr.Markdown("# πŸ“š AnkiGen - Anki Card Generator")
150
  gr.Markdown("#### Generate Anki flashcards using AI.")
@@ -584,25 +593,41 @@ def create_ankigen_interface():
584
  # --- Main Execution --- (Runs if script is executed directly)
585
  if __name__ == "__main__":
586
  import os
 
587
 
588
  try:
589
- ankigen_interface = create_ankigen_interface()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
590
  logger.info("Launching AnkiGen Gradio interface...")
591
 
592
- # Configure for HuggingFace Spaces vs local development
593
- # Note: theme, css, js moved to launch() for Gradio 6 compatibility
594
- launch_kwargs = {
595
- "theme": custom_theme,
596
- "css": custom_css,
597
- "js": js_storage,
598
- }
599
  if os.environ.get("SPACE_ID"): # On HuggingFace Spaces
600
- # Let HuggingFace handle all the configuration
601
  ankigen_interface.queue(default_concurrency_limit=2, max_size=10).launch(
602
  **launch_kwargs
603
  )
604
  else: # Local development
605
- # Use auto port finding for local dev
606
  ankigen_interface.queue(default_concurrency_limit=2, max_size=10).launch(
607
  server_name="127.0.0.1", share=False, **launch_kwargs
608
  )
 
141
  return f"Error reading logs: {e!s}"
142
 
143
 
144
+ def create_ankigen_interface(theme=None, css=None, js=None):
145
  logger.info("Creating AnkiGen Gradio interface...")
146
+ # Theme/css/js passed in for Gradio 4.x compatibility (goes in Blocks())
147
+ # For Gradio 6.x, these are passed to launch() instead
148
+ blocks_kwargs = {"title": "AnkiGen"}
149
+ if theme is not None:
150
+ blocks_kwargs["theme"] = theme
151
+ if css is not None:
152
+ blocks_kwargs["css"] = css
153
+ if js is not None:
154
+ blocks_kwargs["js"] = js
155
+
156
+ with gr.Blocks(**blocks_kwargs) as ankigen:
157
  with gr.Column(elem_classes="contain"):
158
  gr.Markdown("# πŸ“š AnkiGen - Anki Card Generator")
159
  gr.Markdown("#### Generate Anki flashcards using AI.")
 
593
  # --- Main Execution --- (Runs if script is executed directly)
594
  if __name__ == "__main__":
595
  import os
596
+ from packaging import version
597
 
598
  try:
599
+ # Detect Gradio version for API compatibility
600
+ gradio_version = version.parse(gr.__version__)
601
+ is_gradio_6 = gradio_version >= version.parse("5.0.0")
602
+
603
+ logger.info(
604
+ f"Detected Gradio version: {gr.__version__} (v6 API: {is_gradio_6})"
605
+ )
606
+
607
+ if is_gradio_6:
608
+ # Gradio 6.x: theme/css/js go in launch()
609
+ ankigen_interface = create_ankigen_interface()
610
+ launch_kwargs = {
611
+ "theme": custom_theme,
612
+ "css": custom_css,
613
+ "js": js_storage,
614
+ }
615
+ else:
616
+ # Gradio 4.x: theme/css/js go in Blocks()
617
+ ankigen_interface = create_ankigen_interface(
618
+ theme=custom_theme,
619
+ css=custom_css,
620
+ js=js_storage,
621
+ )
622
+ launch_kwargs = {}
623
+
624
  logger.info("Launching AnkiGen Gradio interface...")
625
 
 
 
 
 
 
 
 
626
  if os.environ.get("SPACE_ID"): # On HuggingFace Spaces
 
627
  ankigen_interface.queue(default_concurrency_limit=2, max_size=10).launch(
628
  **launch_kwargs
629
  )
630
  else: # Local development
 
631
  ankigen_interface.queue(default_concurrency_limit=2, max_size=10).launch(
632
  server_name="127.0.0.1", share=False, **launch_kwargs
633
  )