Skip to main content

LocalGPTAction

Defines a custom AI action that can be triggered from the editor.
src/interfaces.ts
export interface LocalGPTAction {
  name: string;
  prompt: string;
  temperature?: number;
  system?: string;
  replace?: boolean;
  separator?: boolean;
  community?: CommunityActionRef;
}

Properties

name
string
required
Display name of the action shown in menus and command paletteExample: "🪄 General help" or "✍️ Continue writing"
prompt
string
required
The user prompt sent to the AI model. Can be empty for freeform actions.Special keywords:
  • {{=SELECTION=}} - Replaced with selected text
  • {{=CONTEXT=}} - Replaced with context from linked files
  • {{=CONTEXT_START=}} / {{=CONTEXT_END=}} - Conditional context blocks
Example:
"Make a concise summary of the key points of the following text."
temperature
number
Override temperature for this action. If not specified, uses the default creativity setting.Range: 0.0 to 1.0
  • 0.0 - Deterministic, focused
  • 1.0 - Creative, varied
system
string
System prompt that defines the AI’s behavior and roleExample:
"You are an AI assistant that follows instruction extremely well. Help as much as you can."
replace
boolean
default:"false"
If true, replaces the selected text with the AI output instead of appending belowUse case: Grammar correction, text transformation
separator
boolean
default:"false"
If true, adds a visual separator in action menus
community
CommunityActionRef
Metadata for community-shared actions. See CommunityActionRef.

CommunityActionRef

Metadata for actions imported from the community repository.
src/interfaces.ts
export interface CommunityActionRef {
  id: string;
  language: string;
  name: string;
  hash: string;
  updatedAt?: string;
  description?: string;
}

Properties

id
string
required
Unique identifier for the community action
language
string
required
Language code (e.g., "en", "es", "fr")
name
string
required
Display name of the community action
hash
string
required
Content hash for version tracking and updates
updatedAt
string
ISO timestamp of last update
description
string
Description of what the action does

Action Examples

Basic Action

Simple summarization action:
{
  name: "🍭 Summarize",
  prompt: "Make a concise summary of the key points of the following text.",
  system: "You are an AI assistant that follows instruction extremely well. Help as much as you can."
}

Replace Action

Grammar correction that replaces selected text:
{
  name: "📖 Fix spelling and grammar",
  prompt: "Proofread the below for spelling and grammar.",
  system: "You are an AI assistant that follows instruction extremely well. Help as much as you can.",
  replace: true
}

Freeform Action

General help action with empty prompt (user provides prompt at runtime):
{
  name: "🪄 General help",
  prompt: "",
  system: "You are an assistant helping a user write more content in a document based on a prompt. Output in markdown format. Do not use links. Do not include literal content from the original document."
}

High Creativity Action

Creative writing with custom temperature:
{
  name: "✨ Creative expansion",
  prompt: "Expand on this idea with creative details and examples.",
  system: "You are a creative writer with a vivid imagination.",
  temperature: 0.9
}

Community Action

Action imported from community repository:
{
  name: "📊 Data Analysis",
  prompt: "Analyze the following data and provide insights.",
  system: "You are a data analyst expert.",
  community: {
    id: "data-analysis-v1",
    language: "en",
    name: "Data Analysis",
    hash: "abc123def456",
    updatedAt: "2026-03-01T00:00:00Z",
    description: "Analyzes data and provides insights"
  }
}

Usage in Code

Actions are executed in src/main.ts:349:
async runAction(action: LocalGPTAction, editor: Editor) {
  return this.executeAction(
    {
      prompt: action.prompt,
      system: action.system,
      replace: !!action.replace,
      temperature:
        action.temperature ||
        CREATIVITY[this.settings.defaults.creativity].temperature,
    },
    editor,
  );
}
Actions can use context from linked files automatically. The RAG system processes [[wikilinks]] in the selection and includes relevant content based on the context limit setting.

Build docs developers (and LLMs) love