@@ -50,6 +50,7 @@ while the LLM performs the actual content generation within each action.
5050 import ai.koog.agents.planner.goap
5151 import ai.koog.agents.planner.goap.GoapAgentState
5252 import ai.koog.prompt.dsl.prompt
53+ import ai.koog.prompt.message.MessagePart
5354 import ai.koog.prompt.executor.clients.openai.OpenAIModels
5455 import ai.koog.prompt.executor.llms.all.simpleOpenAIExecutor
5556 -->
@@ -84,7 +85,7 @@ while the LLM performs the actual content generation within each action.
8485 }
8586 requestLLM()
8687 }
87- state.copy(hasOutline = true, outline = response.content )
88+ state.copy(hasOutline = true, outline = response.parts.filterIsInstance<MessagePart.Text>().joinToString("\n") { it.text } )
8889 }
8990
9091 action(
@@ -100,7 +101,7 @@ while the LLM performs the actual content generation within each action.
100101 }
101102 requestLLM()
102103 }
103- state.copy(hasDraft = true, draft = response.content )
104+ state.copy(hasDraft = true, draft = response.parts.filterIsInstance<MessagePart.Text>().joinToString("\n") { it.text } )
104105 }
105106
106107 action(
@@ -116,7 +117,7 @@ while the LLM performs the actual content generation within each action.
116117 }
117118 requestLLM()
118119 }
119- println("Review feedback: ${response.content }")
120+ println("Review feedback: ${response.parts.filterIsInstance<MessagePart.Text>().joinToString("\n") { it.text } }")
120121 state.copy(hasReview = true)
121122 }
122123
@@ -168,6 +169,8 @@ while the LLM performs the actual content generation within each action.
168169 import ai.koog.agents.planner.goap.GoapAgentState;
169170 import ai.koog.prompt.executor.clients.openai.OpenAIModels;
170171 import ai.koog.prompt.executor.model.PromptExecutor;
172+ import ai.koog.prompt.message.MessagePart;
173+ import java.util.stream.Collectors;
171174 class exampleGoapAgents01 {
172175 -->
173176 <!--- SUFFIX
@@ -227,7 +230,10 @@ while the LLM performs the actual content generation within each action.
227230 prompt.user("Create a detailed outline for an article about: " + state.topic);
228231 return null;
229232 });
230- return session.requestLLM().getContent();
233+ return session.requestLLM().getParts().stream()
234+ .filter(p -> p instanceof MessagePart.Text)
235+ .map(p -> ((MessagePart.Text) p).getText())
236+ .collect(Collectors.joining());
231237 });
232238 return state.copy(true, response, state.hasDraft, state.draft,
233239 state.hasReview, state.isPublished);
@@ -243,7 +249,10 @@ while the LLM performs the actual content generation within each action.
243249 prompt.user("Write an article based on this outline:\n" + state.outline);
244250 return null;
245251 });
246- return session.requestLLM().getContent();
252+ return session.requestLLM().getParts().stream()
253+ .filter(p -> p instanceof MessagePart.Text)
254+ .map(p -> ((MessagePart.Text) p).getText())
255+ .collect(Collectors.joining());
247256 });
248257 return state.copy(state.hasOutline, state.outline, true, response,
249258 state.hasReview, state.isPublished);
@@ -260,7 +269,10 @@ while the LLM performs the actual content generation within each action.
260269 prompt.user("Review this article and suggest improvements:\n" + state.draft);
261270 return null;
262271 });
263- return session.requestLLM().getContent();
272+ return session.requestLLM().getParts().stream()
273+ .filter(p -> p instanceof MessagePart.Text)
274+ .map(p -> ((MessagePart.Text) p).getText())
275+ .collect(Collectors.joining());
264276 });
265277 System.out.println("Review feedback: " + response);
266278 return state.copy(state.hasOutline, state.outline, state.hasDraft,
0 commit comments