- Added OpenRouterModelDiscovery class for managing model listings and metadata resolution. - Introduced OpenRouterModelEndpointsResponse and OpenRouterModelsResponse classes for handling API responses. - Created OpenRouterModelQuery class to encapsulate query parameters for model listing. - Updated ModelProfile to include OPENROUTER as a model provider. - Enhanced ModelProfileService to handle default values for maxTokens and maxContextLength. - Added OpenRouterClientTest for testing model discovery and chat completion functionalities. - Configured application-test.properties and local-openrouter-chatcompletion.properties for OpenRouter integration.
48 lines
1.4 KiB
Java
Executable File
48 lines
1.4 KiB
Java
Executable File
package de.extio.lmlib.profile;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
public record ModelProfile(
|
|
String prompt,
|
|
String tokenizer,
|
|
String tokenEncoding,
|
|
int maxTokens,
|
|
int maxContextLength,
|
|
double temperature,
|
|
double topP,
|
|
ModelProvider modelProvider,
|
|
String modelName,
|
|
String url,
|
|
String apiKey,
|
|
BigDecimal costPerInToken,
|
|
BigDecimal costPerCachedInToken,
|
|
BigDecimal costPerOutToken,
|
|
BigDecimal costPerReasoningOutToken,
|
|
String category) {
|
|
|
|
public ModelProfile {
|
|
if (maxTokens < 0) {
|
|
throw new IllegalArgumentException("Model profile maxTokens must be greater than or equal to zero");
|
|
}
|
|
if (maxContextLength < 0) {
|
|
throw new IllegalArgumentException("Model profile maxContextLength must be greater than or equal to zero");
|
|
}
|
|
if (temperature <= 0) {
|
|
throw new IllegalArgumentException("Model profile temperature must be greater than zero");
|
|
}
|
|
if (topP <= 0) {
|
|
throw new IllegalArgumentException("Model profile topP must be greater than zero");
|
|
}
|
|
if (modelProvider == null) {
|
|
throw new IllegalArgumentException("Model profile modelProvider is mandatory and cannot be null");
|
|
}
|
|
if (category == null || category.isBlank()) {
|
|
throw new IllegalArgumentException("Model profile category is mandatory and cannot be empty");
|
|
}
|
|
}
|
|
|
|
public static enum ModelProvider {
|
|
OAI_TEXT_COMPLETION, OAI_CHAT_COMPLETION, OPENROUTER, OLLAMA;
|
|
}
|
|
}
|