feat: Update model profile and statistics tracking
- Updated model profile to support new cost parameters: costPerCachedInToken and costPerReasoningOutToken. - Enhanced AgentRequestStatistic to track cached input tokens and reasoning output tokens. - Modified CompletionStatistics to include cached input tokens and reasoning output tokens. - Updated AzureAiClient, CachedClient, and other clients to handle new statistics fields. - Introduced Timings class to capture detailed timing metrics for requests. - Adjusted Usage class to include input and output token details. - Updated properties files to include new cost parameters for cached and reasoning tokens.
This commit is contained in:
@@ -14,7 +14,9 @@ public record ModelProfile(
|
||||
String url,
|
||||
String apiKey,
|
||||
BigDecimal costPerInToken,
|
||||
BigDecimal costPerCachedInToken,
|
||||
BigDecimal costPerOutToken,
|
||||
BigDecimal costPerReasoningOutToken,
|
||||
String reasoningEffort,
|
||||
String reasoningSummaryDetails,
|
||||
String category) {
|
||||
|
||||
@@ -76,11 +76,19 @@ public class ModelProfileService {
|
||||
.map(value -> new BigDecimal(value))
|
||||
.orElse(BigDecimal.ZERO)
|
||||
.divide(new BigDecimal(1000000.0));
|
||||
final var costPerCachedInToken = Optional.ofNullable(resource.getProperty("cost1MCachedInTokens"))
|
||||
.map(Object::toString)
|
||||
.map(value -> new BigDecimal(value).divide(new BigDecimal(1000000.0)))
|
||||
.orElse(costPerInToken);
|
||||
final var costPerOutToken = Optional.ofNullable(resource.getProperty("cost1MOutTokens"))
|
||||
.map(Object::toString)
|
||||
.map(value -> new BigDecimal(value))
|
||||
.orElse(BigDecimal.ZERO)
|
||||
.divide(new BigDecimal(1000000.0));
|
||||
final var costPerReasoningOutToken = Optional.ofNullable(resource.getProperty("cost1MReasoningOutTokens"))
|
||||
.map(Object::toString)
|
||||
.map(value -> new BigDecimal(value).divide(new BigDecimal(1000000.0)))
|
||||
.orElse(BigDecimal.ZERO);
|
||||
final var reasoningEffort = Optional.ofNullable(resource.getProperty("reasoningEffort"))
|
||||
.map(Object::toString)
|
||||
.orElse(null);
|
||||
@@ -103,7 +111,7 @@ public class ModelProfileService {
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
return new ModelProfile(promptTemplate, tokenEncoding, maxTokens, maxContextLength, temperature, topP, modelProvider, modelNameCfg, url, apiKey, costPerInToken, costPerOutToken, reasoningEffort, reasoningSummaryDetails, category);
|
||||
return new ModelProfile(promptTemplate, tokenEncoding, maxTokens, maxContextLength, temperature, topP, modelProvider, modelNameCfg, url, apiKey, costPerInToken, costPerCachedInToken, costPerOutToken, costPerReasoningOutToken, reasoningEffort, reasoningSummaryDetails, category);
|
||||
}
|
||||
catch (final IOException e) {
|
||||
LOGGER.error("Error while reading model profile", e);
|
||||
|
||||
Reference in New Issue
Block a user