bramses / summarize-with-gpt3-obsidian

Summarize text with GPT-3 in Obsidian (progressive summarization)
39 stars 2 forks source link

Update to GPT 4? #4

Closed sm18lr88 closed 1 year ago

sm18lr88 commented 1 year ago

For those of us who subscribed for GPT 4, is there a way to use this model vs GPT 3?

bramses commented 1 year ago

i havent edited this codebase in a while, but your best bet is to install it locally and add the gpt-4 engine to this line: https://github.com/bramses/summarize-with-gpt3-obsidian/blob/e59c737df51de1546e040a2a8d1419df9092b4aa/main.ts#L221

sm18lr88 commented 1 year ago

I had GPT 4 help me out. Here is the solution (at least it seems to work for me). Sorry I'm not submitting it in some official way. I'm not a programmer and don't really know how to use Github:

In Main.ts:

const DEFAULT_SETTINGS: GPT3SummarizerSettings = {
    apiKey: "default",
    engine: "gpt-4", // Change this line
    tagToggle: true,
    keepOriginal: true,
};

And further down:

// dropdown setting for choosing engine
new Setting(containerEl)
    .setName("Engine")
    .setDesc("Choose the engine to use for summarization")
    .addDropdown((dropdown) =>
        dropdown
            .addOption("gpt-4", "GPT-4") // Add this line for GPT-4
            .addOption("text-davinci-003", "Davinci")
            .addOption("text-curie-001", "Curie")
            .addOption("text-babbage-001", "Babbage")
            .addOption("text-ada-001", "Ada")

In Main.js, line ~162, we add the option also GPT-4 in the drop-down menu:

...
new import_obsidian.Setting(containerEl).setName("Engine").setDesc("Choose the engine to use for summarization").addDropdown((dropdown) => dropdown.addOption("text-davinci-003", "Davinci").addOption("text-curie-001", "Curie").addOption("text-babbage-001", "Babbage").addOption("text-ada-001", "Ada").addOption("gpt-4", "GPT-4").setValue(this.plugin.settings.engine).onChange((value) => __async(this, null, function* () {
...
bramses commented 1 year ago

So upon further research, the completions endpoint doesn't support GPT-4 and you'd have to move to the ChatML format.

You would need to do light surgery on this method to make it conform to the new ChatML format, see this plugin as an example

In Main.js, line ~162, we add the option also GPT-4 in the drop-down menu:

You shouldn't edit main.js directly, instead use npm run build!