Skip to content
Closed

fix #78

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/rosa/rosa.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
from __future__ import annotations

import logging

from rich.console import Console
from contextlib import contextmanager
from typing import TYPE_CHECKING, Any, AsyncIterable, Dict, Literal, Optional, Union

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Import grouping looks off: from rich.console import Console (third-party) is currently placed between stdlib imports (logging and contextlib). Consider grouping stdlib imports together, then third-party (rich/langchain), then local imports to keep a consistent import order.

Suggested change
from rich.console import Console
from contextlib import contextmanager
from typing import TYPE_CHECKING, Any, AsyncIterable, Dict, Literal, Optional, Union
from contextlib import contextmanager
from typing import TYPE_CHECKING, Any, AsyncIterable, Dict, Literal, Optional, Union
from rich.console import Console

Copilot uses AI. Check for mistakes.
Expand Down Expand Up @@ -216,7 +218,7 @@ async def astream(self, query: str) -> AsyncIterable[Dict[str, Any]]:
# Extract the content from the event and yield it
content = event["data"]["chunk"].content
if content:
final_output += f" {content}"
final_output += content
yield {"type": "token", "content": content}

# Handle tool start events
Expand Down Expand Up @@ -328,9 +330,10 @@ def _print_usage(self, cb):
"""Print the token usage if show_token_usage is enabled."""
if cb is None or not self.__show_token_usage:
return
print(f"[bold]Prompt Tokens:[/bold] {cb.prompt_tokens}")
print(f"[bold]Completion Tokens:[/bold] {cb.completion_tokens}")
print(f"[bold]Total Cost (USD):[/bold] ${cb.total_cost}")
console = Console()
console.print(f"[bold]Prompt Tokens:[/bold] {cb.prompt_tokens}")
console.print(f"[bold]Completion Tokens:[/bold] {cb.completion_tokens}")
console.print(f"[bold]Total Cost (USD):[/bold] ${cb.total_cost}")

def _record_chat_history(self, query: str, response: str):
"""Record the chat history if accumulation is enabled."""
Expand Down
Loading