@Override
    public List<Completion> complete(Prompt prompt, InferenceParameters options) {
        StringBuilder result = new StringBuilder();
        var future = completeWithOffer(prompt, options, 
                completion -> result.append(completion.text()), maxEnqueueWait);
        Completion.FinishReason reason;
    
        try {
            reason = future.get();
        } catch (InterruptedException e) {
          Thread.currentThread().interrupt();
          throw new LanguageModelException(500, "Interruption while generating completion.");
        } catch (ExecutionException e) {
            var cause = e.getCause();

            if (cause instanceof LanguageModelException languageModelException) {
                throw languageModelException;
            } else {
                throw new LanguageModelException(500, "Error while generating completion.", cause);
            }
        }
        
        List<Completion> completions = new ArrayList<>();
        completions.add(new Completion(result.toString(), reason));
        return completions;
    }
A language model running locally on the container node.

@author lesters
@author glebashnik
model-integration/src/main/java/ai/vespa/llm/clients/LocalLLM.java