Skip to content

Commit

Permalink
Some test nits
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Apr 11, 2024
1 parent 3584d9a commit 8e0514b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ void testRunsClient() {
assertThat(assistantStreamEvent.data()).isNotNull();
return assistantStreamEvent.event();
})
// using a LinkedHashSet to preserve the order
.collect(Collectors.toCollection(LinkedHashSet::new));

assertThat(emittedEvents)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,14 +336,12 @@ void testFineTuningClient() {
assertThat(fineTuningJobEvents.hasMore()).isFalse();
assertThat(fineTuningJobEvents.data()).isNotEmpty();

// https://github.com/openai/openai-openapi/issues/217
// FineTuningClient.PaginatedFineTuningCheckpoints fineTuningCheckpoints =
// fineTuningClient.listFineTuningCheckpoints(
// createdFineTuningJob.id(), Optional.empty(), Optional.empty());
//
// assertThat(fineTuningCheckpoints.data()).isNotEmpty();
// assertThat(fineTuningCheckpoints.firstId()).isNotNull();
// assertThat(fineTuningCheckpoints.lastId()).isNotNull();
FineTuningClient.PaginatedFineTuningCheckpoints fineTuningCheckpoints =
fineTuningClient.listFineTuningCheckpoints(
createdFineTuningJob.id(), Optional.empty(), Optional.empty());

assertThat(fineTuningCheckpoints.hasMore()).isFalse();
assertThat(fineTuningCheckpoints.data()).isNotEmpty();

FineTuningJob retrievedFineTuningJob =
fineTuningClient.retrieveFineTuningJob(createdFineTuningJob.id());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ void validateFineTuning() {
validate(
"/" + Endpoint.FINE_TUNING.getPath() + "/{fine_tuning_job_id}/checkpoints",
Method.GET,
listCheckpointsResponse,
"Object has missing required properties ([\"n_epochs\"]");
listCheckpointsResponse);
}

@RepeatedTest(50)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,21 +579,17 @@ private ChatMessage randomChatMessage() {
}

private Map<Integer, Integer> randomLogitBias(int length) {
Map<Integer, Integer> logitBias = new HashMap<>();
for (int i = 0; i < length; i++) {
logitBias.put(randomInt(), randomInt(-100, 100));
}
return logitBias;
return randomKeyValueMap(length, this::randomInt, () -> randomInt(-100, 100));
}

private Map<String, String> randomMetadata() {
return randomKeyValueMap(
randomInt(1, 16), () -> randomString(3, 64), () -> randomString(10, 512));
}

private Map<String, String> randomKeyValueMap(
int length, Supplier<String> keyGenerator, Supplier<String> valueGenerator) {
Map<String, String> keyValueMap = new HashMap<>();
private <K, V> Map<K, V> randomKeyValueMap(
int length, Supplier<K> keyGenerator, Supplier<V> valueGenerator) {
Map<K, V> keyValueMap = new HashMap<>();
for (int i = 0; i < length; i++) {
keyValueMap.put(keyGenerator.get(), valueGenerator.get());
}
Expand Down

0 comments on commit 8e0514b

Please sign in to comment.