Demo using LLMClient with Anthropic provider.
()
| 13 | |
| 14 | |
| 15 | async def demo_anthropic_provider(): |
| 16 | """Demo using LLMClient with Anthropic provider.""" |
| 17 | print("\n" + "=" * 60) |
| 18 | print("DEMO: LLMClient with Anthropic Provider") |
| 19 | print("=" * 60) |
| 20 | |
| 21 | # Load config |
| 22 | config_path = Path("mini_agent/config/config.yaml") |
| 23 | with open(config_path, encoding="utf-8") as f: |
| 24 | config = yaml.safe_load(f) |
| 25 | |
| 26 | # Initialize client with Anthropic provider |
| 27 | client = LLMClient( |
| 28 | api_key=config["api_key"], |
| 29 | provider=LLMProvider.ANTHROPIC, # Specify Anthropic provider |
| 30 | model=config.get("model", "MiniMax-M2.5"), |
| 31 | ) |
| 32 | |
| 33 | print(f"Provider: {client.provider}") |
| 34 | print(f"API Base: {client.api_base}") |
| 35 | |
| 36 | # Simple question |
| 37 | messages = [Message(role="user", content="Say 'Hello from Anthropic!'")] |
| 38 | print(f"\n👤 User: {messages[0].content}") |
| 39 | |
| 40 | try: |
| 41 | response = await client.generate(messages) |
| 42 | if response.thinking: |
| 43 | print(f"💭 Thinking: {response.thinking}") |
| 44 | print(f"💬 Model: {response.content}") |
| 45 | print("✅ Anthropic provider demo completed") |
| 46 | except Exception as e: |
| 47 | print(f"❌ Error: {e}") |
| 48 | |
| 49 | |
| 50 | async def demo_openai_provider(): |