AI Features
Sitepins integrates advanced AI capabilities to assist developers and content creators. The system is provider-agnostic, supporting multiple LLM backends.
Supported Providers
Providers are configured in src/lib/constant.ts and can be switched dynamically:
- OpenAI: GPT-4o, GPT-3.5-Turbo
- Google Gemini: Gemini 1.5 Pro, Gemini 1.5 Flash
- Anthropic: Claude 3.5 Sonnet, Claude 3 Opus
- xAI: Grok-1
AI Command System
The core AI interaction logic is handled by the useAiCommand hook, which leverages the @ai-sdk/react and Plateβs AI plugins.
useAiCommand Hook
This hook manages the streaming chat state for the editorβs AI commands (Edit, Generate, Comment).
// src/hooks/use-ai-command.ts
export const useAiCommand = () => {
const baseChat = useBaseChat({
id: "editor",
api: "/api/ai/command",
// ...
});
// ...
};AI Features in the Editor
- Content Inline Editing: Select text and use AI to rewrite, shorten, or expand it.
- Post Generation: Generate entire sections of content based on a prompt.
- SEO Optimization: Automatically generate meta titles and descriptions.
- Code Assistance: In the Monaco editor, AI can help with Tailwind classes or configuration schemas.
AI Upsell Logic
Access to AI features is gated by the userβs subscription level. The useAiUpsellDialog hook manages the visibility of the upgrade prompt when a user reaches their AI usage limit.
Last updated on