|
| 1 | +import logging |
1 | 2 | from typing import Optional, List, Any, Callable, Dict, Generator |
2 | 3 | from enum import Enum |
3 | 4 | from pydantic import Field |
|
10 | 11 | from .base import BaseAppInput, BaseAppOutput |
11 | 12 | from .file import File |
12 | 13 |
|
| 14 | +logger = logging.getLogger(__name__) |
13 | 15 |
|
14 | 16 | class ContextMessageRole(str, Enum): |
15 | 17 | USER = "user" |
@@ -322,10 +324,15 @@ def _update_tool_calls(self, new_tool_calls: List[Dict[str, Any]]) -> None: |
322 | 324 | current_tool["function"]["arguments"] += func_delta["arguments"] |
323 | 325 |
|
324 | 326 | 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 |
329 | 336 |
|
330 | 337 | def to_output(self, buffer: str, transformer: Any) -> LLMOutput: |
331 | 338 | """Convert current state to LLMOutput.""" |
|
0 commit comments