Demo: Interactive conversation with agent.
()
| 184 | |
| 185 | |
| 186 | async def demo_interactive_mode(): |
| 187 | """Demo: Interactive conversation with agent.""" |
| 188 | print("\n" + "=" * 60) |
| 189 | print("Interactive Mini Agent") |
| 190 | print("=" * 60) |
| 191 | print("\nThis demo shows multi-turn conversation.") |
| 192 | print("(In production, use `mini-agent` for full interactive mode)") |
| 193 | |
| 194 | # Load config |
| 195 | config_path = Path("mini_agent/config/config.yaml") |
| 196 | if not config_path.exists(): |
| 197 | print("❌ config.yaml not found") |
| 198 | return |
| 199 | |
| 200 | config = Config.from_yaml(config_path) |
| 201 | |
| 202 | if not config.llm.api_key or config.llm.api_key.startswith("YOUR_"): |
| 203 | print("❌ API key not configured") |
| 204 | return |
| 205 | |
| 206 | with tempfile.TemporaryDirectory() as workspace_dir: |
| 207 | # Setup |
| 208 | system_prompt = "You are a helpful assistant with access to tools." |
| 209 | llm_client = LLMClient( |
| 210 | api_key=config.llm.api_key, |
| 211 | api_base=config.llm.api_base, |
| 212 | model=config.llm.model, |
| 213 | ) |
| 214 | |
| 215 | tools = [ |
| 216 | WriteTool(workspace_dir=workspace_dir), |
| 217 | ReadTool(workspace_dir=workspace_dir), |
| 218 | BashTool(), |
| 219 | ] |
| 220 | |
| 221 | agent = Agent( |
| 222 | llm_client=llm_client, |
| 223 | system_prompt=system_prompt, |
| 224 | tools=tools, |
| 225 | max_steps=20, |
| 226 | workspace_dir=workspace_dir, |
| 227 | ) |
| 228 | |
| 229 | # Conversation turns |
| 230 | conversations = [ |
| 231 | "Create a file called 'data.txt' with the numbers 1 to 5, one per line.", |
| 232 | "Now read the file and tell me what's in it.", |
| 233 | "Count how many lines are in the file using bash.", |
| 234 | ] |
| 235 | |
| 236 | for i, message in enumerate(conversations, 1): |
| 237 | print(f"\n{'=' * 60}") |
| 238 | print(f"Turn {i}:") |
| 239 | print(f"{'=' * 60}") |
| 240 | print(f"User: {message}\n") |
| 241 | |
| 242 | agent.add_user_message(message) |
| 243 |