diff --git a/README.md b/README.md index a6d4f1c..7bb43bc 100644 --- a/README.md +++ b/README.md @@ -3,16 +3,329 @@ wp-cli/ai-command Interacts with the WordPress AI Client -[![Build Status](https://travis-ci.org/wp-cli/ai-command.svg?branch=master)](https://travis-ci.org/wp-cli/ai-command) +[![Testing](https://github.com/wp-cli/ai-command/actions/workflows/testing.yml/badge.svg)](https://github.com/wp-cli/ai-command/actions/workflows/testing.yml) Quick links: [Using](#using) | [Installing](#installing) | [Contributing](#contributing) | [Support](#support) ## Using +This package implements the following commands: + +### wp ai + +Interacts with the WordPress AI Client for text and image generation. + +~~~ +wp ai +~~~ + +**EXAMPLES** + + # Check AI capabilities status + $ wp ai status + +------------------+-----------+ + | Capability | Supported | + +------------------+-----------+ + | Text Generation | Yes | + | Image Generation | No | + +------------------+-----------+ + + # Generate text from a prompt + $ wp ai generate text "Write a haiku about WordPress" + Success: Generated text: + Open source and free + Empowering creators + WordPress shines bright + + # Generate an image from a prompt + $ wp ai generate image "A futuristic WordPress logo" --destination-file=logo.png + Success: Image saved to logo.png + + # Check if a prompt is supported + $ wp ai check "Summarize this text" + Success: Text generation is supported for this prompt. + + + +### wp ai credentials + +Manages AI provider credentials. + +~~~ +wp ai credentials +~~~ + +**EXAMPLES** + + # List all stored AI provider credentials + $ wp ai credentials list + + # Get credentials for a specific provider + $ wp ai credentials get openai + + # Set credentials for a provider + $ wp ai credentials set openai --api-key=sk-... + + # Delete credentials for a provider + $ wp ai credentials delete openai + + + + + +### wp ai credentials get + +Gets credentials for a specific AI provider. + +~~~ +wp ai credentials get [--format=] +~~~ + +**OPTIONS** + + + The AI provider name (e.g., openai, anthropic, google). + + [--format=] + Render output in a particular format. + --- + default: json + options: + - json + - yaml + --- + +**EXAMPLES** + + # Get OpenAI credentials + $ wp ai credentials get openai + {"provider":"openai","api_key":"sk-*****"} + + + +### wp ai credentials set + +Sets or updates credentials for an AI provider. + +~~~ +wp ai credentials set --api-key= +~~~ + +**OPTIONS** + + + The AI provider name (e.g., openai, anthropic, google). + + --api-key= + The API key for the provider. + +**EXAMPLES** + + # Set OpenAI credentials + $ wp ai credentials set openai --api-key=sk-... + Success: Credentials for provider "openai" have been saved. + + + +### wp ai credentials delete + +Deletes credentials for an AI provider. + +~~~ +wp ai credentials delete +~~~ + +**OPTIONS** + + + The AI provider name (e.g., openai, anthropic, google). + +**EXAMPLES** + + # Delete OpenAI credentials + $ wp ai credentials delete openai + Success: Credentials for provider "openai" have been deleted. + + + +### wp ai credentials list + +Lists all stored AI provider credentials. + +~~~ +wp ai credentials list [--format=] +~~~ + +**OPTIONS** + + [--format=] + Render output in a particular format. + --- + default: table + options: + - table + - csv + - json + - yaml + --- + +**EXAMPLES** + + # List all credentials + $ wp ai credentials list + +----------+----------+ + | provider | api_key | + +----------+----------+ + | openai | sk-***** | + +----------+----------+ + + + +### wp ai check + +Checks if a prompt is supported for generation. + +~~~ +wp ai check [--type=] +~~~ + +**OPTIONS** + + + The prompt to check. + + [--type=] + Type to check. + --- + options: + - text + - image + --- + +**EXAMPLES** + + # Check if text generation is supported + $ wp ai check "Write a poem" + + # Check if image generation is supported + $ wp ai check "A sunset" --type=image + + + +### wp ai generate + +Generates AI content. + +~~~ +wp ai generate [--model=] [--provider=] [--temperature=] [--top-p=] [--top-k=] [--max-tokens=] [--system-instruction=] [--destination-file=] [--format=] +~~~ + +**OPTIONS** + + + Type of content to generate. + --- + options: + - text + - image + --- + + + The prompt to send to the AI. + + [--model=] + Comma-separated list of models in order of preference. Format: "provider,model" (e.g., "openai,gpt-4" or "openai,gpt-4,anthropic,claude-3"). + + [--provider=] + Specific AI provider to use (e.g., "openai", "anthropic", "google"). + + [--temperature=] + Temperature for generation, typically between 0.0 and 1.0. Lower is more deterministic. + + [--top-p=] + Top-p (nucleus sampling) parameter. Value between 0.0 and 1.0. + + [--top-k=] + Top-k sampling parameter. Positive integer. + + [--max-tokens=] + Maximum number of tokens to generate. + + [--system-instruction=] + System instruction to guide the AI's behavior. + + [--destination-file=] + For image generation, path to save the generated image. + +[--stdout] +Output the whole image using standard output (incompatible with --destination-file=) + + [--format=] + Output format for text. + --- + default: text + options: + - text + - json + --- + +**EXAMPLES** + + # Generate text + $ wp ai generate text "Explain WordPress in one sentence" + + # Generate text with specific settings + $ wp ai generate text "List 3 WordPress features" --temperature=0.1 --max-tokens=100 + + # Generate with top-p and top-k sampling + $ wp ai generate text "Write a story" --top-p=0.9 --top-k=40 + + # Generate with model preferences + $ wp ai generate text "Write a haiku" --model=openai,gpt-4,anthropic,claude-3 + + # Generate with system instruction + $ wp ai generate text "Explain AI" --system-instruction="Explain as if to a 5-year-old" + + # Generate image + $ wp ai generate image "A minimalist WordPress logo" --output=wp-logo.png + + + +### wp ai status + +Checks which AI capabilities are currently supported. + ~~~ -wp hello-world +wp ai status [--format=] ~~~ +Checks the environment and credentials to determine which AI operations +are available. Displays a table showing supported capabilities. + +**OPTIONS** + + [--format=] + Render output in a particular format. + --- + default: table + options: + - table + - csv + - json + - yaml + --- + +**EXAMPLES** + + # Check AI status + $ wp ai status + +------------------+-----------+ + | Capability | Supported | + +------------------+-----------+ + | Text Generation | Yes | + | Image Generation | No | + +------------------+-----------+ + ## Installing Installing this package requires WP-CLI v2.12 or greater. Update to the latest stable release with `wp cli update`. @@ -26,7 +339,7 @@ wp package install wp-cli/ai-command:@stable To install the latest development version of this package, use the following command instead: ```bash -wp package install wp-cli/ai-command:dev-master +wp package install wp-cli/ai-command:dev-main ``` ## Contributing