Skip to content

Commit

Permalink
fix: integration 0.4.2 (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovik authored Nov 29, 2023
1 parent 5982bb3 commit 57cb3af
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
10 changes: 8 additions & 2 deletions src/main/java/com/epam/aidial/core/config/Pricing.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.epam.aidial.core.config;

import com.epam.aidial.core.util.DoubleStringDeserializer;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Data;

@Data
public class Pricing {
private String unit;
private Double prompt;
private Double completion;

@JsonDeserialize(using = DoubleStringDeserializer.class)
private String prompt;

@JsonDeserialize(using = DoubleStringDeserializer.class)
private String completion;
}
4 changes: 2 additions & 2 deletions src/main/java/com/epam/aidial/core/data/PricingData.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public class PricingData {
private String unit;
private Double prompt;
private Double completion;
private String prompt;
private String completion;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.epam.aidial.core.util;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.exc.InvalidFormatException;

import java.io.IOException;

public class DoubleStringDeserializer extends JsonDeserializer<String> {

@Override
public String deserialize(JsonParser p, DeserializationContext ctx) throws IOException {
if (p.getCurrentToken() != JsonToken.VALUE_STRING) {
throw InvalidFormatException.from(p, "Expected a JSON string", p.getText(), String.class);
}

String value = p.getValueAsString();
try {
Double.parseDouble(value);
return value;
} catch (NumberFormatException e) {
throw InvalidFormatException.from(p, "Expected a JSON string with a valid double", value, String.class);
}
}
}
10 changes: 5 additions & 5 deletions src/main/resources/aidial.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
},
"pricing": {
"unit": "token",
"prompt": 0.00005,
"completion": 0.0001
"prompt": "0.00005",
"completion": "0.0001"
},
"features": {
"tokenizeEndpoint": "http://localhost:7001/v1/deployments/gpt-35-turbo/tokenize",
Expand All @@ -94,7 +94,7 @@
},
"pricing": {
"unit": "token",
"prompt": 0.00005
"prompt": "0.00005"
},
"features": {
"tokenizeEndpoint": "http://localhost:7001/openai/deployments/ada/tokenize"
Expand All @@ -105,8 +105,8 @@
"endpoint": "http://localhost:7001/openai/deployments/exotic-model/chat/completions",
"pricing": {
"unit": "char_without_whitespace",
"prompt": 0.00005,
"completion": 0.0001
"prompt": "0.00005",
"completion": "0.0001"
},
"features": {
"tokenizeEndpoint": "http://localhost:7001/v1/deployments/exotic-model/tokenize"
Expand Down

0 comments on commit 57cb3af

Please sign in to comment.