Uses of Class
dev.langchain4j.test.mock.MockEmbeddingModel
Packages that use MockEmbeddingModel
Package
Description
Model mocks for tests: they need no network, answer the way a test tells them to, and record the requests they
receive.
-
Uses of MockEmbeddingModel in dev.langchain4j.test.mock
Methods in dev.langchain4j.test.mock that return MockEmbeddingModelModifier and TypeMethodDescriptionstatic MockEmbeddingModelMockEmbeddingModel.thatEmbeds(float... vector) A model that answers the first request with the given vector for every text.static MockEmbeddingModelMockEmbeddingModel.thatEmbeds(Function<String, float[]> embeddings) A model that answers the first request with the vector computed from each text, so the test says which texts are close to each other.static MockEmbeddingModelMockEmbeddingModel.thatFails(RuntimeException exception) A model whose first request fails with exactly the given exception.static MockEmbeddingModelMockEmbeddingModel.thatResponds(EmbeddingResponse response) A model that answers the first request with exactly the given response, including its metadata, for example its token usage or model name, to test code that reads them, such as a cost check:MockEmbeddingModel.thenEmbeds(float... vector) Adds a step: every text of the next request gets the given vector.MockEmbeddingModel.thenEmbeds(Function<String, float[]> embeddings) Adds a step: every text of the next request gets the vector computed from it, seeMockEmbeddingModel.thatEmbeds(Function).MockEmbeddingModel.thenFails(RuntimeException exception) Adds a step: the next request fails with exactly the given exception.MockEmbeddingModel.thenRepeats()Answers every further request with the last step of the script.MockEmbeddingModel.thenResponds(EmbeddingResponse response) Adds a step: the next request is answered with exactly the given response, including its metadata, seeMockEmbeddingModel.thatResponds(EmbeddingResponse).MockEmbeddingModel.withListeners(EmbeddingModelListener... listeners) Notifies the given listeners of each call, like a real model does.MockEmbeddingModel.withListeners(List<EmbeddingModelListener> listeners) Notifies the given listeners of each call, like a real model does.