mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-05-15 11:57:12 +02:00
Updated integration tests
This commit is contained in:
parent
590364dd53
commit
e245d9633f
@ -208,7 +208,7 @@ public class OllamaAPIIntegrationTest {
|
|||||||
OllamaChatRequestBuilder builder = OllamaChatRequestBuilder.getInstance(chatModel);
|
OllamaChatRequestBuilder builder = OllamaChatRequestBuilder.getInstance(chatModel);
|
||||||
|
|
||||||
// Create the initial user question
|
// Create the initial user question
|
||||||
OllamaChatRequest requestModel = builder.withMessage(OllamaChatMessageRole.USER, "What is the capital of France?")
|
OllamaChatRequest requestModel = builder.withMessage(OllamaChatMessageRole.USER, "What is 1+1?")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Start conversation with model
|
// Start conversation with model
|
||||||
@ -216,13 +216,13 @@ public class OllamaAPIIntegrationTest {
|
|||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
chatResult.getChatHistory().stream()
|
chatResult.getChatHistory().stream()
|
||||||
.anyMatch(chat -> chat.getContent().contains("Paris")),
|
.anyMatch(chat -> chat.getContent().contains("2")),
|
||||||
"Expected chat history to contain 'Paris'"
|
"Expected chat history to contain '2'"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the next user question: second largest city
|
// Create the next user question: second largest city
|
||||||
requestModel = builder.withMessages(chatResult.getChatHistory())
|
requestModel = builder.withMessages(chatResult.getChatHistory())
|
||||||
.withMessage(OllamaChatMessageRole.USER, "And what is its official language?")
|
.withMessage(OllamaChatMessageRole.USER, "And what is its squared value?")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Continue conversation with model
|
// Continue conversation with model
|
||||||
@ -230,13 +230,13 @@ public class OllamaAPIIntegrationTest {
|
|||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
chatResult.getChatHistory().stream()
|
chatResult.getChatHistory().stream()
|
||||||
.anyMatch(chat -> chat.getContent().contains("French")),
|
.anyMatch(chat -> chat.getContent().contains("4")),
|
||||||
"Expected chat history to contain 'French'"
|
"Expected chat history to contain '4'"
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the next user question: the third question
|
// Create the next user question: the third question
|
||||||
requestModel = builder.withMessages(chatResult.getChatHistory())
|
requestModel = builder.withMessages(chatResult.getChatHistory())
|
||||||
.withMessage(OllamaChatMessageRole.USER, "What is the largest river in France?")
|
.withMessage(OllamaChatMessageRole.USER, "What is the largest value between 2, 4 and 6?")
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
// Continue conversation with the model for the third question
|
// Continue conversation with the model for the third question
|
||||||
@ -245,7 +245,7 @@ public class OllamaAPIIntegrationTest {
|
|||||||
// verify the result
|
// verify the result
|
||||||
assertNotNull(chatResult, "Chat result should not be null");
|
assertNotNull(chatResult, "Chat result should not be null");
|
||||||
assertTrue(chatResult.getChatHistory().size() > 2, "Chat history should contain more than two messages");
|
assertTrue(chatResult.getChatHistory().size() > 2, "Chat history should contain more than two messages");
|
||||||
assertTrue(chatResult.getChatHistory().get(chatResult.getChatHistory().size() - 1).getContent().contains("river"), "Response should be related to river");
|
assertTrue(chatResult.getChatHistory().get(chatResult.getChatHistory().size() - 1).getContent().contains("6"), "Response should contain '6'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user