brickfrog commited on
Commit
4de67d6
Β·
verified Β·
1 Parent(s): 1d85a18

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -10,7 +10,7 @@ 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 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
 
 
10
 
11
  # AnkiGen - Anki Card Generator
12
 
13
+ AnkiGen is a Gradio-based web application that generates Anki flashcards using OpenAI's GPT models. It creates CSV and `.apkg` deck files with subject-specific card generation.
14
 
15
  ## Features
16
 
ankigen_core/agents/integration.py CHANGED
@@ -72,7 +72,7 @@ class AgentOrchestrator:
72
  context7_client = Context7Client()
73
 
74
  # Dynamic token allocation based on card generation needs
75
- # More cards need more comprehensive documentation
76
  base_tokens = 8000 # Increased base from 5000
77
  if num_cards > 40:
78
  token_limit = 12000 # Large card sets need more context
 
72
  context7_client = Context7Client()
73
 
74
  # Dynamic token allocation based on card generation needs
75
+ # More cards need more thorough documentation
76
  base_tokens = 8000 # Increased base from 5000
77
  if num_cards > 40:
78
  token_limit = 12000 # Large card sets need more context
ankigen_core/agents/templates/generators.j2 CHANGED
@@ -2,7 +2,7 @@
2
  {
3
  "subject_expert": {
4
  "name": "subject_expert",
5
- "instructions": "You are a world-class expert in {{ subject | default('the subject area') }} with deep pedagogical knowledge. \nYour role is to generate high-quality flashcards that demonstrate mastery of {{ subject | default('the subject') }} concepts.\n\nKey responsibilities:\n- Create ATOMIC cards: extremely short (1-9 words on back), break complex info into multiple simple cards\n- Use standardized, bland prompts without fancy formatting or unusual words\n- Design prompts that match real-life recall situations\n- Put ALL to-be-learned information on the BACK of cards, never in prompts\n- Ensure technical accuracy and depth appropriate for the target level\n- Use domain-specific terminology correctly\n- Connect concepts to prerequisite knowledge\n\nCard Types:\n- Basic cards (card_type='basic'): Standard Q&A format for concepts and facts\n- Cloze cards (card_type='cloze'): Fill-in-the-blank format using {{c1::answer}} syntax for code, syntax, formulas\n\nFor cloze cards, wrap the answer in {{c1::text}} format. Example: 'The vLLM class for inference is {{c1::LLM}}'\n\nPrioritize atomic simplicity over comprehensive single cards. Generate cards that test understanding through simple, direct recall.",
6
  "model": "{{ subject_expert_model }}",
7
  "temperature": 0.7,
8
  "timeout": 120.0,
 
2
  {
3
  "subject_expert": {
4
  "name": "subject_expert",
5
+ "instructions": "You are an expert in {{ subject | default('the subject area') }} with deep pedagogical knowledge. \nYour role is to generate flashcards that demonstrate mastery of {{ subject | default('the subject') }} concepts.\n\nKey responsibilities:\n- Create ATOMIC cards: extremely short (1-9 words on back), break complex info into multiple simple cards\n- Use standardized, bland prompts without fancy formatting or unusual words\n- Design prompts that match real-life recall situations\n- Put ALL to-be-learned information on the BACK of cards, never in prompts\n- Ensure technical accuracy and depth appropriate for the target level\n- Use domain-specific terminology correctly\n- Connect concepts to prerequisite knowledge\n\nCard Types:\n- Basic cards (card_type='basic'): Standard Q&A format for concepts and facts\n- Cloze cards (card_type='cloze'): Fill-in-the-blank format using {{ '{{c1::answer}}' }} syntax for code, syntax, formulas\n\nFor cloze cards, wrap the answer in {{ '{{c1::text}}' }} format. Example: 'The vLLM class for inference is {{ '{{c1::LLM}}' }}'\n\nPrioritize atomic simplicity - break complex info into multiple simple cards. Generate cards that test understanding through simple, direct recall.",
6
  "model": "{{ subject_expert_model }}",
7
  "temperature": 0.7,
8
  "timeout": 120.0,
ankigen_core/auto_config.py CHANGED
@@ -17,9 +17,9 @@ class AutoConfigService:
17
  async def analyze_subject(
18
  self, subject: str, openai_client: AsyncOpenAI
19
  ) -> AutoConfigSchema:
20
- """Analyze a subject string and return optimal configuration settings"""
21
 
22
- system_prompt = """You are an expert educational content analyzer specializing in spaced repetition learning. Analyze the given subject and determine optimal flashcard generation settings that focus on ESSENTIAL, HIGH-VALUE concepts.
23
 
24
  CRITICAL PRINCIPLE: Quality over quantity. Focus on fundamental concepts that unlock understanding, not trivial facts.
25
 
@@ -29,11 +29,11 @@ Consider:
29
  - "Basic Pandas Dataframe" β†’ documentation_focus: "dataframe basics, creation, indexing"
30
  - "React hooks tutorial" β†’ documentation_focus: "hooks, useState, useEffect"
31
  - "Docker networking" β†’ documentation_focus: "networking, network drivers, container communication"
32
- 3. Identify the scope: narrow (specific feature), medium (several related topics), broad (comprehensive overview)
33
  4. Determine content type: concepts (theory/understanding), syntax (code/commands), api (library usage), practical (hands-on skills)
34
- 5. Suggest optimal number of topics and cards - aim for comprehensive learning (30-60 total cards minimum)
35
  6. Recommend cloze cards for syntax/code, basic cards for concepts
36
- 7. Choose model based on complexity: gpt-4.1 for complex/advanced, gpt-4.1-nano for basic/simple
37
 
38
  IMPORTANT - Focus on HIGH-VALUE topics:
39
  - GOOD topics: Core concepts, fundamental principles, mental models, design patterns, key abstractions
@@ -45,18 +45,18 @@ Guidelines for settings (MINIMUM 30 cards total):
45
  - Medium scope: 5-7 core topics with 7-9 cards each (35-63 cards)
46
  - Broad scope: 6-8 fundamental topics with 6-8 cards each (36-64 cards)
47
  - "Basic"/"Introduction" keywords: Start with fundamentals, 40-50 cards total
48
- - "Advanced"/"Complex" keywords: Deep dive into critical concepts, 45-60 cards
49
 
50
  Learning preference suggestions:
51
  - For basics: "Focus on fundamental concepts and mental models that form the foundation"
52
  - For practical: "Emphasize core patterns and principles with real-world applications"
53
  - For theory: "Build deep conceptual understanding with progressive complexity"
54
 
55
- Documentation focus examples (be specific and comprehensive):
56
  - "Basic Pandas Dataframe" β†’ "dataframe creation, indexing, selection, basic operations, data types"
57
  - "React hooks" β†’ "useState, useEffect, custom hooks, hook rules, common patterns"
58
  - "Docker basics" β†’ "containers, images, Dockerfile, volumes, basic networking"
59
- - "Advanced TypeScript" β†’ "generics, conditional types, mapped types, utility types, type inference"
60
 
61
  Return a JSON object matching the AutoConfigSchema."""
62
 
@@ -65,7 +65,7 @@ Return a JSON object matching the AutoConfigSchema."""
65
  Extract:
66
  1. The library name if mentioned
67
  2. The specific documentation focus (what aspects of the library to focus on)
68
- 3. Optimal settings for effective learning
69
 
70
  Provide a brief rationale for your choices."""
71
 
 
17
  async def analyze_subject(
18
  self, subject: str, openai_client: AsyncOpenAI
19
  ) -> AutoConfigSchema:
20
+ """Analyze a subject string and return configuration settings"""
21
 
22
+ system_prompt = """You are an educational content analyzer specializing in spaced repetition learning. Analyze the given subject and determine flashcard generation settings that focus on ESSENTIAL concepts.
23
 
24
  CRITICAL PRINCIPLE: Quality over quantity. Focus on fundamental concepts that unlock understanding, not trivial facts.
25
 
 
29
  - "Basic Pandas Dataframe" β†’ documentation_focus: "dataframe basics, creation, indexing"
30
  - "React hooks tutorial" β†’ documentation_focus: "hooks, useState, useEffect"
31
  - "Docker networking" β†’ documentation_focus: "networking, network drivers, container communication"
32
+ 3. Identify the scope: narrow (specific feature), medium (several related topics), broad (full overview)
33
  4. Determine content type: concepts (theory/understanding), syntax (code/commands), api (library usage), practical (hands-on skills)
34
+ 5. Suggest number of topics and cards - aim for thorough learning (30-60 total cards minimum)
35
  6. Recommend cloze cards for syntax/code, basic cards for concepts
36
+ 7. Choose model based on complexity: gpt-4.1 for complex topics, gpt-4.1-nano for basic/simple
37
 
38
  IMPORTANT - Focus on HIGH-VALUE topics:
39
  - GOOD topics: Core concepts, fundamental principles, mental models, design patterns, key abstractions
 
45
  - Medium scope: 5-7 core topics with 7-9 cards each (35-63 cards)
46
  - Broad scope: 6-8 fundamental topics with 6-8 cards each (36-64 cards)
47
  - "Basic"/"Introduction" keywords: Start with fundamentals, 40-50 cards total
48
+ - "Complex" keywords: Deep dive into critical concepts, 45-60 cards
49
 
50
  Learning preference suggestions:
51
  - For basics: "Focus on fundamental concepts and mental models that form the foundation"
52
  - For practical: "Emphasize core patterns and principles with real-world applications"
53
  - For theory: "Build deep conceptual understanding with progressive complexity"
54
 
55
+ Documentation focus examples (be specific and thorough):
56
  - "Basic Pandas Dataframe" β†’ "dataframe creation, indexing, selection, basic operations, data types"
57
  - "React hooks" β†’ "useState, useEffect, custom hooks, hook rules, common patterns"
58
  - "Docker basics" β†’ "containers, images, Dockerfile, volumes, basic networking"
59
+ - "TypeScript types" β†’ "generics, conditional types, mapped types, utility types, type inference"
60
 
61
  Return a JSON object matching the AutoConfigSchema."""
62
 
 
65
  Extract:
66
  1. The library name if mentioned
67
  2. The specific documentation focus (what aspects of the library to focus on)
68
+ 3. Suggested settings for effective learning
69
 
70
  Provide a brief rationale for your choices."""
71
 
app.py CHANGED
@@ -182,8 +182,8 @@ def create_ankigen_interface():
182
  js=js_storage,
183
  ) as ankigen:
184
  with gr.Column(elem_classes="contain"):
185
- gr.Markdown("# πŸ“š AnkiGen - Advanced Anki Card Generator")
186
- gr.Markdown("#### Generate comprehensive Anki flashcards using AI.")
187
 
188
  with gr.Accordion("Configuration Settings", open=True):
189
  with gr.Row():
 
182
  js=js_storage,
183
  ) as ankigen:
184
  with gr.Column(elem_classes="contain"):
185
+ gr.Markdown("# πŸ“š AnkiGen - Anki Card Generator")
186
+ gr.Markdown("#### Generate Anki flashcards using AI.")
187
 
188
  with gr.Accordion("Configuration Settings", open=True):
189
  with gr.Row():