Skip to main content

Document Interfaces

IAIDocument

Document interface from the AI Providers SDK for RAG operations.
src/interfaces.ts
export type {
  IAIDocument,
  IAIProvidersRetrievalResult,
} from "@obsidian-ai-providers/sdk";
This interface is defined in the @obsidian-ai-providers/sdk package. It represents a document chunk used in retrieval-augmented generation (RAG).

Reference Interfaces

FileReference

Represents a file in the vault for the action palette file picker.
src/interfaces.ts
export interface FileReference {
  path: string;
  basename: string;
  extension: string;
}
path
string
required
Full path to the file in the vaultExample: "folder/note.md"
basename
string
required
File name without extensionExample: "note"
extension
string
required
File extensionExample: "md" or "pdf"

CommandReference

Represents an Obsidian command.
src/interfaces.ts
export interface CommandReference {
  name: string;
  description: string;
}
name
string
required
Command name/ID
description
string
required
Human-readable command description

ProviderReference

Represents an AI provider for selection in the action palette.
src/interfaces.ts
export interface ProviderReference {
  id: string;
  name: string;
  providerName: string;
  providerUrl?: string;
}
id
string
required
Unique provider ID
name
string
required
Model name or display name
providerName
string
required
Provider service name (e.g., “Ollama”, “OpenAI”)
providerUrl
string
Optional URL to the provider service

ModelReference

Represents a specific AI model.
src/interfaces.ts
export interface ModelReference {
  id: string;
  name: string;
}
id
string
required
Model ID used by the providerExample: "llama3.2:latest"
name
string
required
Display name for the modelExample: "Llama 3.2"

CreativityReference

Represents a creativity level option.
src/interfaces.ts
export interface CreativityReference {
  id: string; // "", "low", "medium", "high"
  name: string; // localized label from settings.creativity*
}
id
string
required
Creativity level keyValues: "", "low", "medium", "high"
name
string
required
Localized display name for the creativity level

SystemPromptReference

Represents a reusable system prompt from actions.
src/interfaces.ts
export interface SystemPromptReference {
  name: string;
  system: string;
}
name
string
required
Action name that provides this system prompt
system
string
required
The system prompt text

Token and Event Interfaces

TextToken

Represents a parsed token from user input in the action palette.
src/interfaces.ts
export interface TextToken {
  type: "text" | "file" | "command";
  content: string;
  start: number;
  end: number;
  filePath?: string;
  commandName?: string;
}
type
'text' | 'file' | 'command'
required
Type of token parsed from input
content
string
required
Raw content of the token
start
number
required
Start position in the input string
end
number
required
End position in the input string
filePath
string
Resolved file path (when type is "file")
commandName
string
Command name (when type is "command")

ActionPaletteSubmitEvent

Event data when the action palette is submitted.
src/interfaces.ts
export interface ActionPaletteSubmitEvent {
  text: string;
  selectedFiles: string[];
  systemPrompt?: string;
}
text
string
required
User input text/prompt
selectedFiles
string[]
required
Array of file paths selected for context
systemPrompt
string
Optional system prompt selected from action templates

Callback Types

Function signatures for action palette callbacks.
src/interfaces.ts
export type GetFilesCallback = () => FileReference[];
export type GetProvidersCallback = () => Promise<ProviderReference[]>;
export type OnProviderChangeCallback = (providerId: string) => Promise<void>;
export type GetModelsCallback = (
  providerId: string,
) => Promise<ModelReference[]>;
export type OnModelChangeCallback = (model: string) => Promise<void>;
export type OnCreativityChangeCallback = (
  creativityKey: string,
) => Promise<void> | void;
export type GetSystemPromptsCallback = () => SystemPromptReference[];

GetFilesCallback

Returns available files for selection.
type GetFilesCallback = () => FileReference[];

GetProvidersCallback

Returns available AI providers.
type GetProvidersCallback = () => Promise<ProviderReference[]>;

OnProviderChangeCallback

Called when user changes the selected provider.
type OnProviderChangeCallback = (providerId: string) => Promise<void>;

GetModelsCallback

Returns available models for a given provider.
type GetModelsCallback = (
  providerId: string,
) => Promise<ModelReference[]>;

OnModelChangeCallback

Called when user changes the selected model.
type OnModelChangeCallback = (model: string) => Promise<void>;

OnCreativityChangeCallback

Called when user changes the creativity level.
type OnCreativityChangeCallback = (
  creativityKey: string,
) => Promise<void> | void;

GetSystemPromptsCallback

Returns available system prompts from actions.
type GetSystemPromptsCallback = () => SystemPromptReference[];

Usage Example

These interfaces are used throughout the action palette implementation in src/main.ts:240-322:
showActionPalette(editorView, insertPos, {
  onSubmit: (text, selectedFiles, systemPrompt) => { /* ... */ },
  onCancel: () => { /* ... */ },
  placeholder: I18n.t("commands.actionPalette.placeholder"),
  modelLabel: modelLabel,
  providerId: currentProviderId,
  getFiles: () => {
    return this.app.vault
      .getMarkdownFiles()
      .concat(
        this.app.vault
          .getFiles()
          .filter((f) => f.extension === "pdf"),
      )
      .map((file) => ({
        path: file.path,
        basename: file.basename,
        extension: file.extension,
      }));
  },
  getProviders: async () => { /* ... */ },
  getModels: async (providerId) => { /* ... */ },
  onProviderChange: async (providerId) => { /* ... */ },
  onModelChange: async (model) => { /* ... */ },
  onCreativityChange: async (creativityKey) => { /* ... */ },
  getSystemPrompts: () => { /* ... */ },
});
These interfaces enable extensibility and type safety throughout the plugin. Use them when extending Local GPT with custom features or integrations.

Build docs developers (and LLMs) love