Demo using LLMClient with OpenAI provider.
()
| 48 | |
| 49 | |
| 50 | async def demo_openai_provider(): |
| 51 | """Demo using LLMClient with OpenAI provider.""" |
| 52 | print("\n" + "=" * 60) |
| 53 | print("DEMO: LLMClient with OpenAI Provider") |
| 54 | print("=" * 60) |
| 55 | |
| 56 | # Load config |
| 57 | config_path = Path("mini_agent/config/config.yaml") |
| 58 | with open(config_path, encoding="utf-8") as f: |
| 59 | config = yaml.safe_load(f) |
| 60 | |
| 61 | # Initialize client with OpenAI provider |
| 62 | client = LLMClient( |
| 63 | api_key=config["api_key"], |
| 64 | provider=LLMProvider.OPENAI, # Specify OpenAI provider |
| 65 | model=config.get("model", "MiniMax-M2.5"), |
| 66 | ) |
| 67 | |
| 68 | print(f"Provider: {client.provider}") |
| 69 | print(f"API Base: {client.api_base}") |
| 70 | |
| 71 | # Simple question |
| 72 | messages = [Message(role="user", content="Say 'Hello from OpenAI!'")] |
| 73 | print(f"\n👤 User: {messages[0].content}") |
| 74 | |
| 75 | try: |
| 76 | response = await client.generate(messages) |
| 77 | if response.thinking: |
| 78 | print(f"💭 Thinking: {response.thinking}") |
| 79 | print(f"💬 Model: {response.content}") |
| 80 | print("✅ OpenAI provider demo completed") |
| 81 | except Exception as e: |
| 82 | print(f"❌ Error: {e}") |
| 83 | |
| 84 | |
| 85 | async def demo_default_provider(): |