MCPcopy Create free account
hub / github.com/1rgs/claude-code-proxy / compare_stream_stats

Function compare_stream_stats

tests.py:527–566  ·  view source on GitHub ↗

Compare the statistics from the two streams to see if they're similar enough.

(anthropic_stats, proxy_stats)

Source from the content-addressed store, hash-verified

525 return stats, error
526
527def compare_stream_stats(anthropic_stats, proxy_stats):
528 """Compare the statistics from the two streams to see if they're similar enough."""
529
530 print("\n--- Stream Comparison ---")
531
532 # Required events
533 anthropic_missing = REQUIRED_EVENT_TYPES - anthropic_stats.event_types
534 proxy_missing = REQUIRED_EVENT_TYPES - proxy_stats.event_types
535
536 print(f"Anthropic missing event types: {anthropic_missing}")
537 print(f"Proxy missing event types: {proxy_missing}")
538
539 # Check if proxy has the required events
540 if proxy_missing:
541 print(f"⚠️ Proxy is missing required event types: {proxy_missing}")
542 else:
543 print("✅ Proxy has all required event types")
544
545 # Compare content
546 if anthropic_stats.text_content and proxy_stats.text_content:
547 anthropic_preview = "\n".join(anthropic_stats.text_content.strip().split("\n")[:5])
548 proxy_preview = "\n".join(proxy_stats.text_content.strip().split("\n")[:5])
549
550 print("\n--- Anthropic Content Preview ---")
551 print(anthropic_preview)
552
553 print("\n--- Proxy Content Preview ---")
554 print(proxy_preview)
555
556 # Compare tool use
557 if anthropic_stats.has_tool_use and proxy_stats.has_tool_use:
558 print("✅ Both have tool use")
559 elif anthropic_stats.has_tool_use and not proxy_stats.has_tool_use:
560 print("⚠️ Anthropic has tool use but proxy does not")
561 elif not anthropic_stats.has_tool_use and proxy_stats.has_tool_use:
562 print("⚠️ Proxy has tool use but Anthropic does not")
563
564 # Success as long as proxy has some content and no errors
565 return (not proxy_stats.has_error and
566 len(proxy_stats.text_content) > 0 or proxy_stats.has_tool_use)
567
568async def test_streaming(test_name, request_data):
569 """Run a streaming test with the given request data."""

Callers 1

test_streamingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected