logancyang / obsidian-copilot

THE Copilot in Obsidian
GNU Affero General Public License v3.0
2.72k stars 189 forks source link

Add support for GPT-4o #446

Closed flemming-pr closed 2 months ago

flemming-pr commented 4 months ago

GPT-4o was just released and it would be nice to use it in Copilot due to lower costs and faster responses.

atsyplenkov commented 4 months ago

Oh, yeah, this PR is very much anticipated! @logancyang please merge it!

wafe commented 4 months ago

Thank you very much for this PR! I have directly edited my main.js. Additionally, we need to update tiktoken as well. GPT-4o uses the o200k_base tokenizer, which is different from the one used by GPT-4 models.

image

flemming-pr commented 4 months ago

Yeah great, waiting for this as well!

I believe you need to add an option to the chat model selection for it to show up:

master...wehard:obsidian-copilot:patch-1

Thanks for your help. I have added it to my PR.

flemming-pr commented 4 months ago

Thank you very much for this PR! I have directly edited my main.js. Additionally, we need to update tiktoken as well. GPT-4o uses the o200k_base tokenizer, which is different from the one used by GPT-4 models.

image

@wafe To my shame. I actually just looked for suitable places in the code and added the option. Can you tell me exactly where this part needs to be added?

peteretelej commented 4 months ago

@wafe To my shame. I actually just looked for suitable places in the code and added the option. Can you tell me exactly where this part needs to be added?

I'd recommend waiting for the merge. But if you have to, backup the plugin folder first. Just for reference for anyone that's trying to do this, the main.js output to edit is at .obsidian/plugins/copilot/main.js I'd search for GPT-4 TURBO and add duplicate line in each of the places for gpt-4o. For the tokenizer, you can add a new case to the function getEncodingNameForModel

case "gpt-4o": {
      return "o200k-base";
}
Richard-Woessner commented 4 months ago

Thank you @peteretelej it worked for me

Richard-Woessner commented 4 months ago

main copy.txt

Also, if someone else comes across this and needs a quick reference, here's my main.js that works for me.

I had to change it to a text file because github

kvndrsslr commented 3 months ago

ℹ️ The file uploaded by @Richard-Woessner (thanks!) contains a typo so while it might look like it's working it'll actually not use GPT-4o. Instead it'll use whatever model you loaded before that. To fix it, search the file for GPY-4 and replace with GPT-4! :)

Richard-Woessner commented 3 months ago

file by @Richard-Woessner (thanks!) contains a typo so while it might look like it's working it'll actually not use GPT-4o

Ope, Thanks for the heads up.

Placebo effect is real. I thought it was working lol.

morrisjosephd commented 3 months ago

I'd recommend waiting for the merge.

@peteretelej Do you have insight you can share as to when this could merge?

peteretelej commented 3 months ago

I'd recommend waiting for the merge.

@peteretelej Do you have insight you can share as to when this could merge?

No idea, seems like Logan's been away for a while. Didn't know it'd take long. Please see my comment on how to update the main.js file to add 4o

Richard-Woessner commented 3 months ago

main.copy.txt Typo fixed

varlineau commented 3 months ago

Hi! I'm sorry, I'm new to using github. How do I update my Copilot plugin to include this PR?

Richard-Woessner commented 3 months ago

Hi! I'm sorry, I'm new to using github. How do I update my Copilot plugin to include this PR?

You could wait or add the main.js file yourself. I'm out so I'm not able to give a great explanation but in your vault look into the hidden .obsidian file, go to plugins, then to obsidian copilot, backup up main.js and replace it with the text file I linked.

Make sure to rename it to main.js

varlineau commented 3 months ago

Hi! I'm sorry, I'm new to using github. How do I update my Copilot plugin to include this PR?

You could wait or add the main.js file yourself. I'm out so I'm not able to give a great explanation but in your vault look into the hidden .obsidian file, go to plugins, then to obsidian copilot, backup up main.js and replace it with the text file I linked.

Make sure to rename it to main.js

Thank you so much!

logancyang commented 2 months ago

@flemming-petersen Sorry guys, I've been AFK for a while, life happened. But I'm back now! Thanks for the PR, merged! Will put up a new version soon!