Skip to content

Commit f50a53f

Browse files
committed
fix stats
1 parent ed920b3 commit f50a53f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/inferencesh/models/llm.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
from typing import Optional, List, Any, Callable, Dict, Generator
23
from enum import Enum
34
from pydantic import Field
@@ -10,6 +11,7 @@
1011
from .base import BaseAppInput, BaseAppOutput
1112
from .file import File
1213

14+
logger = logging.getLogger(__name__)
1315

1416
class ContextMessageRole(str, Enum):
1517
USER = "user"
@@ -322,10 +324,15 @@ def _update_tool_calls(self, new_tool_calls: List[Dict[str, Any]]) -> None:
322324
current_tool["function"]["arguments"] += func_delta["arguments"]
323325

324326
def has_updates(self) -> bool:
325-
"""Check if this response has any content or tool call updates."""
326-
has_updates = bool(self.content) or bool(self.tool_calls)
327-
print(f"DEBUG: has_updates: {has_updates}, content: {bool(self.content)}, tool_calls: {bool(self.tool_calls)}")
328-
return has_updates
327+
"""Check if this response has any content, tool call, or usage updates."""
328+
has_content = bool(self.content)
329+
has_tool_calls = bool(self.tool_calls)
330+
has_usage = self.usage_stats["prompt_tokens"] > 0 or self.usage_stats["completion_tokens"] > 0
331+
has_finish = bool(self.finish_reason)
332+
333+
print(f"DEBUG: has_updates check - content: {has_content}, tool_calls: {has_tool_calls}, usage: {has_usage}, finish: {has_finish}")
334+
335+
return has_content or has_tool_calls or has_usage or has_finish
329336

330337
def to_output(self, buffer: str, transformer: Any) -> LLMOutput:
331338
"""Convert current state to LLMOutput."""

0 commit comments

Comments
 (0)