- Added OllamaClient to handle conversations with the Ollama API. - Introduced OllamaDialect for managing thinking modes. - Created data classes: OllamaFunctionCall, OllamaListedModel, OllamaMessage, OllamaShowRequest, OllamaShowResponse, OllamaTagsResponse, OllamaToolCall, OllamaToolDefinition, and OllamaToolFunction for structured API communication. - Developed unit tests for OllamaClient to validate model listing, chat completion, streaming responses, and tool calling capabilities. - Configured test properties for local Ollama instance.
51 lines
1.5 KiB
Java
Executable File
51 lines
1.5 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 zero");
|
|
}
|
|
if (maxContextLength <= 0) {
|
|
throw new IllegalArgumentException("Model profile maxContextLength must be greater than 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 (url == null || url.isBlank()) {
|
|
throw new IllegalArgumentException("Model profile url is mandatory and cannot be empty");
|
|
}
|
|
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, OLLAMA;
|
|
}
|
|
}
|