Skip to content

Commit f10ead0

Browse files
committed
fix: clean up deprecated code
1 parent 04834d2 commit f10ead0

File tree

2 files changed

+3
-397
lines changed

2 files changed

+3
-397
lines changed

src/llama_stack_client/lib/inference/event_logger.py

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# the root directory of this source tree.
66
from typing import Generator
77
from termcolor import cprint
8-
from llama_stack_client.types import ChatCompletionResponseStreamChunk, ChatCompletionChunk
8+
from llama_stack_client.types import ChatCompletionChunk
99

1010

1111
class InferenceStreamPrintableEvent:
@@ -28,35 +28,11 @@ def __init__(self):
2828
self.is_thinking = False
2929

3030
def yield_printable_events(
31-
self, chunk: ChatCompletionResponseStreamChunk | ChatCompletionChunk
31+
self, chunk: ChatCompletionChunk
3232
) -> Generator[InferenceStreamPrintableEvent, None, None]:
33-
# Check if the chunk has event attribute (ChatCompletionResponseStreamChunk)
34-
if hasattr(chunk, "event"):
35-
yield from self._handle_inference_stream_chunk(chunk)
36-
# Check if the chunk has choices attribute (ChatCompletionChunk)
37-
elif hasattr(chunk, "choices") and len(chunk.choices) > 0:
33+
if hasattr(chunk, "choices") and len(chunk.choices) > 0:
3834
yield from self._handle_chat_completion_chunk(chunk)
3935

40-
def _handle_inference_stream_chunk(
41-
self, chunk: ChatCompletionResponseStreamChunk
42-
) -> Generator[InferenceStreamPrintableEvent, None, None]:
43-
event = chunk.event
44-
if event.event_type == "start":
45-
yield InferenceStreamPrintableEvent("Assistant> ", color="cyan", end="")
46-
elif event.event_type == "progress":
47-
if event.delta.type == "reasoning":
48-
if not self.is_thinking:
49-
yield InferenceStreamPrintableEvent("<thinking> ", color="magenta", end="")
50-
self.is_thinking = True
51-
yield InferenceStreamPrintableEvent(event.delta.reasoning, color="magenta", end="")
52-
else:
53-
if self.is_thinking:
54-
yield InferenceStreamPrintableEvent("</thinking>", color="magenta", end="")
55-
self.is_thinking = False
56-
yield InferenceStreamPrintableEvent(event.delta.text, color="yellow", end="")
57-
elif event.event_type == "complete":
58-
yield InferenceStreamPrintableEvent("")
59-
6036
def _handle_chat_completion_chunk(
6137
self, chunk: ChatCompletionChunk
6238
) -> Generator[InferenceStreamPrintableEvent, None, None]:

0 commit comments

Comments
 (0)