Skip to content

Commit

Permalink
External processor should honor $ in usage string
Browse files Browse the repository at this point in the history
  • Loading branch information
Tharsanan1 committed Sep 27, 2024
1 parent cebc399 commit 2003ea7
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,9 @@ private static Usage extractUsageFromBody(String body, String completionTokenPat

// Extract completion token count
String[] keysForCompletionTokens = completionTokenPath.split("\\.");
if (keysForCompletionTokens.length > 0 && "$".equals(keysForCompletionTokens[0])) {
keysForCompletionTokens = Arrays.copyOfRange(keysForCompletionTokens, 1, keysForCompletionTokens.length);
}
JsonNode currentNodeForCompletionToken = null;
if (rootNode.has(keysForCompletionTokens[0])) {
currentNodeForCompletionToken = rootNode.get(keysForCompletionTokens[0]);
Expand All @@ -347,6 +350,9 @@ private static Usage extractUsageFromBody(String body, String completionTokenPat

// Extract total token count
String[] keysForTotalTokens = totalTokenPath.split("\\.");
if (keysForTotalTokens.length > 0 && "$".equals(keysForTotalTokens[0])) {
keysForTotalTokens = Arrays.copyOfRange(keysForTotalTokens, 1, keysForTotalTokens.length);
}
JsonNode currentNodeForTotalToken = null;
if (rootNode.has(keysForTotalTokens[0])) {
currentNodeForTotalToken = rootNode.get(keysForTotalTokens[0]);
Expand Down

0 comments on commit 2003ea7

Please sign in to comment.