Skip to content

Commit

Permalink
docs: parse batch response
Browse files Browse the repository at this point in the history
  • Loading branch information
linux-china committed Oct 10, 2024
1 parent b4d5e91 commit 36db700
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,20 @@ public class PromptTest {
}
```

After `completion_window(24h)`, and you can call `openAIBatchAPI.retrieve(batchId)` to get the `BatchObject`.
Get `BatchObject.outputFileId` and call `OpenAIFileAPI.retrieve(outputFileId)` to get jsonl response,
and use follow code to parse every chat response.

```
List<String> lines = new BufferedReader(new InputStreamReader(inputStream)).lines().toList();
for (String line : lines) {
if (line.startsWith("{")) {
ChatCompletionBatchResponse response = objectMapper.readValue(line, ChatCompletionBatchResponse.class);
System.out.println(response.getCustomId());
}
}
```

# FAQ

### OpenAI REST API proxy
Expand Down

0 comments on commit 36db700

Please sign in to comment.