feat: Introduce reasoning capabilities in chat and text completion
- Added AbstractCompletionRequest and AbstractCompletionResponse classes to standardize request and response structures. - Implemented StreamOptions for streaming responses in chat completions. - Enhanced ChatCompletionClient and TextCompletionClient to support reasoning content in responses. - Updated ModelProfile to include reasoning effort and summary details. - Created GptOssPromptStrategy to handle specific prompt formatting and reasoning extraction. - Modified existing tests to validate reasoning content in completions. - Updated configuration properties for reasoning settings in local properties files.
This commit is contained in:
@@ -14,7 +14,9 @@ public record ModelProfile(
|
||||
String url,
|
||||
String apiKey,
|
||||
BigDecimal costInToken,
|
||||
BigDecimal costOutToken) {
|
||||
BigDecimal costOutToken,
|
||||
String reasoningEffort,
|
||||
String reasoningSummaryDetails) {
|
||||
|
||||
public static enum ModelProvider {
|
||||
AZURE_AI, OAI_TEXT_COMPLETION, OAI_CHAT_COMPLETION;
|
||||
|
||||
@@ -85,8 +85,14 @@ public class ModelProfileService {
|
||||
.map(value -> new BigDecimal(value))
|
||||
.orElse(BigDecimal.ZERO)
|
||||
.divide(new BigDecimal(1000000.0));
|
||||
final var reasoningEffort = Optional.ofNullable(resource.getProperty("reasoningEffort"))
|
||||
.map(Object::toString)
|
||||
.orElse(null);
|
||||
final var reasoningSummaryDetails = Optional.ofNullable(resource.getProperty("reasoningSummaryDetails"))
|
||||
.map(Object::toString)
|
||||
.orElse(null);
|
||||
|
||||
//To resolve api key placeholder ${exchangeautodocumentation.azure.apikey} in model-name.properties file
|
||||
//To resolve api key placeholder ${apikey} in model-name.properties file
|
||||
String apiKey = null;
|
||||
synchronized (this.environment) {
|
||||
if (this.environment instanceof final ConfigurableEnvironment configurableEnvironment) {
|
||||
@@ -97,7 +103,7 @@ public class ModelProfileService {
|
||||
.orElseThrow(() -> new IllegalStateException("No model apiKey found for model: " + modelName));
|
||||
}
|
||||
|
||||
return new ModelProfile(promptTemplate, tokenEncoding, maxTokens, maxContextLength, temperature, topP, modelProvider, modelNameCfg, url, apiKey, costInToken, costOutToken);
|
||||
return new ModelProfile(promptTemplate, tokenEncoding, maxTokens, maxContextLength, temperature, topP, modelProvider, modelNameCfg, url, apiKey, costInToken, costOutToken, reasoningEffort, reasoningSummaryDetails);
|
||||
}
|
||||
catch (final IOException e) {
|
||||
LOGGER.error("Error while reading model profile", e);
|
||||
|
||||
Reference in New Issue
Block a user