Move files into src, rename classes

This commit is contained in:
Mohammad Iskandarani 2023-03-14 17:31:17 +03:00
parent 50d81ae3ad
commit dad58d83c3
4 changed files with 14 additions and 17 deletions

View file

@ -2,20 +2,19 @@ import esbuild from "esbuild";
import process from "process"; import process from "process";
import builtins from "builtin-modules"; import builtins from "builtin-modules";
const banner = const banner = `/*
`/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin if you want to view the source, please visit the github repository of this plugin
*/ */
`; `;
const prod = (process.argv[2] === "production"); const prod = process.argv[2] === "production";
const context = await esbuild.context({ const context = await esbuild.context({
banner: { banner: {
js: banner, js: banner,
}, },
entryPoints: ["main.ts"], entryPoints: ["src/main.ts"],
bundle: true, bundle: true,
external: [ external: [
"obsidian", "obsidian",
@ -31,7 +30,8 @@ const context = await esbuild.context({
"@lezer/common", "@lezer/common",
"@lezer/highlight", "@lezer/highlight",
"@lezer/lr", "@lezer/lr",
...builtins], ...builtins,
],
format: "cjs", format: "cjs",
target: "es2018", target: "es2018",
logLevel: "info", logLevel: "info",
@ -45,4 +45,4 @@ if (prod) {
process.exit(0); process.exit(0);
} else { } else {
await context.watch(); await context.watch();
} }

View file

@ -1,6 +1,6 @@
import { Configuration, OpenAIApi } from "openai"; import { Configuration, OpenAIApi } from "openai";
import GPT3Tokenizer from "gpt3-tokenizer"; import GPT3Tokenizer from "gpt3-tokenizer";
import { cosineSimilarity } from "utils"; import { cosineSimilarity } from "./utils";
export interface chunkData { export interface chunkData {
text: string; text: string;

View file

@ -1,8 +1,6 @@
import { Answer, Assistant } from "assistant"; import { Answer, Assistant } from "./assistant";
import { import {
App, App,
Component,
MarkdownPreviewRenderer,
MarkdownRenderer, MarkdownRenderer,
Modal, Modal,
Notice, Notice,
@ -11,18 +9,17 @@ import {
Setting, Setting,
TextAreaComponent, TextAreaComponent,
} from "obsidian"; } from "obsidian";
// TODO: Remember to rename these classes and interfaces!
interface MyPluginSettings { interface PluginSettings {
apiKey: string; apiKey: string;
} }
const DEFAULT_SETTINGS: MyPluginSettings = { const DEFAULT_SETTINGS: PluginSettings = {
apiKey: "", apiKey: "",
}; };
export default class MyPlugin extends Plugin { export default class GPTAssistantPlugin extends Plugin {
settings: MyPluginSettings; settings: PluginSettings;
assistant: Assistant; assistant: Assistant;
async onload() { async onload() {
this.addSettingTab(new AssistantSettings(this.app, this)); this.addSettingTab(new AssistantSettings(this.app, this));
@ -152,9 +149,9 @@ class AskAssistantModal extends Modal {
} }
class AssistantSettings extends PluginSettingTab { class AssistantSettings extends PluginSettingTab {
plugin: MyPlugin; plugin: GPTAssistantPlugin;
constructor(app: App, plugin: MyPlugin) { constructor(app: App, plugin: GPTAssistantPlugin) {
super(app, plugin); super(app, plugin);
this.plugin = plugin; this.plugin = plugin;
} }