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 builtins from "builtin-modules";
const banner =
`/*
const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
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({
banner: {
js: banner,
},
entryPoints: ["main.ts"],
entryPoints: ["src/main.ts"],
bundle: true,
external: [
"obsidian",
@ -31,7 +30,8 @@ const context = await esbuild.context({
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins],
...builtins,
],
format: "cjs",
target: "es2018",
logLevel: "info",
@ -45,4 +45,4 @@ if (prod) {
process.exit(0);
} else {
await context.watch();
}
}

View file

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

View file

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