Class CohereScoringModel
java.lang.Object
dev.langchain4j.model.cohere.CohereScoringModel
- All Implemented Interfaces:
ScoringModel
An implementation of a
ScoringModel that uses
Cohere Rerank API.-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuilder()doScoreAsync(ScoringRequest scoringRequest) Genuinely non-blocking counterpart ofscoreAll(List, String), used by the asynchronous and reactive RAG flow.scoreAll(List<TextSegment> segments, String query) Scores all providedTextSegments against a given query.static CohereScoringModelwithApiKey(String apiKey) Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ScoringModel
defaultRequestParameters, score, score, scoreAsync
-
Constructor Details
-
CohereScoringModel
-
CohereScoringModel
-
-
Method Details
-
withApiKey
Deprecated, for removal: This API element is subject to removal in a future version.Please usebuilder()instead, and explicitly set the model name and, if necessary, other parameters. -
builder
-
scoreAll
Description copied from interface:ScoringModelScores all providedTextSegments against a given query.- Specified by:
scoreAllin interfaceScoringModel- Parameters:
segments- The list ofTextSegments to score.query- The query against which to score the segments.- Returns:
- the list of scores. The order of scores corresponds to the order of
TextSegments.
-
doScoreAsync
Genuinely non-blocking counterpart ofscoreAll(List, String), used by the asynchronous and reactive RAG flow. The underlying HTTP call is dispatched asynchronously (no thread is parked while it is in flight), and cancelling the returned future aborts the in-flight call (best-effort).Like
scoreAll(List, String), a failed request is retried up tomaxRetriestimes (retry-around-future, composing futures without parking a thread); a cancellation is never retried.- Specified by:
doScoreAsyncin interfaceScoringModel- Parameters:
scoringRequest- the (already defaults-applied) request to score.- Returns:
- a
CompletableFutureof the scores, in the order ofScoringRequest.documents().
-
builder()instead, and explicitly set the model name and, if necessary, other parameters.