Maps this instance's current variant to a value of type [T] using the given [visitor].
public T accept(Visitor<T> visitor)Maps this instance's current variant to a value of type [T] using the given [visitor]. Note that this method is not forwards compatible with new variants from the API, unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the SDK gracefully, consider overriding [Visitor.unknown]:
import com.langchain.smith.core.JsonValue;
import java.util.Optional;
Optional result = runStatsResponse.accept(new RunStatsResponse.Visitor>() {
@Override
public Optional visitRunStats(RunStats runStats) {
return Optional.of(runStats.toString());
}
// ...
@Override
public Optional unknown(JsonValue json) {
// Or inspect the `json`.
return Optional.empty();
}
});
LangChainInvalidDataException: if [Visitor.unknown] is not overridden in [visitor] and
the current variant is unknown.| Name | Type | Description |
|---|---|---|
visitor* | Visitor<T> |