[Refactor/Bugfix] Use Delta Messages for Streaming (#2911)
Signed-off-by: Alex Brooks <albrooks@redhat.com> Signed-off-by: Sy03 <1370724210@qq.com> Signed-off-by: Yueqian Lin <linyueqian@outlook.com> Signed-off-by: Yueqian Lin <70319226+linyueqian@users.noreply.github.com> Co-authored-by: Sy03 <1370724210@qq.com> Co-authored-by: Yueqian Lin <linyueqian@outlook.com> Co-authored-by: Yueqian Lin <70319226+linyueqian@users.noreply.github.com>
This commit is contained in:
27 files changed
+623
-177
No files matched your search
@@ -8,7 +8,7 @@ for type-safe multimodal output routing and tensor merging.
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from enum import Enum, Flag, auto
|
||||
from enum import Enum, Flag, StrEnum, auto
|
||||
|
||||
_MODALITY_ALIASES: dict[str, str] = {
|
||||
"speech": "audio",
|
||||
@@ -21,6 +21,27 @@ _MODALITY_ALIASES: dict[str, str] = {
|
||||
}
|
||||
|
||||
|
||||
class OutputModalityNames(StrEnum):
|
||||
"""Keys for output modalities.
|
||||
|
||||
TODO: (Alex) Integrate this with the big-flag enum below + throughout the code
|
||||
for better type safety (currently only used for output processor).
|
||||
"""
|
||||
|
||||
TEXT = "text"
|
||||
IMAGE = "image"
|
||||
AUDIO = "audio"
|
||||
LATENT = "latent"
|
||||
|
||||
|
||||
# Specify which output modalities may be drained when handling delta messages.
|
||||
# For some types, e.g., latents, we need to be careful to ensure the full context
|
||||
# is passed as the stream yields due to assumptions in the I/O processing and model
|
||||
# when async chunk isn't enabled.
|
||||
NON_DRAINABLE_MODALITIES = {OutputModalityNames.TEXT, OutputModalityNames.LATENT}
|
||||
DRAINABLE_MODALITIES = {mod for mod in OutputModalityNames if mod not in NON_DRAINABLE_MODALITIES}
|
||||
|
||||
|
||||
class OutputModality(Flag):
|
||||
"""Bit-flag enum for output modalities.
|
||||
|
||||
|
||||
Reference in new issue
Block a user