Skip to content

Commit

Permalink
[python] Add generated_text key to rolling batch output
Browse files Browse the repository at this point in the history
  • Loading branch information
xyang16 committed Jul 5, 2023
1 parent 675c009 commit 173cb55
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ void addResponse(String json, boolean enableStreaming) {
} else {
nextToken.append(element.get("data").getAsString());
if (last) {
data.appendContent(BytesSupplier.wrap(nextToken.toString()), true);
data.appendContent(
BytesSupplier.wrap(
"{\"generated_text\": [\"" + nextToken.toString() + "\"]}"),
true);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public void testRollingBatch() throws TranslateException, IOException, ModelExce
Assert.assertNull(cbs.pollChunk());
String ret = cbs.getAsString();
System.out.println(ret);
Assert.assertTrue(ret.startsWith(" token_request4_"));
Assert.assertTrue(ret.startsWith("{\"generated_text\": [\" token_request4_"));
}
}

Expand Down

0 comments on commit 173cb55

Please sign in to comment.