Externalize AI into its own module