Skip to content

Commit

Permalink
chore: Update dependencies and add tenacity library for retrying vali…
Browse files Browse the repository at this point in the history
…dation errors
  • Loading branch information
knowsuchagency committed Jun 9, 2024
1 parent 9d05f90 commit 5f34d90
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from promptic import llm
from pydantic import BaseModel
from pypdf import PdfReader
from tenacity import retry, retry_if_exception_type
from pydantic import ValidationError


class DialogueItem(BaseModel):
Expand All @@ -28,6 +30,7 @@ class Dialogue(BaseModel):
dialogue: List[DialogueItem]


@retry(retry=retry_if_exception_type(ValidationError))
@llm(model="gemini/gemini-1.5-flash")
def generate_dialogue(text: str) -> Dialogue:
"""
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pydantic~=2.7
google-generativeai~=0.6
loguru~=0.7
pypdf~=4.1
tenacity~=8.3

0 comments on commit 5f34d90

Please sign in to comment.