feat(backends,conversations,frontends): opus 5.5 progress updates reach telegram, current claude cli in the image
This commit is contained in:
1 parent
e58153628c
commit
bbce425eeb
9 files changed
+140
-20
No files matched your search
@@ -32,11 +32,11 @@ from beaver_gateway.frontends.accumulate import StreamAccumulator
|
||||
from beaver_gateway.storage.models import Conversation, InjectQueueItem, RateLimit
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from collections.abc import AsyncIterator, Callable, Sequence
|
||||
from collections.abc import AsyncIterator, Callable, Iterable, Sequence
|
||||
|
||||
from beaver_gateway.events.stream import MessageStreamEvent
|
||||
|
||||
__all__ = ["Turns", "content_of", "image_block"]
|
||||
__all__ = ["Turns", "content_of", "image_block", "reply_text"]
|
||||
|
||||
_log = logging.getLogger(__name__)
|
||||
|
||||
@@ -164,12 +164,7 @@ class Turns(Seeds):
|
||||
):
|
||||
acc.feed(event)
|
||||
message = acc.finalize(model=agent.model)
|
||||
reply = "\n\n".join(
|
||||
getattr(b, "text", "")
|
||||
for b in message.content
|
||||
if getattr(b, "type", "") == "text"
|
||||
).strip()
|
||||
return reply, capture
|
||||
return reply_text(message.content), capture
|
||||
|
||||
async def before_turn(self, conv: Conversation) -> str | None: # noqa: ARG002
|
||||
return None
|
||||
@@ -489,6 +484,22 @@ class Turns(Seeds):
|
||||
IMAGE_MAX_BYTES = 5 * 1024 * 1024
|
||||
|
||||
|
||||
def reply_text(content: Iterable[Any]) -> str:
|
||||
"""Text blocks plus non-empty thinking blocks, in block order.
|
||||
|
||||
What the model writes between tool calls rides in thinking blocks; the
|
||||
hidden reasoning in them is empty and drops out on its own.
|
||||
"""
|
||||
parts: list[str] = []
|
||||
for block in content:
|
||||
kind = getattr(block, "type", "")
|
||||
if kind == "text":
|
||||
parts.append(getattr(block, "text", "") or "")
|
||||
elif kind == "thinking":
|
||||
parts.append(getattr(block, "thinking", "") or "")
|
||||
return "\n\n".join(p for p in parts if p).strip()
|
||||
|
||||
|
||||
def content_of(
|
||||
text: str, attachments: Sequence[dict[str, Any]] | None
|
||||
) -> str | list[dict[str, Any]]:
|
||||
|
||||
Reference in new issue
Block a user