0.0.1 • Published 9 months ago

@pradheep_varatharajan/play-ai v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

play-ai

A powerful AI-driven automation library built on top of Playwright, enabling natural language-based browser automation.

Installation

npm install play-ai
# or
yarn add play-ai

Prerequisites

  • Node.js >= 16
  • OpenAI API key (set as OPENAI_API_KEY in your environment variables)

Usage

import { play } from 'play-ai';

async function example() {
  // Initialize the browser automation
  await play('Navigate to google.com and search for "playwright automation"');
  
  // You can chain multiple commands
  await play('Click on the first search result');
  
  // Complex interactions are also supported
  await play('Fill out the contact form with my email test@example.com');
}

Features

  • Natural language commands for browser automation
  • Built on top of Playwright for reliable browser automation
  • OpenAI integration for intelligent command interpretation
  • TypeScript support out of the box
  • Extensive error handling and reporting

Environment Variables

Create a .env file in your project root:

OPENAI_API_KEY=your_api_key_here

Error Handling

The package exports PlayAIError for specific error handling:

import { play, PlayAIError } from 'play-ai';

try {
  await play('Navigate to a non-existent website');
} catch (error) {
  if (error instanceof PlayAIError) {
    console.error('AI automation error:', error.message);
  }
}

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see the LICENSE file for details