Skip to content

Commit

Permalink
remove System.out.println() from tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LangChain4j committed Aug 26, 2024
1 parent d5bc868 commit cc7121a
Show file tree
Hide file tree
Showing 47 changed files with 0 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ void should_generate_answer_and_return_token_usage_and_finish_reason_stop() {

// when
Response<AiMessage> response = model.generate(userMessage);
System.out.println(response);

// then
assertThat(response.content().text()).contains("Berlin");
Expand Down Expand Up @@ -146,7 +145,6 @@ void should_respect_maxTokens() {

// when
Response<AiMessage> response = model.generate(userMessage);
System.out.println(response);

// then
assertThat(response.content().text()).isNotBlank();
Expand All @@ -166,7 +164,6 @@ void should_respect_system_message() {

// when
Response<AiMessage> response = model.generate(systemMessage, userMessage);
System.out.println(response);

// then
assertThat(response.content().text()).containsIgnoringCase("liebe");
Expand All @@ -189,7 +186,6 @@ void should_respect_stop_sequences() {

// when
Response<AiMessage> response = model.generate(userMessage);
System.out.println(response);

// then
assertThat(response.content().text()).containsIgnoringCase("hello");
Expand Down Expand Up @@ -222,7 +218,6 @@ void test_all_parameters() {

// when
Response<AiMessage> response = model.generate(userMessage);
System.out.println(response);

// then
assertThat(response.content().text()).isNotBlank();
Expand All @@ -245,7 +240,6 @@ void should_support_all_enum_model_names(AnthropicChatModelName modelName) {

// when
Response<AiMessage> response = model.generate(userMessage);
System.out.println(response);

// then
assertThat(response.content().text()).isNotBlank();
Expand All @@ -270,7 +264,6 @@ void should_support_all_string_model_names(AnthropicChatModelName modelName) {

// when
Response<AiMessage> response = model.generate(userMessage);
System.out.println(response);

// then
assertThat(response.content().text()).isNotBlank();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ void should_support_all_string_model_names(AzureOpenAiChatModelName modelName) {

// when
Response<AiMessage> response = model.generate(userMessage);
System.out.println(response);

// then
assertThat(response.content().text()).isNotBlank();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ void should_support_all_string_model_names(AzureOpenAiLanguageModelName modelNam
// when
String prompt = "Describe the capital of France in 100 words: ";
Response<String> response = model.generate(prompt);
System.out.println(response.toString());

// then
assertThat(response.finishReason()).isEqualTo(LENGTH);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ public class TestStreamingResponseHandler<T> implements StreamingResponseHandler

@Override
public void onNext(String token) {
System.out.println("onNext: '" + token + "'");
textContentBuilder.append(token);
}

@Override
public void onComplete(Response<T> response) {
System.out.println("onComplete: '" + response + "'");

String expectedTextContent = textContentBuilder.toString();
if (response.content() instanceof AiMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ void should_support_special_characters(String s) {

// when
Prompt prompt = promptTemplate.apply(s);
System.out.println(prompt.text());

// then
assertThat(prompt.text()).isEqualTo("This is " + s + ".");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void should_send_non_multimodal_messages_and_receive_response(String mode
.build();

Response<AiMessage> response = model.generate(QwenTestHelper.chatMessages());
System.out.println(response);

assertThat(response.content().text()).containsIgnoringCase("rain");
}
Expand Down Expand Up @@ -217,7 +216,6 @@ public void should_send_multimodal_image_url_and_receive_response(String modelNa
.build();

Response<AiMessage> response = model.generate(multimodalChatMessagesWithImageUrl());
System.out.println(response);

assertThat(response.content().text()).containsIgnoringCase("dog");
}
Expand All @@ -231,7 +229,6 @@ public void should_send_multimodal_image_data_and_receive_response(String modelN
.build();

Response<AiMessage> response = model.generate(multimodalChatMessagesWithImageData());
System.out.println(response);

assertThat(response.content().text()).containsIgnoringCase("parrot");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public void should_send_messages_and_receive_response(String modelName) {
.modelName(modelName)
.build();
Response<String> response = model.generate("Please say 'hello' to me");
System.out.println(response);

assertThat(response.content()).containsIgnoringCase("hello");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public void should_send_non_multimodal_messages_and_receive_response(String mode
TestStreamingResponseHandler<AiMessage> handler = new TestStreamingResponseHandler<>();
model.generate(chatMessages(), handler);
Response<AiMessage> response = handler.get();
System.out.println(response);

assertThat(response.content().text()).containsIgnoringCase("rain");
assertThat(response.content().text()).endsWith("That's all!");
Expand All @@ -40,7 +39,6 @@ public void should_send_multimodal_image_url_and_receive_response(String modelNa
TestStreamingResponseHandler<AiMessage> handler = new TestStreamingResponseHandler<>();
model.generate(multimodalChatMessagesWithImageUrl(), handler);
Response<AiMessage> response = handler.get();
System.out.println(response);

assertThat(response.content().text()).containsIgnoringCase("dog");
assertThat(response.content().text()).endsWith("That's all!");
Expand All @@ -56,7 +54,6 @@ public void should_send_multimodal_image_data_and_receive_response(String modelN
TestStreamingResponseHandler<AiMessage> handler = new TestStreamingResponseHandler<>();
model.generate(multimodalChatMessagesWithImageData(), handler);
Response<AiMessage> response = handler.get();
System.out.println(response);

assertThat(response.content().text()).containsIgnoringCase("parrot");
assertThat(response.content().text()).endsWith("That's all!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public void should_send_messages_and_receive_response(String modelName) {
TestStreamingResponseHandler<String> handler = new TestStreamingResponseHandler<>();
model.generate("Please say 'hello' to me", handler);
Response<String> response = handler.get();
System.out.println(response);

assertThat(response.content()).containsIgnoringCase("hello");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ void RAG_should_be_easy_to_setup() {
.build();

String answer = assistant.chat("How many days before the rental can I cancel my booking?");
System.out.println(answer);

assertThat(answer).containsAnyOf("17", "61");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public void should_send_messages_and_receive_response() {
).content();

assertThat(aiMessage.text()).isNotBlank();
System.out.println(aiMessage.text());
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public void should_send_prompt_and_receive_response() {
String answer = model.generate("What is the capital of the USA?").content();

assertThat(answer).containsIgnoringCase("Washington");
System.out.println(answer);
}

@ParameterizedTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ void should_send_messages_and_return_response() {

// when
Response<AiMessage> response = model.generate(messages);
System.out.println(response);

// then
AiMessage aiMessage = response.content();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void should_embed() {

// when
Response<Embedding> response = model.embed(text);
System.out.println(response);

// then
assertThat(response.content().vector()).isNotEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void should_send_prompt_and_return_response() {

// when
Response<String> response = model.generate(prompt);
System.out.println(response);

// then
assertThat(response.content()).isNotBlank();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ void should_send_user_message_and_return_string_response() {

// when
String response = model.generate(userMessage);
System.out.println(response);

// then
assertThat(response).isNotBlank();
Expand All @@ -45,7 +44,6 @@ void should_send_messages_and_return_response() {

// when
Response<AiMessage> response = model.generate(messages);
System.out.println(response);

// then
AiMessage aiMessage = response.content();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ void should_embed_text() {

// when
Response<Embedding> response = model.embed(text);
System.out.println(response);

// then
Embedding embedding = response.content();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void should_send_prompt_and_return_response() {

// when
Response<String> response = model.generate(prompt);
System.out.println(response);

// then
assertThat(response.content()).isNotBlank();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ void should_generate_response() {

// when
Response<AiMessage> response = model.generate(userMessage);
System.out.println(response);

// then
AiMessage aiMessage = response.content();
Expand Down Expand Up @@ -66,7 +65,6 @@ void should_respect_numPredict() {

// when
Response<AiMessage> response = model.generate(userMessage);
System.out.println(response);

// then
assertThat(response.content().text()).doesNotContain("Berlin");
Expand All @@ -82,7 +80,6 @@ void should_respect_system_message() {

// when
Response<AiMessage> response = model.generate(systemMessage, userMessage);
System.out.println(response);

// then
assertThat(response.content().text()).containsIgnoringCase("liebe");
Expand All @@ -104,7 +101,6 @@ void should_respond_to_few_shot() {

// when
Response<AiMessage> response = model.generate(messages);
System.out.println(response);

// then
assertThat(response.content().text()).startsWith(">>> 8");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ void should_embed() {

// when
Response<Embedding> response = model.embed(text);
System.out.println(response);

// then
assertThat(response.content().vector()).isNotEmpty();
Expand All @@ -48,7 +47,6 @@ void should_embed_multiple_segments() {

// when
Response<List<Embedding>> response = model.embedAll(segments);
System.out.println(response);

// then
assertThat(response.content()).hasSize(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ void should_generate_answer() {

// when
Response<String> response = model.generate(userMessage);
System.out.println(response);

// then
assertThat(response.content()).contains("Berlin");
Expand All @@ -46,7 +45,6 @@ void should_respect_numPredict() {

// when
Response<String> response = model.generate(prompt);
System.out.println(response);

// then
assertThat(response.content()).doesNotContain("Berlin");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ void should_generate_response() {

// when
Response<AiMessage> response = model.generate(userMessage);
System.out.println(response);

// then
AiMessage aiMessage = response.content();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ void should_generate_response() {
TestStreamingResponseHandler<AiMessage> handler = new TestStreamingResponseHandler<>();
model.generate(userMessage, handler);
Response<AiMessage> response = handler.get();
System.out.println(response);

// then
AiMessage aiMessage = response.content();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ void should_embed_single_text() {

// when
Response<Embedding> response = model.embed(text);
System.out.println(response);

// then
assertThat(response.content().vector()).hasSize(1536);
Expand All @@ -56,7 +55,6 @@ void should_embed_multiple_segments() {

// when
Response<List<Embedding>> response = model.embedAll(segments);
System.out.println(response);

// then
assertThat(response.content()).hasSize(2);
Expand Down Expand Up @@ -91,7 +89,6 @@ void should_embed_text_with_embedding_shortening() {

// when
Response<Embedding> response = model.embed(text);
System.out.println(response);

// then
assertThat(response.content().dimension()).isEqualTo(dimension);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ void should_use_enum_as_model_name() {

// when
Response<Image> response = model.generate(prompt);
System.out.println(response);

// then
URI remoteImage = response.content().url();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ void should_generate_answer_and_return_token_usage_and_finish_reason_stop() {
String prompt = "What is the capital of Germany?";

Response<String> response = model.generate(prompt);
System.out.println(response);

assertThat(response.content()).contains("Berlin");

Expand Down
Loading

0 comments on commit cc7121a

Please sign in to comment.