diff --git a/ldp/alg/optimizer/ape.py b/ldp/alg/optimizer/ape.py index 72c43ef..de0529a 100644 --- a/ldp/alg/optimizer/ape.py +++ b/ldp/alg/optimizer/ape.py @@ -193,8 +193,10 @@ def aggregate_trajectory(self, trajectory: Trajectory) -> None: if result is None or not result.messages or not result.prompt: continue # (x: first prompt's user message's content, y: AI response's content) + # m is a Message with a result of the LLM. Which completes only strings. + # and we checked the result exists above. x = next( - cast(str, m.content) + cast(str, m.content) for m in result.prompt if (isinstance(m, Message) and m.role == "user") )