You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/LiveLingo.Core/Engines/LlamaTranslationEngine.cs
+14-6Lines changed: 14 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -47,17 +47,21 @@ public async Task<string> TranslateAsync(
47
47
vartgtName=GetLanguageName(targetLanguage);
48
48
49
49
varendpoint=await_host.GetOrStartServerAsync(ct);
50
-
varurl=$"{endpoint}/completion";
50
+
varurl=$"{endpoint}/v1/chat/completions";
51
51
52
52
varsystemPrompt=$"You are an expert translation engine. Your task is to translate the source text from {srcName} to {tgtName}.\n\nRules:\n1. Output ONLY the final {tgtName} translation.\n2. Do NOT output any {srcName} text.\n3. Do NOT output any explanations, conversational text, or notes.\n4. Do NOT use <think> tags or output any thought process.";
53
-
varprompt=$"<|im_start|>system\n{systemPrompt}<|im_end|>\n<|im_start|>user\nTranslate the following {srcName} text to {tgtName}:\n\n<source>\n{text}\n</source><|im_end|>\n<|im_start|>assistant\n";
53
+
varuserPrompt=$"Translate the following {srcName} text to {tgtName}:\n\n<source>\n{text}\n</source>";
54
54
55
-
_logger.LogDebug("Translation prompt for {Src}→{Tgt}: {Prompt}",sourceLanguage,targetLanguage,prompt);
55
+
_logger.LogDebug("Translation prompt for {Src}→{Tgt}: {Prompt}",sourceLanguage,targetLanguage,userPrompt);
56
56
57
57
varrequestBody=new
58
58
{
59
-
prompt=prompt,
60
-
n_predict=512,
59
+
messages=new[]
60
+
{
61
+
new{role="system",content=systemPrompt},
62
+
new{role="user",content=userPrompt}
63
+
},
64
+
max_tokens=512,
61
65
temperature=0.1f,
62
66
top_p=0.95f,
63
67
stop=StopSequences,
@@ -69,7 +73,11 @@ public async Task<string> TranslateAsync(
0 commit comments