> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/pfrankov/obsidian-local-gpt/llms.txt
> Use this file to discover all available pages before exploring further.

# Core Interfaces

> TypeScript interfaces for documents, references, and action palette

## Document Interfaces

### IAIDocument

Document interface from the AI Providers SDK for RAG operations.

```typescript src/interfaces.ts theme={null}
export type {
  IAIDocument,
  IAIProvidersRetrievalResult,
} from "@obsidian-ai-providers/sdk";
```

<Info>
  This interface is defined in the `@obsidian-ai-providers/sdk` package. It represents a document chunk used in retrieval-augmented generation (RAG).
</Info>

## Reference Interfaces

### FileReference

Represents a file in the vault for the action palette file picker.

```typescript src/interfaces.ts theme={null}
export interface FileReference {
  path: string;
  basename: string;
  extension: string;
}
```

<ParamField path="path" type="string" required>
  Full path to the file in the vault

  **Example:** `"folder/note.md"`
</ParamField>

<ParamField path="basename" type="string" required>
  File name without extension

  **Example:** `"note"`
</ParamField>

<ParamField path="extension" type="string" required>
  File extension

  **Example:** `"md"` or `"pdf"`
</ParamField>

### CommandReference

Represents an Obsidian command.

```typescript src/interfaces.ts theme={null}
export interface CommandReference {
  name: string;
  description: string;
}
```

<ParamField path="name" type="string" required>
  Command name/ID
</ParamField>

<ParamField path="description" type="string" required>
  Human-readable command description
</ParamField>

### ProviderReference

Represents an AI provider for selection in the action palette.

```typescript src/interfaces.ts theme={null}
export interface ProviderReference {
  id: string;
  name: string;
  providerName: string;
  providerUrl?: string;
}
```

<ParamField path="id" type="string" required>
  Unique provider ID
</ParamField>

<ParamField path="name" type="string" required>
  Model name or display name
</ParamField>

<ParamField path="providerName" type="string" required>
  Provider service name (e.g., "Ollama", "OpenAI")
</ParamField>

<ParamField path="providerUrl" type="string">
  Optional URL to the provider service
</ParamField>

### ModelReference

Represents a specific AI model.

```typescript src/interfaces.ts theme={null}
export interface ModelReference {
  id: string;
  name: string;
}
```

<ParamField path="id" type="string" required>
  Model ID used by the provider

  **Example:** `"llama3.2:latest"`
</ParamField>

<ParamField path="name" type="string" required>
  Display name for the model

  **Example:** `"Llama 3.2"`
</ParamField>

### CreativityReference

Represents a creativity level option.

```typescript src/interfaces.ts theme={null}
export interface CreativityReference {
  id: string; // "", "low", "medium", "high"
  name: string; // localized label from settings.creativity*
}
```

<ParamField path="id" type="string" required>
  Creativity level key

  **Values:** `""`, `"low"`, `"medium"`, `"high"`
</ParamField>

<ParamField path="name" type="string" required>
  Localized display name for the creativity level
</ParamField>

### SystemPromptReference

Represents a reusable system prompt from actions.

```typescript src/interfaces.ts theme={null}
export interface SystemPromptReference {
  name: string;
  system: string;
}
```

<ParamField path="name" type="string" required>
  Action name that provides this system prompt
</ParamField>

<ParamField path="system" type="string" required>
  The system prompt text
</ParamField>

## Token and Event Interfaces

### TextToken

Represents a parsed token from user input in the action palette.

```typescript src/interfaces.ts theme={null}
export interface TextToken {
  type: "text" | "file" | "command";
  content: string;
  start: number;
  end: number;
  filePath?: string;
  commandName?: string;
}
```

<ParamField path="type" type="'text' | 'file' | 'command'" required>
  Type of token parsed from input
</ParamField>

<ParamField path="content" type="string" required>
  Raw content of the token
</ParamField>

<ParamField path="start" type="number" required>
  Start position in the input string
</ParamField>

<ParamField path="end" type="number" required>
  End position in the input string
</ParamField>

<ParamField path="filePath" type="string">
  Resolved file path (when type is `"file"`)
</ParamField>

<ParamField path="commandName" type="string">
  Command name (when type is `"command"`)
</ParamField>

### ActionPaletteSubmitEvent

Event data when the action palette is submitted.

```typescript src/interfaces.ts theme={null}
export interface ActionPaletteSubmitEvent {
  text: string;
  selectedFiles: string[];
  systemPrompt?: string;
}
```

<ParamField path="text" type="string" required>
  User input text/prompt
</ParamField>

<ParamField path="selectedFiles" type="string[]" required>
  Array of file paths selected for context
</ParamField>

<ParamField path="systemPrompt" type="string">
  Optional system prompt selected from action templates
</ParamField>

## Callback Types

Function signatures for action palette callbacks.

```typescript src/interfaces.ts theme={null}
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.

```typescript theme={null}
type GetFilesCallback = () => FileReference[];
```

### GetProvidersCallback

Returns available AI providers.

```typescript theme={null}
type GetProvidersCallback = () => Promise<ProviderReference[]>;
```

### OnProviderChangeCallback

Called when user changes the selected provider.

```typescript theme={null}
type OnProviderChangeCallback = (providerId: string) => Promise<void>;
```

### GetModelsCallback

Returns available models for a given provider.

```typescript theme={null}
type GetModelsCallback = (
  providerId: string,
) => Promise<ModelReference[]>;
```

### OnModelChangeCallback

Called when user changes the selected model.

```typescript theme={null}
type OnModelChangeCallback = (model: string) => Promise<void>;
```

### OnCreativityChangeCallback

Called when user changes the creativity level.

```typescript theme={null}
type OnCreativityChangeCallback = (
  creativityKey: string,
) => Promise<void> | void;
```

### GetSystemPromptsCallback

Returns available system prompts from actions.

```typescript theme={null}
type GetSystemPromptsCallback = () => SystemPromptReference[];
```

## Usage Example

These interfaces are used throughout the action palette implementation in `src/main.ts:240-322`:

```typescript theme={null}
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: () => { /* ... */ },
});
```

<Tip>
  These interfaces enable extensibility and type safety throughout the plugin. Use them when extending Local GPT with custom features or integrations.
</Tip>
