diff --git a/README.md b/README.md index e092003..64ac979 100644 --- a/README.md +++ b/README.md @@ -111,8 +111,8 @@ final var modelProfile = new ModelProfile( "gpt-4", // modelName "https://api.openai.com/v1", // url System.getenv("OPENAI_API_KEY"), // apiKey - new BigDecimal("0.03"), // costInToken (per token) - new BigDecimal("0.06"), // costOutToken (per token) + new BigDecimal("0.3").divide(1000000), // costPerInToken (per token) + new BigDecimal("0.6").divide(1000000), // costPerOutToken (per token) null, // reasoningEffort null, // reasoningSummaryDetails "DYNAMIC" // category (short name for logging) @@ -558,8 +558,8 @@ final var customProfile = new ModelProfile( "gpt-4-turbo", // modelName "https://api.openai.com/v1", // url System.getenv("OPENAI_API_KEY"), // apiKey - new BigDecimal("0.01"), // costInToken - new BigDecimal("0.03"), // costOutToken + new BigDecimal("0.3").divide(1000000), // costPerInToken (per token) + new BigDecimal("0.6").divide(1000000), // costPerOutToken (per token) null, // reasoningEffort null, // reasoningSummaryDetails "GPT4T" // category diff --git a/pom.xml b/pom.xml index bb910d8..65e50cd 100755 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ lm-lib de.extio lm-lib - 1.8.1 + 1.8.2 21 diff --git a/src/main/java/de/extio/lmlib/client/azureai/AzureAiClient.java b/src/main/java/de/extio/lmlib/client/azureai/AzureAiClient.java index 78dbdfd..83e016b 100755 --- a/src/main/java/de/extio/lmlib/client/azureai/AzureAiClient.java +++ b/src/main/java/de/extio/lmlib/client/azureai/AzureAiClient.java @@ -291,7 +291,7 @@ public final class AzureAiClient implements Client { Duration.between(start, LocalDateTime.now()), promptTokens, completionTokens, - new BigDecimal(promptTokens).multiply(modelProfile.costInToken()).add(new BigDecimal(completionTokens).multiply(modelProfile.costOutToken())), + new BigDecimal(promptTokens).multiply(modelProfile.costPerInToken()).add(new BigDecimal(completionTokens).multiply(modelProfile.costPerOutToken())), false); LOGGER.debug("{}", statistics); return statistics; diff --git a/src/main/java/de/extio/lmlib/client/oai/completion/AbstractCompletionClient.java b/src/main/java/de/extio/lmlib/client/oai/completion/AbstractCompletionClient.java index a6dcbce..c6efa57 100755 --- a/src/main/java/de/extio/lmlib/client/oai/completion/AbstractCompletionClient.java +++ b/src/main/java/de/extio/lmlib/client/oai/completion/AbstractCompletionClient.java @@ -161,7 +161,7 @@ public abstract class AbstractCompletionClient implements Client, DisposableBean Duration.between(start, LocalDateTime.now()), inTokens, outTokens, - new BigDecimal(inTokens).multiply(modelProfile.costInToken()).add(new BigDecimal(outTokens).multiply(modelProfile.costOutToken())), + new BigDecimal(inTokens).multiply(modelProfile.costPerInToken()).add(new BigDecimal(outTokens).multiply(modelProfile.costPerOutToken())), false); LOGGER.debug("{}", statistics); if (this.collectStatistics) { diff --git a/src/main/java/de/extio/lmlib/profile/ModelProfile.java b/src/main/java/de/extio/lmlib/profile/ModelProfile.java index f658c9f..784eb66 100755 --- a/src/main/java/de/extio/lmlib/profile/ModelProfile.java +++ b/src/main/java/de/extio/lmlib/profile/ModelProfile.java @@ -13,8 +13,8 @@ public record ModelProfile( String modelName, String url, String apiKey, - BigDecimal costInToken, - BigDecimal costOutToken, + BigDecimal costPerInToken, + BigDecimal costPerOutToken, String reasoningEffort, String reasoningSummaryDetails, String category) { diff --git a/src/main/java/de/extio/lmlib/profile/ModelProfileService.java b/src/main/java/de/extio/lmlib/profile/ModelProfileService.java index ce9527f..454ba08 100755 --- a/src/main/java/de/extio/lmlib/profile/ModelProfileService.java +++ b/src/main/java/de/extio/lmlib/profile/ModelProfileService.java @@ -71,12 +71,12 @@ public class ModelProfileService { final var url = Optional.ofNullable(resource.getProperty("url")) .map(Object::toString) .orElseThrow(() -> new IllegalStateException("No model url found for model: " + modelName)); - final var costInToken = Optional.ofNullable(resource.getProperty("cost1MInTokens")) + final var costPerInToken = Optional.ofNullable(resource.getProperty("cost1MInTokens")) .map(Object::toString) .map(value -> new BigDecimal(value)) .orElse(BigDecimal.ZERO) .divide(new BigDecimal(1000000.0)); - final var costOutToken = Optional.ofNullable(resource.getProperty("cost1MOutTokens")) + final var costPerOutToken = Optional.ofNullable(resource.getProperty("cost1MOutTokens")) .map(Object::toString) .map(value -> new BigDecimal(value)) .orElse(BigDecimal.ZERO) @@ -103,7 +103,7 @@ public class ModelProfileService { .orElse(null); } - return new ModelProfile(promptTemplate, tokenEncoding, maxTokens, maxContextLength, temperature, topP, modelProvider, modelNameCfg, url, apiKey, costInToken, costOutToken, reasoningEffort, reasoningSummaryDetails, category); + return new ModelProfile(promptTemplate, tokenEncoding, maxTokens, maxContextLength, temperature, topP, modelProvider, modelNameCfg, url, apiKey, costPerInToken, costPerOutToken, reasoningEffort, reasoningSummaryDetails, category); } catch (final IOException e) { LOGGER.error("Error while reading model profile", e);