Skip to content

Commit

Permalink
OPIK-610 invalid model failing test green
Browse files Browse the repository at this point in the history
  • Loading branch information
idoberko2 committed Dec 29, 2024
1 parent 4c0d114 commit 6983a0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

@Singleton
public class LlmProviderFactory {
public static final String ERROR_MODEL_NOT_SUPPORTED = "model not supported %s";

private final LlmProviderClientConfig llmProviderClientConfig;
private final LlmProviderApiKeyService llmProviderApiKeyService;

Expand Down Expand Up @@ -52,7 +54,7 @@ private LlmProvider getLlmProvider(String model) {
return LlmProvider.ANTHROPIC;
}

throw new BadRequestException("model not supported: " + model);
throw new BadRequestException(ERROR_MODEL_NOT_SUPPORTED.formatted(model));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.NullSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.testcontainers.clickhouse.ClickHouseContainer;
import org.testcontainers.containers.MySQLContainer;
Expand All @@ -41,6 +40,7 @@
import java.util.UUID;
import java.util.stream.Stream;

import static com.comet.opik.domain.llmproviders.LlmProviderFactory.ERROR_MODEL_NOT_SUPPORTED;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assumptions.assumeThat;

Expand Down Expand Up @@ -154,7 +154,6 @@ void createReturnsBadRequestWhenNoLlmProviderApiKey() {

@ParameterizedTest
@ValueSource(strings = {"", "non-existing-model"})
@NullSource
void createReturnsBadRequestWhenModelIsInvalid(String model) {
var workspaceName = RandomStringUtils.randomAlphanumeric(20);
var workspaceId = UUID.randomUUID().toString();
Expand All @@ -171,7 +170,7 @@ void createReturnsBadRequestWhenModelIsInvalid(String model) {

assertThat(errorMessage.getCode()).isEqualTo(HttpStatus.SC_BAD_REQUEST);
assertThat(errorMessage.getMessage())
.containsIgnoringCase("invalid model '%s'".formatted(model));
.containsIgnoringCase(ERROR_MODEL_NOT_SUPPORTED.formatted(model));
}

@ParameterizedTest
Expand Down

0 comments on commit 6983a0a

Please sign in to comment.