Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Space Config #66

Merged
merged 3 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This page is a brief overview of each version.
- Use a separate queue for indexing embeddings and summaries, to prevent blocking the main SB indexing thread
- Refactor to use JSR for most Silverbullet imports, and lots of related changes
- Reduced bundle size
- Add support for [space-config](https://silverbullet.md/Space%20Config)

---
## 0.3.2
Expand Down
10 changes: 9 additions & 1 deletion sbai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,21 @@ import {
* This should prevent us from having to reload or refresh when changing the settings.
* TODO: This gets triggered when other settings are changed too, but shouldn't make a difference
* when there are no changes to the objects we care about.
* TODO: Remove after space-config has been around for a while
*/
export async function reloadConfig(pageName: string) {
export async function reloadSettingsPage(pageName: string) {
if (pageName === "SETTINGS" || pageName === "SECRETS") {
await initializeOpenAI(true);
}
}

/**
* Similar to the above function, but meant for the config:loaded event.
*/
export async function reloadConfig() {
await initializeOpenAI(true);
}

/**
* Prompts the user to select a text/llm model from the configured models.
*/
Expand Down
10 changes: 8 additions & 2 deletions silverbullet-ai.plug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ functions:
queryAI:
path: sbai.ts:queryAI

reloadConfig:
path: sbai.ts:reloadConfig
reloadSettingsPageEvent:
path: sbai.ts:reloadSettingsPage
events:
- page:saved

reloadConfigEvent:
path: sbai.ts:reloadConfig
events:
- config:loaded

summarizeNote:
path: sbai.ts:openSummaryPanel
command:
Expand Down
3 changes: 1 addition & 2 deletions src/init.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { readSecret } from "https://deno.land/x/silverbullet@0.9.4/plug-api/lib/secrets_page.ts";
import { readSetting } from "https://deno.land/x/silverbullet@0.7.7/plug-api/lib/settings_page.ts";
import { clientStore, system } from "@silverbulletmd/silverbullet/syscalls";
import { DallEProvider } from "./providers/dalle.ts";
import { GeminiEmbeddingProvider, GeminiProvider } from "./providers/gemini.ts";
Expand Down Expand Up @@ -347,7 +346,7 @@ async function loadAndMergeSettings() {
indexSummaryPrompt: "",
enhanceFrontMatterPrompt: "",
};
const newSettings = await readSetting("ai", {});
const newSettings = await system.getSpaceConfig("ai", {});
justyns marked this conversation as resolved.
Show resolved Hide resolved
const newCombinedSettings = { ...defaultSettings, ...newSettings };
newCombinedSettings.chat = {
...defaultChatSettings,
Expand Down
Loading