ai-replace-prompt
v1770195.248.27
Published
Professional integration for https://supermaker.ai/blog/best-ai-replace-prompts-to-transform-your-photos-instantly/
Maintainers
Readme
ai-replace-prompt
A lightweight JavaScript library for generating optimized AI replacement prompts based on user input. This utility helps streamline the creation of effective prompts for image editing and transformation tasks.
Installation
bash npm install ai-replace-prompt
Usage Examples
Here are several examples demonstrating how to use ai-replace-prompt in your JavaScript or Node.js projects:
Example 1: Basic Replacement javascript const { generatePrompt } = require('ai-replace-prompt');
const targetObject = "the sky"; const replacementObject = "a starry night";
const prompt = generatePrompt(targetObject, replacementObject); console.log(prompt); // Output: Replace the sky with a starry night.
Example 2: Adding Contextual Details javascript const { generatePrompt } = require('ai-replace-prompt');
const targetObject = "the car"; const replacementObject = "a futuristic hovercraft"; const context = "in a cyberpunk city";
const prompt = generatePrompt(targetObject, replacementObject, context); console.log(prompt); // Output: Replace the car with a futuristic hovercraft in a cyberpunk city.
Example 3: Specifying a Style javascript const { generatePrompt } = require('ai-replace-prompt');
const targetObject = "the portrait"; const replacementObject = "a painting in the style of Van Gogh";
const prompt = generatePrompt(targetObject, replacementObject); console.log(prompt); // Output: Replace the portrait with a painting in the style of Van Gogh.
Example 4: Using Advanced Options javascript const { generatePrompt } = require('ai-replace-prompt');
const targetObject = "the coffee cup"; const replacementObject = "a steaming mug of hot chocolate"; const context = "on a snowy windowsill"; const options = { strength: "high", detailLevel: "intricate" };
const prompt = generatePrompt(targetObject, replacementObject, context, options); console.log(prompt); // Output: Replace the coffee cup with a steaming mug of hot chocolate on a snowy windowsill. Strength: high, Detail Level: intricate.
Example 5: Handling Empty Context javascript const { generatePrompt } = require('ai-replace-prompt');
const targetObject = "the wall"; const replacementObject = "a mural"; const context = ""; // Empty context
const prompt = generatePrompt(targetObject, replacementObject, context); console.log(prompt); // Output: Replace the wall with a mural.
API Summary
generatePrompt(targetObject, replacementObject, context = "", options = {})
Generates an optimized AI replacement prompt string.
Parameters:
targetObject(string): The object to be replaced in the image.replacementObject(string): The object that will replace the target object.context(string, optional): Additional contextual information to refine the replacement. Defaults to "".options(object, optional): An object containing additional options to control the prompt generation. Supported options includestrength(string, e.g., "high", "medium", "low") anddetailLevel(string, e.g., "intricate", "simple"). Defaults to{}.
Returns:
string: The generated AI replacement prompt.
License
MIT
This package is part of the ai-replace-prompt ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/blog/best-ai-replace-prompts-to-transform-your-photos-instantly/
