selectService method

  1. @override
LlmClientServiceAdapter? selectService(
  1. String request, {
  2. Map<String, dynamic>? properties,
})

Select the most appropriate service for a request

Implementation

@override
LlmClientServiceAdapter? selectService(String request, {Map<String, dynamic>? properties}) {
  // Route based on request characteristics
  String? clientId = _router.routeRequest(request, properties);

  // Use load balancer if no routing result
  if (clientId == null || !_clients.containsKey(clientId)) {
    clientId = _loadBalancer.getNextService();
  }

  return clientId != null ? _clients[clientId] : null;
}