1
1
from gpt_function_decorator import gpt_function
2
2
from pydantic import BaseModel , Field
3
+ from typing import List
3
4
4
5
5
6
def test_interpolated_docstring ():
@@ -28,7 +29,7 @@ def positivity(sentence) -> int:
28
29
29
30
def test_list_of_str_output ():
30
31
@gpt_function
31
- def list_famous_composers (n ) -> list [str ]:
32
+ def list_famous_composers (n ) -> List [str ]:
32
33
"Return the {n} most famous composers."
33
34
34
35
assert len (list_famous_composers (2 )) == 2
@@ -40,7 +41,7 @@ class USPresident(BaseModel):
40
41
name : str
41
42
42
43
@gpt_function
43
- def first_us_presidents (n ) -> list [USPresident ]:
44
+ def first_us_presidents (n ) -> List [USPresident ]:
44
45
"""Return the {n} first US presidents with their birth year"""
45
46
46
47
assert first_us_presidents (1 )[0 ].birth_year == 1732
@@ -52,7 +53,7 @@ class USPresident(BaseModel):
52
53
name : str = Field (description = "Family name" )
53
54
54
55
@gpt_function
55
- def first_us_presidents (n ) -> list [USPresident ]:
56
+ def first_us_presidents (n ) -> List [USPresident ]:
56
57
"""Return the {n} first US presidents with their birth year"""
57
58
58
59
assert first_us_presidents (1 )[0 ].name == "Washington"
@@ -73,7 +74,7 @@ def from_description(description) -> "Car":
73
74
74
75
def test_reasoned_answer ():
75
76
@gpt_function
76
- def could_have_met (person : str , celebrities : list ) -> list [str ]:
77
+ def could_have_met (person : str , celebrities : list ) -> List [str ]:
77
78
"""List the names in {celebrities} that {person} could have met."""
78
79
79
80
answer = could_have_met (
0 commit comments