|
| 1 | +import QtQml 2.0 |
| 2 | +import QOwnNotesTypes 1.0 |
| 3 | + |
| 4 | +/** |
| 5 | + * This script adds GitHub Models to QOwnNotes, allowing you to use AI models |
| 6 | + * via your GitHub Copilot subscription through the GitHub Models inference API. |
| 7 | + * |
| 8 | + * Setup: |
| 9 | + * 1. Install this script in QOwnNotes (Settings > Scripting) |
| 10 | + * 2. Go to the script settings and enter your GitHub Personal Access Token |
| 11 | + * (create one at https://github.com/settings/tokens — fine-grained |
| 12 | + * with "Models: Read" permission, or a classic token) |
| 13 | + * 3. Once the script is active, you can choose the "GitHub" backend and |
| 14 | + * your preferred model |
| 15 | + * |
| 16 | + */ |
| 17 | +Script { |
| 18 | + property string githubToken; |
| 19 | + |
| 20 | + property variant settingsVariables: [ |
| 21 | + { |
| 22 | + "identifier": "githubToken", |
| 23 | + "name": "GitHub Personal Access Token", |
| 24 | + "description": "Enter your GitHub PAT (create at https://github.com/settings/tokens).\nFine-grained: enable 'Models: Read' permission.\nClassic: the 'models' scope is needed.", |
| 25 | + "type": "string-secret", |
| 26 | + "default": "", |
| 27 | + } |
| 28 | + ]; |
| 29 | + |
| 30 | + function openAiBackendsHook() { |
| 31 | + if (!githubToken || githubToken === "") { |
| 32 | + return []; |
| 33 | + } |
| 34 | + |
| 35 | + return [ |
| 36 | + { |
| 37 | + "id": "github-models", |
| 38 | + "name": "GitHub", |
| 39 | + "baseUrl": "https://models.inference.ai.azure.com/chat/completions", |
| 40 | + "apiKey": githubToken, |
| 41 | + "models": [ |
| 42 | + "gpt-4o", |
| 43 | + "gpt-4o-mini", |
| 44 | + "gpt-4.1", |
| 45 | + "gpt-4.1-mini", |
| 46 | + "gpt-4.1-nano", |
| 47 | + "gpt-5", |
| 48 | + "gpt-5-mini", |
| 49 | + "gpt-5-nano", |
| 50 | + "o4-mini", |
| 51 | + "o3", |
| 52 | + "o3-mini", |
| 53 | + "o1", |
| 54 | + "o1-mini", |
| 55 | + "deepseek-r1", |
| 56 | + "deepseek-r1-0528", |
| 57 | + "deepseek-v3-0324", |
| 58 | + "llama-4-scout-17b-16e-instruct", |
| 59 | + "llama-4-maverick-17b-128e-instruct-fp8", |
| 60 | + "llama-3.3-70b-instruct", |
| 61 | + "grok-3", |
| 62 | + "grok-3-mini", |
| 63 | + "mistral-small-2503", |
| 64 | + "phi-4", |
| 65 | + "phi-4-reasoning", |
| 66 | + ], |
| 67 | + } |
| 68 | + ]; |
| 69 | + } |
| 70 | +} |
0 commit comments