Class ModelCall
java.lang.Object
dev.langchain4j.test.service.ModelCall
- Direct Known Subclasses:
ChatModelCall, DecisionModelCall, EmbeddingModelCall, ModerationModelCall, ScoringModelCall
@Experimental
public abstract sealed class ModelCall
extends Object
permits ChatModelCall, EmbeddingModelCall, ScoringModelCall, ModerationModelCall, DecisionModelCall
A call to a model made during an AI Service invocation: by the AI Service itself to its chat model (see
ChatModelCall.isOwn()), or by the components it runs, for example a query transformer or a judge calling a
chat model, an embedding model used for retrieval, or a scoring model that re-ranks the retrieved contents.
There is one subclass per type of model, with the request and the response of that type:
ChatModelCall, EmbeddingModelCall, ScoringModelCall, ModerationModelCall and
DecisionModelCall.
Only calls whose listeners LangChain4j notifies are captured: the calls that go through the default methods of
the model interfaces (chat, embed, score, moderate, decide), which most
models of LangChain4j do. The calls of a model that bypasses them are not captured, for example a chat model that
overrides chat(...) instead of implementing doChat(...), or VertexAiScoringModel. See
AiServiceInvocation.modelCalls().
-
Method Summary
Modifier and TypeMethodDescriptionerror()Returns the error the call failed with, ornullif it did not fail.booleanReturns whether the call failed, that is whethererror()is notnull.Returns the provider of the model, ornullif the model does not report it.abstract Objectrequest()Returns the request sent to the model.abstract Objectresponse()Returns the response of the model, ornullif the call failed or had not ended when the invocation finished.toString()
-
Method Details
-
modelProvider
Returns the provider of the model, ornullif the model does not report it. -
request
Returns the request sent to the model. Each subclass returns the request type of its model, for exampleChatModelCall.request()returns aChatRequest. -
response
Returns the response of the model, ornullif the call failed or had not ended when the invocation finished. Each subclass returns the response type of its model, for exampleChatModelCall.response()returns aChatResponse. -
error
Returns the error the call failed with, ornullif it did not fail. -
hasFailed
public boolean hasFailed()Returns whether the call failed, that is whethererror()is notnull. A call that had not ended when the invocation finished has not failed: it has neither a response nor an error. -
toString
-