AI Prompts
Getting Started with AI
Section titled “Getting Started with AI”Plasma integrates AI capabilities to accelerate development and improve code quality through intelligent assistance.
Setup Process
Section titled “Setup Process”1. Setup AI Configuration
Section titled “1. Setup AI Configuration”First, configure your AI settings in the Plasma configuration file:
export default {ai: { provider: 'openai', model: 'gpt-4', apiKey: process.env.OPENAI_API_KEY,},};2. Create Your First Prompt
Section titled “2. Create Your First Prompt”Use the AI prompt system to generate code or get suggestions:
import { ai } from 'plasma';
const result = await ai.prompt('Generate a React component for user profile');3. Customize Prompts
Section titled “3. Customize Prompts”Enhance your prompts with context and examples for better results.
Prompt Types
Section titled “Prompt Types”Code Generation
Section titled “Code Generation”Generate code components, functions, and entire modules using AI.
// Generate a complete React componentconst component = await ai.generateComponent({name: 'UserDashboard',props: ['user', 'onUpdate'],features: ['responsive', 'accessible'],});Documentation
Section titled “Documentation”Automatically generate documentation for your code.
// Generate docs for existing functionsconst docs = await ai.generateDocs(functionCode);Testing
Section titled “Testing”Create comprehensive test suites for your components.
// Generate testsconst tests = await ai.generateTests(componentCode);File Structure
Section titled “File Structure”Here’s how AI-generated files are organized in your project:
src/├── ai-generated/│ ├── components.ts│ ├── utils.ts│ └── types.ts├── prompts/│ ├── templates.ts│ └── custom.tsai.config.jsAdvanced Configuration
Section titled “Advanced Configuration”Custom Models
Section titled “Custom Models”Configure custom AI models for specific use cases:
const customModel = {name: 'code-specialist',baseModel: 'gpt-4',systemPrompt: 'You are a senior React developer...',temperature: 0.1,};Prompt Templates
Section titled “Prompt Templates”Create reusable prompt templates:
const templates = {component: 'Generate a React component that {description}',test: 'Create comprehensive tests for {componentName}',docs: 'Write documentation for {functionName}',};Context Integration
Section titled “Context Integration”Integrate project context for better AI responses:
const context = {framework: 'React',typescript: true,styleGuide: 'Material-UI',testFramework: 'Jest',};API Reference
Section titled “API Reference”| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| prompt | string | ✅ | - | The AI prompt string |
| context | object | ❌ | - | Additional context for the AI |
| model | ”gpt-4” | “gpt-3.5-turbo” | “claude” | ❌ | “gpt-4” | AI model to use |
Best Practices
Section titled “Best Practices”Pro Tip: Always provide specific context and examples in your prompts for better AI responses.
- Be specific about the desired output format
- Include relevant project context
- Test prompts with different inputs
- Review and refine AI-generated code