summaryrefslogtreecommitdiff
path: root/src/lib/services/aitranslation.ts
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-08-17 02:20:42 +0700
committerpolwex <polwex@sortug.com>2025-08-17 02:20:42 +0700
commit9be51e192fca8901d47328875d9e0c690d4b2b99 (patch)
tree926151e075c539019c5eb65e2140678acb383c5f /src/lib/services/aitranslation.ts
parentc505750ab36f8164256a91830fc83a807a9d6984 (diff)
this was me. local LLM!HEADmaster
Diffstat (limited to 'src/lib/services/aitranslation.ts')
-rw-r--r--src/lib/services/aitranslation.ts14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/lib/services/aitranslation.ts b/src/lib/services/aitranslation.ts
index 331e10e..fb88323 100644
--- a/src/lib/services/aitranslation.ts
+++ b/src/lib/services/aitranslation.ts
@@ -1,12 +1,12 @@
import { z } from "zod";
import type { Language, TranslationService } from "../types";
-import AIModelAPI, { type AIModelChoice } from "sortug-ai";
+import AIModelAPI, { type LLMChoice } from "sortug-ai";
import type { AsyncRes } from "@/lib/types";
export class AiTranslator implements TranslationService {
endpoint = ""; // doesn't apply here
api;
- constructor(model: AIModelChoice) {
+ constructor(model: LLMChoice) {
const api = AIModelAPI(model);
this.api = api;
}
@@ -24,12 +24,11 @@ export class AiTranslator implements TranslationService {
},
];
const res = await this.api.send(
- `You are a professional, state of the art excellent translation service. Please translate the text given by the user. The prompts will be sent as JSON, in the format "{'text': string, 'sourceLang': string, 'targetLang': string}". You are to translate the 'text' from 'fromLang' to 'targetLang'. Output the desired translation and nothing else. Pause to think the translations as much as you need.`,
input,
+ `You are a professional, state of the art excellent translation service. Please translate the text given by the user. The prompts will be sent as JSON, in the format "{'text': string, 'sourceLang': string, 'targetLang': string}". You are to translate the 'text' from 'fromLang' to 'targetLang'. Output the desired translation and nothing else. Pause to think the translations as much as you need.`,
);
console.log({ res });
- if ("error" in res) return res;
- else return { ok: res.ok.join(", ") };
+ return res;
}
async getSupportedLanguages() {
@@ -49,10 +48,9 @@ export class AiTranslator implements TranslationService {
},
];
const res = await this.api.send(
- `You are a professional, state of the art excellent translation service. Please transliterate, the text given by the user. The prompts will be sent as JSON, in the format "{'text': string, 'language': string, 'fromScript': string, 'toScript': string}". You are to transliterate the 'text' belongng to language 'language' from 'fromScript' to 'toScript' to the best of your ability. Output the desired transiteration and nothing else. Pause to think the output as much as you need.`,
input,
+ `You are a professional, state of the art excellent translation service. Please transliterate, the text given by the user. The prompts will be sent as JSON, in the format "{'text': string, 'language': string, 'fromScript': string, 'toScript': string}". You are to transliterate the 'text' belongng to language 'language' from 'fromScript' to 'toScript' to the best of your ability. Output the desired transiteration and nothing else. Pause to think the output as much as you need.`,
);
- if ("error" in res) return res;
- else return { ok: res.ok.join(", ") };
+ return res;
}
}