Compare responses from both providers.
()
| 115 | |
| 116 | |
| 117 | async def demo_provider_comparison(): |
| 118 | """Compare responses from both providers.""" |
| 119 | print("\n" + "=" * 60) |
| 120 | print("DEMO: Provider Comparison") |
| 121 | print("=" * 60) |
| 122 | |
| 123 | # Load config |
| 124 | config_path = Path("mini_agent/config/config.yaml") |
| 125 | with open(config_path, encoding="utf-8") as f: |
| 126 | config = yaml.safe_load(f) |
| 127 | |
| 128 | # Create clients for both providers |
| 129 | anthropic_client = LLMClient( |
| 130 | api_key=config["api_key"], |
| 131 | provider=LLMProvider.ANTHROPIC, |
| 132 | model=config.get("model", "MiniMax-M2.5"), |
| 133 | ) |
| 134 | |
| 135 | openai_client = LLMClient( |
| 136 | api_key=config["api_key"], |
| 137 | provider=LLMProvider.OPENAI, |
| 138 | model=config.get("model", "MiniMax-M2.5"), |
| 139 | ) |
| 140 | |
| 141 | # Same question for both |
| 142 | messages = [Message(role="user", content="What is 2+2?")] |
| 143 | print(f"\n👤 Question: {messages[0].content}\n") |
| 144 | |
| 145 | try: |
| 146 | # Get response from Anthropic |
| 147 | anthropic_response = await anthropic_client.generate(messages) |
| 148 | print(f"🔵 Anthropic: {anthropic_response.content}") |
| 149 | |
| 150 | # Get response from OpenAI |
| 151 | openai_response = await openai_client.generate(messages) |
| 152 | print(f"🟢 OpenAI: {openai_response.content}") |
| 153 | |
| 154 | print("\n✅ Provider comparison completed") |
| 155 | except Exception as e: |
| 156 | print(f"❌ Error: {e}") |
| 157 | |
| 158 | |
| 159 | async def main(): |