Package org.codelibs.fess.llm
Interface LlmStreamCallback
- All Known Implementing Classes:
PhaseAwareStreamCallback
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Callback interface for receiving streaming chat responses from LLM.
-
Method Summary
Modifier and TypeMethodDescriptionvoidCalled for each chunk of the streaming response.default voidCalled when an error occurs during streaming.default voidCalled when the LLM HTTP call is being retried.default voidCalled when the request is waiting for a concurrency permit.default voidCalled when an internal silent fallback occurs (e.g., reasoning model token exhaustion).
-
Method Details
-
onChunk
Called for each chunk of the streaming response.- Parameters:
chunk- the text chunk from the LLM responsedone- true if this is the final chunk
-
onError
Called when an error occurs during streaming.- Parameters:
error- the error that occurred
-
onRetry
Called when the LLM HTTP call is being retried.- Parameters:
operation- log label for the operation (e.g., "chat", "streamChat")attempt- 1-based current attempt index that just failedmaxAttempts- total attempts including the firstsleepMs- milliseconds the client will sleep before the next attemptcause- the cause of the retry (RetryableHttpException or IOException)
-
onWaiting
Called when the request is waiting for a concurrency permit.- Parameters:
reason- short reason code, currently always "concurrency_limit"elapsedMs- milliseconds already spent waiting (0 on the first call)timeoutMs- maximum milliseconds the client will wait before giving up
-
onWarning
Called when an internal silent fallback occurs (e.g., reasoning model token exhaustion).- Parameters:
code- short machine-readable warning code (e.g., "reasoning_token_exhausted")detail- human-readable detail (free-form)
-