Skip to content

Commit

Permalink
Update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ntqdinh-axonivy committed Nov 20, 2024
1 parent d1f9c21 commit 7e6148c
Showing 3 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -97,10 +97,8 @@ private String input(JsonNode request, Map<String, JsonNode> examples) {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response chat(JsonNode request) {
Ivy.log().warn(request.toPrettyString());
var in = input(request, openAIExamples);
var node = openAIExamples.get(in+"-response");
Ivy.log().warn(request);
return Response.ok()
.entity(node)
.build();
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@
"index": 0,
"message": {
"role": "assistant",
"content": "<select id=\"brand-select\">\n <option value=\"mercedes\">Mercedes</option>\n <option value=\"bmw\">BMW</option>\n <option value=\"tesla\">Tesla</option>\n</select>",
"content": "<select id=\"brand-select-without-system-promt\">\n <option value=\"mercedes\">Mercedes</option>\n <option value=\"bmw\">BMW</option>\n <option value=\"tesla\">Tesla</option>\n</select>",
"refusal": null
},
"logprobs": null,
Original file line number Diff line number Diff line change
@@ -91,8 +91,17 @@ void mailGenerator() {
@Test
void askWithOutSystemPromt() {
JsonNode result = assistWithQuestion("insert a combobox to pick a brand out of: Mercedes, BMW or Tesla", false);
assertThat(result.toPrettyString())
.isNotEmpty();
assertThat(result.toPrettyString()).isNotEmpty();
assertThat(result.toPrettyString()).as("Provide combobox with generated message")
.contains("Sure, here is a combobox for you to pick a brand out of Mercedes, BMW, or Tesla");
}

@Test
void insertWithSystemPromt() {
JsonNode result = assistWithQuestion("insert a combobox to pick a brand out of: Mercedes, BMW or Tesla", true);
assertThat(result.toPrettyString()).isNotEmpty();
assertThat(result.toPrettyString()).as("Provide combobox with system promt")
.contains("<select id=\\\"brand-select-without-system-promt\\\"");
}

private static JsonNode assist(JsonNode quest) {
@@ -114,7 +123,6 @@ private static JsonNode chatAssist(JsonNode quest) {
private static JsonNode assistWithQuestion(String question, boolean includeSystemPrompt) {
WebTarget client = Ivy.rest().client(OPEN_AI);
Entity<JsonNode> request = buildPayloadFromQuestion(question, includeSystemPrompt);
Ivy.log().warn("here");
JsonNode result = client.path("chat/completions").request()
.post(request).readEntity(JsonNode.class);
return result;

0 comments on commit 7e6148c

Please sign in to comment.