-
public interface LlmCallbackCallback interface for Llm model. Users can implement this interface to receive the generated tokens and statistics.
Warning: These APIs are experimental and subject to change without notice
-
-
Method Summary
Modifier and Type Method Description abstract UnitonResult(String result)Called when a new result is available from JNI. UnitonStats(String stats)Called when the statistics for the generate() is available. UnitonError(Integer errorCode, String message)Called when an error occurs during generate(). -
-
Method Detail
-
onResult
abstract Unit onResult(String result)
Called when a new result is available from JNI. Users will keep getting onResult() invocations until generate() finishes.
- Parameters:
result- Last generated token
-
onStats
Unit onStats(String stats)
Called when the statistics for the generate() is available.
The result will be a JSON string. See extension/llm/stats.h for the field definitions.
- Parameters:
stats- JSON string containing the statistics for the generate()
-
onError
Unit onError(Integer errorCode, String message)
Called when an error occurs during generate().
- Parameters:
errorCode- Error code from the ExecuTorch runtime (see org.pytorch.executorch.ExecutorchRuntimeException)message- Human-readable error description
-
-
-
-