File tree Expand file tree Collapse file tree
src/main/java/org/soujava/samples/ai/patterns/planning Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44import jakarta .enterprise .context .ApplicationScoped ;
55import jakarta .inject .Inject ;
66
7+ import java .util .Optional ;
8+ import java .util .UUID ;
9+ import java .util .logging .Logger ;
10+
711@ ApplicationScoped
812public class OrderService {
913
14+ private static final Logger LOGGER = Logger .getLogger (OrderService .class .getName ());
15+
1016 private final OrderRepository repository ;
1117
1218 @ Inject
@@ -17,11 +23,9 @@ public OrderService(OrderRepository repository) {
1723 // Tool B (Requires the output of Tool A)
1824 @ Tool ("Finds the active Order Number for a given internal Customer ID." )
1925 public String getActiveOrderNumber (String customerId ) {
20- System .out .println ("[TOOL EXECUTION] Looking up order for ID: " + customerId );
21- if (customerId .equals ("CUST-9988" )) {
22- return "ORD-12345" ;
23- }
24- return "NO_ACTIVE_ORDERS" ;
26+ LOGGER .info ("[TOOL EXECUTION] Looking up order for ID: " + customerId );
27+ Optional <Order > order = repository .findByCustomerId (UUID .fromString (customerId ));
28+ return order .map (Order ::id ).map (UUID ::toString ).orElse ("NO_ACTIVE_ORDERS" );
2529 }
2630
2731 // Tool C (Requires the output of Tool B)
You can’t perform that action at this time.
0 commit comments