Skip to content

Commit

Permalink
feat: added gpt-4 for translation alongside appropriate setting. Chan…
Browse files Browse the repository at this point in the history
…ged default model to gpt-3.5
  • Loading branch information
MatissJurevics committed May 16, 2023
1 parent ec9deb4 commit 5910103
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface Settings {
translateTokens: number;
temperature: number;
model: string;
gpt4Translation: boolean;
}

const DEFAULT_SETTINGS: Settings = {
Expand All @@ -36,7 +37,8 @@ const DEFAULT_SETTINGS: Settings = {
modifyTokens: 364,
translateTokens: 364,
temperature: 0.7,
model: "text-davinci-003",
model: "gpt-3.5-turbo",
gpt4Translation: false,
};

export default class GeneAI extends Plugin {
Expand Down Expand Up @@ -179,6 +181,10 @@ export default class GeneAI extends Plugin {
.trim();
let language = "english";

// Use GPT-4 if enabled
let model:string;
this.settings.gpt4Translation ? model = "gpt-4" : model = this.settings.model;

new TranslatePrompt(this.app, async (result) => {
language = result;
let message = `Provided context (which may or may not be relavent): "${context}", Translate the following: "${prompt}" into ${language}`;
Expand All @@ -188,7 +194,7 @@ export default class GeneAI extends Plugin {
if (this.settings.model === "gpt-3.5-turbo") {
completion = await openai
.createChatCompletion({
model: this.settings.model,
model: model,
messages: [
{
role: "user",
Expand Down
22 changes: 18 additions & 4 deletions src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export class SettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
})
);



new Setting(containerEl)
.setName("AI Completion")
.setDesc("Tokens used for AI completion")
Expand Down Expand Up @@ -130,14 +131,27 @@ export class SettingTab extends PluginSettingTab {
})
);

new Setting(containerEl)
.setName("GPT-4 for Translation")
.setDesc("Use GPT-4 for translation. This will provide more accurate translations into other languages. (Will not work if you do not have access to GPT-4)")
.addToggle((toggle) =>
toggle
.setValue(this.plugin.settings.gpt4Translation)
.onChange(async (value: boolean) => {
this.plugin.settings.gpt4Translation = value;
await this.plugin.saveSettings();
})
);

new Setting(containerEl)
.setName("Model")
.setDesc(
"The model used for the AI. Different models have different strengths and weaknesses. (Note that the price changes with the model used)"
"The model used for the AI. Different models have different strengths and weaknesses. (Note that the price changes with the model used) NOTE: Most users will not be able to use GPT-4 as you must join a waitlist for it"
)
.addDropdown((val) =>
val
.addOption("gpt-3.5-turbo", "(Beta) ChatGPT")
val
.addOption("gpt-4", "GPT-4")
.addOption("gpt-3.5-turbo", "ChatGPT")
.addOption("text-davinci-003", "DaVinci")
.addOption("text-curie-001", "Curie")
.addOption("text-babbage-001", "Babbage")
Expand Down

0 comments on commit 5910103

Please sign in to comment.