Skip to content

Commit

Permalink
Merge pull request #817 from PrefectHQ/sorting-hat
Browse files Browse the repository at this point in the history
Add sorting hat example
  • Loading branch information
jlowin authored Jan 30, 2024
2 parents 6c0cc96 + ad69405 commit 1ce41f6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 1 deletion.
Binary file not shown.
21 changes: 21 additions & 0 deletions docs/examples/hogwarts_sorting_hat/hogwarts_sorting_hat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Hogwarts sorting hat

![](hogwarts_patch.webp){width="400"}


!!! example "Hogwarts sorting hat"
```python
import marvin

student = "Brave, daring, chivalrous, and sometimes a bit reckless."

house = marvin.classify(
student,
labels=["Gryffindor", "Hufflepuff", "Ravenclaw", "Slytherin"]
)
```

!!! success "Welcome to Gryffindor!"
```python
assert house == "Gryffindor"
```
2 changes: 1 addition & 1 deletion docs/examples/xkcd_bird.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# xkcd's bird photo classifier
# xkcd bird classifier

[![](https://imgs.xkcd.com/comics/tasks.png)](https://xkcd.com/1425/)

Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ nav:
- Examples:
- examples/xkcd_bird.md
- examples/michael_scott_business/michael_scott_business.md
- examples/hogwarts_sorting_hat/hogwarts_sorting_hat.md


- Community:
Expand Down
11 changes: 11 additions & 0 deletions tests/ai/test_classify.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,14 @@ class TestAsync:
async def test_classify_positive_sentiment(self):
result = await marvin.classify_async("This is a great feature!", bool)
assert result is True

class TestExamples:
async def test_hogwarts_sorting_hat(self):
description = "Brave, daring, chivalrous, and sometimes a bit reckless."

house = marvin.classify(
description,
labels=["Gryffindor", "Hufflepuff", "Ravenclaw", "Slytherin"],
)

assert house == "Gryffindor"

0 comments on commit 1ce41f6

Please sign in to comment.