mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-05-15 20:07:10 +02:00
Merge pull request #107 from ollama4j/integration-tests-updates
All checks were successful
Mark stale issues / stale (push) Successful in 21s
All checks were successful
Mark stale issues / stale (push) Successful in 21s
test
This commit is contained in:
commit
c9db51a71e
@ -1,11 +1,8 @@
|
|||||||
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created
|
|
||||||
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path
|
|
||||||
|
|
||||||
name: Run Tests
|
name: Run Tests
|
||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
# types: [ opened, reopened ]
|
# types: [opened, reopened, synchronize, edited]
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
|
@ -203,12 +203,12 @@ public class OllamaAPIIntegrationTest {
|
|||||||
@Test
|
@Test
|
||||||
@Order(10)
|
@Order(10)
|
||||||
public void testChat() throws Exception {
|
public void testChat() throws Exception {
|
||||||
String chatModel = "qwen2.5:0.5b";
|
String chatModel = "llama3";
|
||||||
api.pullModel(chatModel);
|
api.pullModel(chatModel);
|
||||||
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? Answer only in numbers.")
|
||||||
.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