diff --git a/src/cai/repl/commands/model.py b/src/cai/repl/commands/model.py index 94baea75..8595ede7 100644 --- a/src/cai/repl/commands/model.py +++ b/src/cai/repl/commands/model.py @@ -201,10 +201,6 @@ class ModelCommand(Command): console.print( "[yellow]Warning: Could not fetch model pricing data[/yellow]" ) - print("--------------------------------") - print(LITELLM_URL) - print(model_pricing_data) - print("--------------------------------") # Create a flat list of all models for numeric selection # pylint: disable=invalid-name ALL_MODELS = [] diff --git a/src/cai/sdk/agents/models/openai_chatcompletions.py b/src/cai/sdk/agents/models/openai_chatcompletions.py index fb5c0b58..4031a7af 100644 --- a/src/cai/sdk/agents/models/openai_chatcompletions.py +++ b/src/cai/sdk/agents/models/openai_chatcompletions.py @@ -358,16 +358,11 @@ class OpenAIChatCompletionsModel(Model): # Create streaming context if needed streaming_context = None if should_show_rich_stream: - #print(f"\nDEBUG: Creating streaming context with initial stats:") - #print(f"DEBUG: Model: {str(self.model)}") - #print(f"DEBUG: Agent name: {self.agent_name}") - #print(f"DEBUG: Counter: {self.interaction_counter}") streaming_context = create_agent_streaming_context( agent_name=self.agent_name, counter=self.interaction_counter, model=str(self.model) ) - print(f"DEBUG: Created streaming context: {streaming_context}") with generation_span( model=str(self.model), @@ -772,7 +767,6 @@ class OpenAIChatCompletionsModel(Model): interaction_cost = max(float(interaction_cost if interaction_cost is not None else 0.0), 0.00001) total_cost = max(float(total_cost if total_cost is not None else 0.0), 0.00001) - #print(f"DEBUG: Final direct cost calculations - Interaction: ${interaction_cost:.6f}, Total: ${total_cost:.6f}") # Create final stats with explicit type conversion for all values final_stats = { @@ -791,20 +785,12 @@ class OpenAIChatCompletionsModel(Model): "total_cost": float(total_cost), } - #print(f"DEBUG: Final stats costs (from dictionary) - Interaction: ${final_stats['interaction_cost']:.6f}, Total: ${final_stats['total_cost']:.6f}") - #print(f"DEBUG: Cost types in dictionary - Interaction: {type(final_stats['interaction_cost'])}, Total: {type(final_stats['total_cost'])}") - # At the end of streaming, finish the streaming context if we were using it if streaming_context: # Create a direct copy of the costs to ensure they remain as floats direct_stats = final_stats.copy() direct_stats["interaction_cost"] = float(interaction_cost) direct_stats["total_cost"] = float(total_cost) - - print(f"\nDEBUG: Final stats before finish_agent_streaming:") - print(f"DEBUG: Direct stats costs - Interaction: ${direct_stats['interaction_cost']:.6f}, Total: ${direct_stats['total_cost']:.6f}") - print(f"DEBUG: Direct stats types - Interaction: {type(direct_stats['interaction_cost'])}, Total: {type(direct_stats['total_cost'])}") - # Use the direct copy with guaranteed float costs finish_agent_streaming(streaming_context, direct_stats) # If we're not using rich streaming and not suppressing output, use old method diff --git a/src/cai/util.py b/src/cai/util.py index 7635ef5a..4bab6da4 100644 --- a/src/cai/util.py +++ b/src/cai/util.py @@ -367,7 +367,7 @@ def _create_token_display( # pylint: disable=too-many-arguments,too-many-locals current_cost = float(interaction_cost) if interaction_cost is not None else 0.0 except (ValueError, TypeError): current_cost = 0.0 - # print(f"DEBUG _create_token_display: Current cost after conversion: {current_cost}") + tokens_text.append(f"(${current_cost:.4f}) ", style="bold") # Separator @@ -387,7 +387,7 @@ def _create_token_display( # pylint: disable=too-many-arguments,too-many-locals total_cost_value = float(total_cost) if total_cost is not None else 0.0 except (ValueError, TypeError): total_cost_value = 0.0 - # print(f"DEBUG _create_token_display: Total cost after conversion: {total_cost_value}") + tokens_text.append(f"(${total_cost_value:.4f}) ", style="bold") # Separator @@ -586,13 +586,10 @@ def finish_agent_streaming(context, final_stats=None): total_output_tokens = final_stats.get("total_output_tokens") total_reasoning_tokens = final_stats.get("total_reasoning_tokens") - # CRITICAL FIX: Ensure costs are properly extracted and preserved as floats + # Ensure costs are properly extracted and preserved as floats interaction_cost = float(final_stats.get("interaction_cost", 0.0)) total_cost = float(final_stats.get("total_cost", 0.0)) - #print(f"\nDEBUG finish_agent_streaming: Received costs from final_stats - Interaction: {interaction_cost}, Total: {total_cost}") - #print(f"DEBUG finish_agent_streaming: Type of interaction_cost: {type(interaction_cost)}, Type of total_cost: {type(total_cost)}") - if (interaction_input_tokens is not None and interaction_output_tokens is not None and interaction_reasoning_tokens is not None and @@ -606,9 +603,6 @@ def finish_agent_streaming(context, final_stats=None): if total_cost is None or total_cost == 0.0: total_cost = calculate_model_cost(context["model"], total_input_tokens, total_output_tokens) - #print(f"DEBUG finish_agent_streaming: Costs before passing to _create_token_display - Interaction: {interaction_cost}, Total: {total_cost}") - #print(f"DEBUG finish_agent_streaming: Type of costs before passing - Interaction: {type(interaction_cost)}, Total: {type(total_cost)}") - tokens_text = _create_token_display( interaction_input_tokens, interaction_output_tokens,