Skip to content

Commit

Permalink
Guaranteed Message type in APEOpt (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
maykcaldas authored Dec 18, 2024
1 parent 420203b commit 3b4f596
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion ldp/alg/optimizer/ape.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,11 @@ def aggregate_trajectory(self, trajectory: Trajectory) -> None:
continue
# (x: first prompt's user message's content, y: AI response's content)
x = next(
cast(str, m.content) for m in result.prompt if m.role == "user"
# m is a Message with a result of the LLM. Which completes only strings.
# and we checked the result exists above.
cast(str, m.content)
for m in result.prompt
if (isinstance(m, Message) and m.role == "user")
)
y = cast(str, result.messages[0].content)

Expand Down

0 comments on commit 3b4f596

Please sign in to comment.