Skip to content

Commit

Permalink
Update index.qmd
Browse files Browse the repository at this point in the history
  • Loading branch information
awellis committed Nov 28, 2024
1 parent b973926 commit 10a7b38
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions projects/anki/example/index.qmd
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
---
title: "Generate Anki flashcards: example code"
jupyter: python3
execute:
cache: true
---

```{python}
import os
import csv
from dotenv import load_dotenv # For loading environment variables
from openai import OpenAI
Expand Down Expand Up @@ -38,7 +42,9 @@ class AnkiDeck(BaseModel):
```

```{python}
def generate_structured_flashcards(text: str, deck_name: str, num_cards: int = 5) -> AnkiDeck:
def generate_structured_flashcards(text: str,
deck_name: str,
num_cards: int = 5) -> AnkiDeck:
"""
Generate structured flashcards using GPT-4o with enforced Pydantic model output.
Expand Down Expand Up @@ -133,12 +139,16 @@ The Romantic era's emphasis on emotional expression, its technical innovations,
:::

```{python}
#| echo: false
#| eval: false
print(romantic_text)
```


```{python}
romantic_deck = generate_structured_flashcards(romantic_text, "Romanticism", 10)
romantic_deck = generate_structured_flashcards(romantic_text,
"Romanticism",
num_cards=10)
```

```{python}
Expand Down

0 comments on commit 10a7b38

Please sign in to comment.