mirror of
https://github.com/amithkoujalgi/ollama4j.git
synced 2025-11-04 10:30:41 +01:00
Refactor model response classes and update API methods
- Renamed `ModelProcessesResponse` to `ModelProcessesResult` and updated all related references in the codebase. - Introduced `OllamaEmbedResult` class to replace `OllamaEmbedResponse`, ensuring consistency across the API. - Updated method signatures in `OllamaAPI` to reflect the new class names and adjusted integration tests accordingly.
This commit is contained in:
@@ -16,7 +16,7 @@ import io.github.ollama4j.impl.ConsoleOutputChatTokenHandler;
|
||||
import io.github.ollama4j.impl.ConsoleOutputGenerateTokenHandler;
|
||||
import io.github.ollama4j.models.chat.*;
|
||||
import io.github.ollama4j.models.embed.OllamaEmbedRequest;
|
||||
import io.github.ollama4j.models.embed.OllamaEmbedResponse;
|
||||
import io.github.ollama4j.models.embed.OllamaEmbedResult;
|
||||
import io.github.ollama4j.models.generate.OllamaGenerateRequest;
|
||||
import io.github.ollama4j.models.generate.OllamaGenerateRequestBuilder;
|
||||
import io.github.ollama4j.models.generate.OllamaGenerateStreamObserver;
|
||||
@@ -234,7 +234,7 @@ class OllamaAPIIntegrationTest {
|
||||
OllamaEmbedRequest m = new OllamaEmbedRequest();
|
||||
m.setModel(EMBEDDING_MODEL);
|
||||
m.setInput(Arrays.asList("Why is the sky blue?", "Why is the grass green?"));
|
||||
OllamaEmbedResponse embeddings = api.embed(m);
|
||||
OllamaEmbedResult embeddings = api.embed(m);
|
||||
assertNotNull(embeddings, "Embeddings should not be null");
|
||||
assertFalse(embeddings.getEmbeddings().isEmpty(), "Embeddings should not be empty");
|
||||
}
|
||||
@@ -1333,7 +1333,7 @@ class OllamaAPIIntegrationTest {
|
||||
requestModel.setInput(
|
||||
Collections.singletonList("This is a single test sentence for embedding."));
|
||||
|
||||
OllamaEmbedResponse embeddings = api.embed(requestModel);
|
||||
OllamaEmbedResult embeddings = api.embed(requestModel);
|
||||
|
||||
assertNotNull(embeddings);
|
||||
assertFalse(embeddings.getEmbeddings().isEmpty());
|
||||
|
||||
@@ -17,7 +17,7 @@ import io.github.ollama4j.exceptions.OllamaException;
|
||||
import io.github.ollama4j.exceptions.RoleNotFoundException;
|
||||
import io.github.ollama4j.models.chat.OllamaChatMessageRole;
|
||||
import io.github.ollama4j.models.embed.OllamaEmbedRequest;
|
||||
import io.github.ollama4j.models.embed.OllamaEmbedResponse;
|
||||
import io.github.ollama4j.models.embed.OllamaEmbedResult;
|
||||
import io.github.ollama4j.models.generate.OllamaGenerateRequest;
|
||||
import io.github.ollama4j.models.generate.OllamaGenerateRequestBuilder;
|
||||
import io.github.ollama4j.models.generate.OllamaGenerateStreamObserver;
|
||||
@@ -112,7 +112,7 @@ class TestMockedAPIs {
|
||||
OllamaEmbedRequest m = new OllamaEmbedRequest();
|
||||
m.setModel(model);
|
||||
m.setInput(List.of(prompt));
|
||||
when(ollamaAPI.embed(m)).thenReturn(new OllamaEmbedResponse());
|
||||
when(ollamaAPI.embed(m)).thenReturn(new OllamaEmbedResult());
|
||||
ollamaAPI.embed(m);
|
||||
verify(ollamaAPI, times(1)).embed(m);
|
||||
} catch (OllamaException e) {
|
||||
@@ -127,7 +127,7 @@ class TestMockedAPIs {
|
||||
List<String> inputs = List.of("some prompt text");
|
||||
try {
|
||||
OllamaEmbedRequest m = new OllamaEmbedRequest(model, inputs);
|
||||
when(ollamaAPI.embed(m)).thenReturn(new OllamaEmbedResponse());
|
||||
when(ollamaAPI.embed(m)).thenReturn(new OllamaEmbedResult());
|
||||
ollamaAPI.embed(m);
|
||||
verify(ollamaAPI, times(1)).embed(m);
|
||||
} catch (OllamaException e) {
|
||||
@@ -142,7 +142,7 @@ class TestMockedAPIs {
|
||||
List<String> inputs = List.of("some prompt text");
|
||||
try {
|
||||
when(ollamaAPI.embed(new OllamaEmbedRequest(model, inputs)))
|
||||
.thenReturn(new OllamaEmbedResponse());
|
||||
.thenReturn(new OllamaEmbedResult());
|
||||
ollamaAPI.embed(new OllamaEmbedRequest(model, inputs));
|
||||
verify(ollamaAPI, times(1)).embed(new OllamaEmbedRequest(model, inputs));
|
||||
} catch (OllamaException e) {
|
||||
|
||||
Reference in New Issue
Block a user