|
15 | 15 | */
|
16 | 16 | package io.serverlessworkflow.fluent.agentic;
|
17 | 17 |
|
| 18 | +import dev.langchain4j.agent.tool.Tool; |
18 | 19 | import dev.langchain4j.agentic.Agent;
|
19 | 20 | import dev.langchain4j.agentic.internal.AgentSpecification;
|
| 21 | +import dev.langchain4j.service.SystemMessage; |
20 | 22 | import dev.langchain4j.service.UserMessage;
|
21 | 23 | import dev.langchain4j.service.V;
|
22 | 24 | import java.util.List;
|
@@ -234,4 +236,143 @@ String draftNew(
|
234 | 236 | @V("allowedDomains") List<String> allowedDomains,
|
235 | 237 | @V("links") List<String> links);
|
236 | 238 | }
|
| 239 | + |
| 240 | + interface CreativeWriter { |
| 241 | + |
| 242 | + @UserMessage( |
| 243 | + """ |
| 244 | + You are a creative writer. |
| 245 | + Generate a draft of a story no more than |
| 246 | + 3 sentences long around the given topic. |
| 247 | + Return only the story and nothing else. |
| 248 | + The topic is {{topic}}. |
| 249 | + """) |
| 250 | + @Agent("Generates a story based on the given topic") |
| 251 | + String generateStory(@V("topic") String topic); |
| 252 | + } |
| 253 | + |
| 254 | + interface AudienceEditor { |
| 255 | + |
| 256 | + @UserMessage( |
| 257 | + """ |
| 258 | + You are a professional editor. |
| 259 | + Analyze and rewrite the following story to better align |
| 260 | + with the target audience of {{audience}}. |
| 261 | + Return only the story and nothing else. |
| 262 | + The story is "{{story}}". |
| 263 | + """) |
| 264 | + @Agent("Edits a story to better fit a given audience") |
| 265 | + String editStory(@V("story") String story, @V("audience") String audience); |
| 266 | + } |
| 267 | + |
| 268 | + interface StyleEditor { |
| 269 | + |
| 270 | + @UserMessage( |
| 271 | + """ |
| 272 | + You are a professional editor. |
| 273 | + Analyze and rewrite the following story to better fit and be more coherent with the {{style}} style. |
| 274 | + Return only the story and nothing else. |
| 275 | + The story is "{{story}}". |
| 276 | + """) |
| 277 | + @Agent("Edits a story to better fit a given style") |
| 278 | + String editStory(@V("story") String story, @V("style") String style); |
| 279 | + } |
| 280 | + |
| 281 | + interface StyleScorer { |
| 282 | + |
| 283 | + @UserMessage( |
| 284 | + """ |
| 285 | + You are a critical reviewer. |
| 286 | + Give a review score between 0.0 and 1.0 for the following |
| 287 | + story based on how well it aligns with the style '{{style}}'. |
| 288 | + Return only the score and nothing else. |
| 289 | +
|
| 290 | + The story is: "{{story}}" |
| 291 | + """) |
| 292 | + @Agent("Scores a story based on how well it aligns with a given style") |
| 293 | + double scoreStyle(@V("story") String story, @V("style") String style); |
| 294 | + } |
| 295 | + |
| 296 | + interface FoodExpert { |
| 297 | + |
| 298 | + @UserMessage( |
| 299 | + """ |
| 300 | + You are a great evening planner. |
| 301 | + Propose a list of 3 meals matching the given mood. |
| 302 | + The mood is {{mood}}. |
| 303 | + For each meal, just give the name of the meal. |
| 304 | + Provide a list with the 3 items and nothing else. |
| 305 | + """) |
| 306 | + @Agent |
| 307 | + List<String> findMeal(@V("mood") String mood); |
| 308 | + } |
| 309 | + |
| 310 | + interface AstrologyAgent { |
| 311 | + @SystemMessage( |
| 312 | + """ |
| 313 | + You are an astrologist that generates horoscopes based on the user's name and zodiac sign. |
| 314 | + """) |
| 315 | + @UserMessage( |
| 316 | + """ |
| 317 | + Generate the horoscope for {{name}} who is a {{sign}}. |
| 318 | + """) |
| 319 | + @Agent("An astrologist that generates horoscopes based on the user's name and zodiac sign.") |
| 320 | + String horoscope(@V("name") String name, @V("sign") String sign); |
| 321 | + } |
| 322 | + |
| 323 | + enum RequestCategory { |
| 324 | + LEGAL, |
| 325 | + MEDICAL, |
| 326 | + TECHNICAL, |
| 327 | + UNKNOWN |
| 328 | + } |
| 329 | + |
| 330 | + interface CategoryRouter { |
| 331 | + |
| 332 | + @UserMessage( |
| 333 | + """ |
| 334 | + Analyze the following user request and categorize it as 'legal', 'medical' or 'technical'. |
| 335 | + In case the request doesn't belong to any of those categories categorize it as 'unknown'. |
| 336 | + Reply with only one of those words and nothing else. |
| 337 | + The user request is: '{{request}}'. |
| 338 | + """) |
| 339 | + @Agent("Categorizes a user request") |
| 340 | + RequestCategory classify(@V("request") String request); |
| 341 | + } |
| 342 | + |
| 343 | + interface MedicalExpert { |
| 344 | + |
| 345 | + @dev.langchain4j.service.UserMessage( |
| 346 | + """ |
| 347 | + You are a medical expert. |
| 348 | + Analyze the following user request under a medical point of view and provide the best possible answer. |
| 349 | + The user request is {{it}}. |
| 350 | + """) |
| 351 | + @Tool("A medical expert") |
| 352 | + String medicalRequest(String request); |
| 353 | + } |
| 354 | + |
| 355 | + interface LegalExpert { |
| 356 | + |
| 357 | + @dev.langchain4j.service.UserMessage( |
| 358 | + """ |
| 359 | + You are a legal expert. |
| 360 | + Analyze the following user request under a legal point of view and provide the best possible answer. |
| 361 | + The user request is {{it}}. |
| 362 | + """) |
| 363 | + @Tool("A legal expert") |
| 364 | + String legalRequest(String request); |
| 365 | + } |
| 366 | + |
| 367 | + interface TechnicalExpert { |
| 368 | + |
| 369 | + @dev.langchain4j.service.UserMessage( |
| 370 | + """ |
| 371 | + You are a technical expert. |
| 372 | + Analyze the following user request under a technical point of view and provide the best possible answer. |
| 373 | + The user request is {{it}}. |
| 374 | + """) |
| 375 | + @Tool("A technical expert") |
| 376 | + String technicalRequest(String request); |
| 377 | + } |
237 | 378 | }
|
0 commit comments