public void test() {
            var promptStr = TASK_PROMPT_TEMPLATE.replace("{input}", input);
            var inferenceOptions = new InferenceParameters(Map.of("temperature", "0")::get);
            
            if (expectException != null) {
                var exception = assertThrows(LanguageModelException.class, () -> llm.complete(StringPrompt.from(promptStr), inferenceOptions));
                assertEquals(expectException.code(), exception.code());
                assertTrue(exception.getMessage().toLowerCase().contains(expectException.getMessage().toLowerCase()));
                return;
            }

            var completion = llm.complete(StringPrompt.from(promptStr), inferenceOptions);
            var finishReason = completion.get(0).finishReason();
            assertEquals(expectFinishReason, finishReason);
            var completionStr = completion.get(0).text().split("\n")[0].strip();

            if (!completionStr.equals(expectOutput)) {
                System.err.println("Prompt: " + promptStr);
                System.err.println("Expected output: " + expectOutput);
                System.err.println("Actual output: " + completionStr);
            }
            
            // Using edit distance to compare output to account for small variations in LLM output.
            // The threshold is an arbitrary small number.
            // Using an edit distance method from arbitrary library among existing dependencies.
            if (expectOutput != null) {
                var editDistance = EditDistance.editDistance(expectOutput, completionStr);
                var maxEditDistance = expectOutput.length() * 0.05;
                assertTrue(editDistance <= maxEditDistance, 
                        "Expected output edit distance <= " + maxEditDistance + ", got " + editDistance);
            }
            
            if (expectNotOutput != null) {
                var editDistance = EditDistance.editDistance(expectNotOutput, completionStr);
                var maxEditDistance = expectNotOutput.length() * 0.05;
                assertTrue(editDistance >= maxEditDistance,
                        "Expected output edit distance >= " + maxEditDistance + ", got " + editDistance);
            }
        }
Tests for LocalLLM.
Tests are disabled to avoid running them automatically as part of the CI/CD.
The reason for this is the long time it takes to download (2-5 min) and run LLMs (10-60 seconds).
Still, these tests can be triggered manually and are useful for debugging runtime issues.

@author lesters
@author glebashnik
model-integration/src/test/java/ai/vespa/llm/clients/LocalLLMTest.java