generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.ts
31 lines (26 loc) · 836 Bytes
/
settings.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import OpenAIPlugin from "main";
import { App, PluginSettingTab, Setting } from "obsidian";
export class SettingTab extends PluginSettingTab {
plugin: OpenAIPlugin;
constructor(app: App, plugin: OpenAIPlugin) {
super(app, plugin);
this.plugin = plugin;
}
display(): void {
const { containerEl } = this;
containerEl.empty();
new Setting(containerEl)
.setName("OpenAI API Key")
.setDesc("The API key for the OpenAI API. This is required for the OpenAI plugin to work. You may obtain a key from https://beta.openai.com/account/api-keys")
.addText((text) =>
text
.setPlaceholder("OpenAI API key")
.setValue(this.plugin.settings.apiKey)
.onChange(async (value) => {
console.log(value);
this.plugin.settings.apiKey = value;
await this.plugin.saveSettings();
})
);
}
}