Skip to content

Commit 89ae595

Browse files
committed
some example fixes
1 parent 44c7cb4 commit 89ae595

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

examples/games/cheater_guess_the_word.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class InputEvaluation(BaseModel):
3131
user_asked_to_quit: bool = Field(description="Does the user want to quit?")
3232

3333
@gpt_function(reasoning=True)
34-
def evaluate_guess(text: str, secret_word: str) -> "InputEvaluation":
34+
def from_guess(text: str, secret_word: str) -> "InputEvaluation":
3535
"""In trying to guess secret word "{secret_word}", the user said "{text}".
3636
Evaluate this input
3737
"""
@@ -51,7 +51,7 @@ def play_cheater_guess_the_word(subject):
5151
for turns_left in range(50, 0, -1):
5252
user_input = input(f"\nGuess the word ({turns_left} turns left): ")
5353
logs += f"INPUT: {user_input}\n"
54-
evaluation = evaluate_guess(text=user_input, secret_word=secret_word)
54+
evaluation = InputEvaluation.from_guess(user_input, secret_word=secret_word)
5555
evaluation = evaluation
5656
if evaluation.user_guessed_the_secret_word:
5757
# The user is about to win! We'll try changing the secret word.

examples/write_a_movie_script.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ class Character(BaseModel):
4747
relationship_to_other_characters: str
4848
character_arc_in_the_movie: str
4949

50-
@staticmethod
51-
@gpt_function
52-
def list_from_plot(n: int, plot: str) -> List["Character"]:
53-
"""Flesh out {n} main characters for the given plot. Be concise."""
50+
51+
@gpt_function
52+
def invent_characters_from_plot(n: int, plot: str) -> List[Character]:
53+
"""Flesh out {n} main characters for the given plot. Be concise."""
5454

5555

5656
class ActOutline(BaseModel):
@@ -60,9 +60,9 @@ class ActOutline(BaseModel):
6060

6161

6262
@gpt_function(reasoning=True)
63-
def list_from_plot(
63+
def act_outlines_from_plot(
6464
n: int, plot: str, characters: list[Character]
65-
) -> list["ActOutline"]:
65+
) -> list[ActOutline]:
6666
"""Come up with {n} acts for the movie, with for each a title and a summary
6767
explaining which characters are involved (use full names) and what they do."""
6868

@@ -74,11 +74,11 @@ class SceneOutline(BaseModel):
7474

7575

7676
@gpt_function
77-
def list_from_act_outline(
77+
def scene_outlines_from_act_outline(
7878
act_outline: ActOutline,
7979
full_story_plot: str,
8080
background_on_characters: list[Character],
81-
) -> list["SceneOutline"]:
81+
) -> list[SceneOutline]:
8282
"""Decompose the act into scenes, and for each scene provide a summary.
8383
The summary should use characters (with their full name) mentioned in the
8484
act outline, and from the provided list.
@@ -121,7 +121,7 @@ async def from_outline(
121121
semaphore: asyncio.Semaphore,
122122
) -> "Scene":
123123
text = await cls.write_scene_text(
124-
scene_outline=scene_outline,
124+
scene_outline=scene_outline.summary,
125125
act_outline=act_outline,
126126
background_on_characters=background_on_characters,
127127
gpt_system_prompt=gpt_system_prompt,
@@ -140,16 +140,16 @@ async def from_outline(
140140
characters: list[Character],
141141
gpt_system_prompt: str,
142142
async_semaphore: asyncio.Semaphore,
143-
) -> list["Act"]:
144-
scene_outlines = SceneOutline.list_from_act_outline(
143+
) -> "Act":
144+
scene_outlines = scene_outlines_from_act_outline(
145145
act_outline.summary,
146146
full_story_plot=plot,
147147
background_on_characters=characters,
148148
gpt_system_prompt=gpt_system_prompt,
149149
)
150150
scene_text_futures = [
151151
Scene.from_outline(
152-
scene_outline=scene_outline.summary,
152+
scene_outline=scene_outline,
153153
act_outline=act_outline.summary,
154154
background_on_characters=[
155155
c for c in characters if c.name in scene_outline.character_names
@@ -183,10 +183,10 @@ async def from_subject(
183183
print("Title:", outline.title)
184184
print("Synopsis:", outline.synopsis)
185185
print("\nWriting that story...")
186-
characters = Character.list_from_plot(
186+
characters = invent_characters_from_plot(
187187
n=n_characters, plot=outline.plot, gpt_model="gpt-4o", **kwargs
188188
)
189-
act_outlines = ActOutline.list_from_plot(
189+
act_outlines = act_outlines_from_plot(
190190
n_acts, outline.plot, characters, gpt_model="gpt-4o", **kwargs
191191
)
192192

0 commit comments

Comments
 (0)