Interface ChatGenerationMetadata
- All Superinterfaces:
ResultMetadata
- All Known Implementing Classes:
DefaultChatGenerationMetadata
Represents the metadata associated with the generation of a chat response.
- Since:
- 0.7.0
- Author:
- John Blum, Christian Tzolov
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionbuilder()booleancontainsKey(String key) entrySet()<T> @Nullable T@Nullable StringGet the reason this generation finished, as the provider names it.default FinishReasonCategoryReturn the normalized category of the finish reason, which is the same for every provider, whilegetFinishReason()keeps the name the provider uses.<T> TgetOrDefault(String key, T defaultObject) booleanisEmpty()keySet()
-
Field Details
-
NULL
-
-
Method Details
-
getFinishReason
@Nullable String getFinishReason()Get the reason this generation finished, as the provider names it. The names differ between providers:stop,end_turnandSTOPall say that the model finished its answer. For a meaning that is the same for every provider, seegetFinishReasonCategory().- Returns:
- the raw finish reason of the provider, or
nullwhen it gave none
-
getFinishReasonCategory
Return the normalized category of the finish reason, which is the same for every provider, whilegetFinishReason()keeps the name the provider uses.A chat model classifies its own finish reasons and sets the category with
ChatGenerationMetadata.Builder.finishReasonCategory(FinishReasonCategory). It sees the whole provider response, so it can also classify a stop that the finish reason alone does not tell, such as a refusal reported in another field.This default implementation is the fallback for metadata that carries no category. It classifies the raw string only: a
nullreason isFinishReasonCategory.UNSPECIFIEDand an unrecognized non-blank reason isFinishReasonCategory.OTHER.- Returns:
- the categorized finish reason, never
null - Since:
- 2.1.0
- See Also:
-
getContentFilters
-
get
-
containsKey
-
getOrDefault
-
entrySet
-
keySet
-
isEmpty
boolean isEmpty() -
builder
-