From 9be51e192fca8901d47328875d9e0c690d4b2b99 Mon Sep 17 00:00:00 2001 From: polwex Date: Sun, 17 Aug 2025 02:20:42 +0700 Subject: this was me. local LLM! --- src/lib/services/aitranslation.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/lib/services/aitranslation.ts') 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; } } -- cgit v1.2.3