Skip to content

Commit

Permalink
fix: model update on gpt & new language mapping logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ParvinEyvazov committed Jul 31, 2024
1 parent 98754be commit 4853271
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 785 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.0.1",
"version": "3.0.2",
"license": "MIT",
"main": "dist/index.js",
"description": "Translate your JSON file or object into another languages with Google Translate API",
Expand Down
11 changes: 10 additions & 1 deletion src/modules/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ export async function translateWithGPT4o(
str: string,
from: string,
to: string
) {
return translateWithGPT('gpt-4o', str, from, to);
}

export async function translateWithGPT(
model: string,
str: string,
from: string,
to: string
) {
type ChatCompletionRequestMessage = {
role: 'system' | 'user' | 'assistant';
Expand Down Expand Up @@ -214,7 +223,7 @@ export async function translateWithGPT4o(
];

const response = await openai.chat.completions.create({
model: 'gpt-4',
model: model,
messages: conversationHistory,
max_tokens: 1000,
});
Expand Down
8 changes: 4 additions & 4 deletions src/modules/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ export function getLanguageVariant(

for (let key of Object.keys(LanguageMapping)) {
if (
LanguageMapping[key][source] !== undefined &&
LanguageMapping[key][source] === sourceValue &&
LanguageMapping[key][destination] !== undefined
LanguageMapping[key].includes(source) &&
getTranslationModuleByKey(source).languages[key] === sourceValue &&
LanguageMapping[key].includes(destination)
) {
destinationValue = LanguageMapping[key][destination];
destinationValue = getTranslationModuleByKey(destination).languages[key];
break;
}
}
Expand Down
Loading

0 comments on commit 4853271

Please sign in to comment.