obsidian-copilot icon indicating copy to clipboard operation
obsidian-copilot copied to clipboard

Add support for GPT-4o

Open flemming-pr opened this issue 1 year ago • 6 comments

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

flemming-pr avatar May 14 '24 17:05 flemming-pr

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

atsyplenkov avatar May 14 '24 21:05 atsyplenkov

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 avatar May 16 '24 03:05 wafe

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 avatar May 17 '24 10:05 flemming-pr

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?

flemming-pr avatar May 17 '24 10:05 flemming-pr

@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";
}

peteretelej avatar May 18 '24 13:05 peteretelej

Thank you @peteretelej it worked for me

Richard-Woessner avatar May 21 '24 19:05 Richard-Woessner

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

Richard-Woessner avatar May 22 '24 18:05 Richard-Woessner

ℹ️ 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! :)

kvndrsslr avatar Jun 07 '24 10:06 kvndrsslr

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.

Richard-Woessner avatar Jun 07 '24 13:06 Richard-Woessner

I'd recommend waiting for the merge.

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

morrisjosephd avatar Jun 07 '24 17:06 morrisjosephd

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

peteretelej avatar Jun 07 '24 18:06 peteretelej

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

spaceoutlaws avatar Jun 21 '24 20:06 spaceoutlaws

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

Richard-Woessner avatar Jun 21 '24 21:06 Richard-Woessner

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!

spaceoutlaws avatar Jun 21 '24 23:06 spaceoutlaws

@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!

logancyang avatar Jul 21 '24 22:07 logancyang