Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandreroman committed Jun 4, 2024
1 parent 95dae89 commit 16fdc42
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class HelloController {

@GetMapping(value = "/hello", produces = MediaType.TEXT_PLAIN_VALUE)
CharSequence hello(@RequestParam(name = "n", defaultValue = "John Doe") String name) {
// In this example, you can see that the AI engine has no "session" or memory of past conversations,
// as RequestResponseAdvisor is provided.
// In this example, you can see that the AI engine has no "session" or memory of past conversations.
return chatWithAI(name, List.of());
}

Expand All @@ -51,17 +50,17 @@ CharSequence helloMemory(@RequestParam(name = "n", defaultValue = "John Doe") St
}

private CharSequence chatWithAI(String name, List<RequestResponseAdvisor> advisors) {
final var buf = new StringBuilder();
buf.append("Current time is: ").append(Instant.now()).append("\n\n");
final var res = new StringBuilder(128);
res.append("Current time is: ").append(Instant.now()).append("\n\n");

final var p1 = String.format("Hello, my name is %s.", name);
buf.append("💬️ ").append(p1).append("\n");
buf.append("🤖 ").append(chatClient.prompt().advisors(advisors).user(p1).call().content()).append("\n\n");
res.append("💬️ ").append(p1).append("\n");
res.append("🤖 ").append(chatClient.prompt().advisors(advisors).user(p1).call().content()).append("\n\n");

final var p2 = "Hello, what's my name?";
buf.append("💬️ ").append(p2).append("\n");
buf.append("🤖 ").append(chatClient.prompt().advisors(advisors).user(p2).call().content()).append("\n");
res.append("💬️ ").append(p2).append("\n");
res.append("🤖 ").append(chatClient.prompt().advisors(advisors).user(p2).call().content()).append("\n");

return buf;
return res;
}
}

0 comments on commit 16fdc42

Please sign in to comment.