⚠️ This plugin requires AI Providers plugin to be installed.
184 |Please install and configure AI Providers plugin first.
185 | `)); 186 | } 187 | } 188 | 189 | export type { 190 | ObsidianEvents, 191 | IAIProvider, 192 | IChunkHandler, 193 | IAIProvidersService, 194 | IAIProvidersExecuteParams, 195 | IAIProvidersEmbedParams, 196 | IAIHandler, 197 | IAIProvidersPluginSettings, 198 | AIProviderType 199 | } from './types'; -------------------------------------------------------------------------------- /packages/sdk/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@obsidian-ai-providers/sdk", 3 | "version": "1.1.1", 4 | "private": false, 5 | "scripts": { 6 | "build": "tsc -p tsconfig.json && node esbuild.config.mjs production", 7 | "dev": "node esbuild.config.mjs" 8 | }, 9 | "description": "SDK for integrating with AI Providers plugin", 10 | "homepage": "https://github.com/pfrankov/obsidian-ai-providers", 11 | "main": "dist/index.js", 12 | "types": "dist/index.d.ts", 13 | "exports": { 14 | ".": { 15 | "types": "./dist/index.d.ts", 16 | "default": "./dist/index.js" 17 | }, 18 | "./styles.css": "./dist/styles.css" 19 | }, 20 | "files": [ 21 | "dist", 22 | "README.md", 23 | "LICENSE" 24 | ], 25 | "keywords": [ 26 | "obsidian", 27 | "ai", 28 | "sdk", 29 | "plugin", 30 | "llm", 31 | "gpt", 32 | "openai", 33 | "providers" 34 | ], 35 | "author": "Pavel Frankov", 36 | "license": "MIT", 37 | "repository": { 38 | "type": "git", 39 | "url": "git+https://github.com/pfrankov/obsidian-ai-providers.git" 40 | }, 41 | "bugs": { 42 | "url": "https://github.com/pfrankov/obsidian-ai-providers/issues" 43 | }, 44 | "peerDependencies": { 45 | "obsidian": "latest" 46 | }, 47 | "devDependencies": { 48 | "esbuild": "0.17.3", 49 | "typescript": "4.7.4", 50 | "tslib": "2.4.0" 51 | }, 52 | "publishConfig": { 53 | "access": "public" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /packages/sdk/styles.css: -------------------------------------------------------------------------------- 1 | /* ============================================ 2 | AI Providers missing notice 3 | ============================================ */ 4 | .ai-providers-notice { 5 | margin: 0 -1em 1em; 6 | padding: 1em; 7 | border: 1px solid var(--background-modifier-border); 8 | border-radius: var(--radius-m); 9 | background-color: var(--background-secondary); 10 | color: var(--text-muted); 11 | font-size: var(--font-small); 12 | line-height: var(--line-height-tight); 13 | } 14 | 15 | .ai-providers-notice p { 16 | margin: 0; 17 | margin-bottom: 0.5em; 18 | } 19 | 20 | .ai-providers-notice p:last-child { 21 | margin-bottom: 0; 22 | } 23 | 24 | /* ============================================ 25 | AI Providers Dropdown Styles 26 | Prevents width overflow and maintains layout 27 | ============================================ */ 28 | .ai-providers-select > .setting-item-info { 29 | flex-grow: 1; 30 | flex-shrink: 1; 31 | } 32 | .ai-providers-select > .setting-item-control { 33 | flex-grow: 0; 34 | flex-shrink: 1; 35 | flex-basis: 50%; 36 | max-width: 50%; 37 | } 38 | 39 | .ai-providers-select > .setting-item-control .dropdown { 40 | max-width: 100%; 41 | } -------------------------------------------------------------------------------- /packages/sdk/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "inlineSourceMap": true, 5 | "inlineSources": true, 6 | "module": "ESNext", 7 | "target": "ES6", 8 | "allowJs": true, 9 | "noImplicitAny": true, 10 | "moduleResolution": "node", 11 | "importHelpers": true, 12 | "isolatedModules": true, 13 | "strictNullChecks": true, 14 | "declaration": true, 15 | "outDir": "./dist", 16 | "lib": [ 17 | "DOM", 18 | "ES5", 19 | "ES6", 20 | "ES7" 21 | ], 22 | "skipLibCheck": true 23 | }, 24 | "include": [ 25 | "**/*.ts" 26 | ] 27 | } -------------------------------------------------------------------------------- /packages/sdk/types.d.ts: -------------------------------------------------------------------------------- 1 | import { App, Plugin, EventRef } from "obsidian"; 2 | 3 | export type ObsidianEvents = { 4 | 'ai-providers-ready': () => void; 5 | }; 6 | 7 | export type AIProviderType = 'openai' | 'ollama' | 'gemini' | 'openrouter' | 'lmstudio'; 8 | export interface IAIProvider { 9 | id: string; 10 | name: string; 11 | apiKey?: string; 12 | url?: string; 13 | type: AIProviderType; 14 | model?: string; 15 | availableModels?: string[]; 16 | } 17 | 18 | export interface IChunkHandler { 19 | onData(callback: (chunk: string, accumulatedText: string) => void): void; 20 | onEnd(callback: (fullText: string) => void): void; 21 | onError(callback: (error: Error) => void): void; 22 | abort(): void; 23 | } 24 | 25 | export interface IAIProvidersService { 26 | version: number; 27 | providers: IAIProvider[]; 28 | fetchModels: (provider: IAIProvider) => Promise