Spaces:
Running
on
T4
Running
on
T4
knowsuchagency
commited on
Commit
•
5f34d90
1
Parent(s):
9d05f90
chore: Update dependencies and add tenacity library for retrying validation errors
Browse files- main.py +3 -0
- requirements.txt +1 -0
main.py
CHANGED
@@ -8,6 +8,8 @@ from openai import OpenAI
|
|
8 |
from promptic import llm
|
9 |
from pydantic import BaseModel
|
10 |
from pypdf import PdfReader
|
|
|
|
|
11 |
|
12 |
|
13 |
class DialogueItem(BaseModel):
|
@@ -28,6 +30,7 @@ class Dialogue(BaseModel):
|
|
28 |
dialogue: List[DialogueItem]
|
29 |
|
30 |
|
|
|
31 |
@llm(model="gemini/gemini-1.5-flash")
|
32 |
def generate_dialogue(text: str) -> Dialogue:
|
33 |
"""
|
|
|
8 |
from promptic import llm
|
9 |
from pydantic import BaseModel
|
10 |
from pypdf import PdfReader
|
11 |
+
from tenacity import retry, retry_if_exception_type
|
12 |
+
from pydantic import ValidationError
|
13 |
|
14 |
|
15 |
class DialogueItem(BaseModel):
|
|
|
30 |
dialogue: List[DialogueItem]
|
31 |
|
32 |
|
33 |
+
@retry(retry=retry_if_exception_type(ValidationError))
|
34 |
@llm(model="gemini/gemini-1.5-flash")
|
35 |
def generate_dialogue(text: str) -> Dialogue:
|
36 |
"""
|
requirements.txt
CHANGED
@@ -4,3 +4,4 @@ pydantic~=2.7
|
|
4 |
google-generativeai~=0.6
|
5 |
loguru~=0.7
|
6 |
pypdf~=4.1
|
|
|
|
4 |
google-generativeai~=0.6
|
5 |
loguru~=0.7
|
6 |
pypdf~=4.1
|
7 |
+
tenacity~=8.3
|