Skip to content

Commit

Permalink
MBS-9817: Instruct LLM to only return the bare translation
Browse files Browse the repository at this point in the history
  • Loading branch information
PhMemmel committed Dec 28, 2024
1 parent f2a4650 commit c2e54c9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion question.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ protected function llm_translate(string $text): string {

$cache = cache::make('qtype_aitext', 'stringdata');
if (($translation = $cache->get(current_language().'_'.$text)) === false) {
$prompt = 'translate "'.$text .'" into '.current_language();
$prompt = 'translate "'.$text .'" into '.current_language() .
'Only return the exact text, do not wrap it in other text.';
$translation = $this->perform_request($prompt, 'translate');
$translation = trim($translation, '"');
$cache->set(current_language().'_'.$text, $translation);
Expand Down

0 comments on commit c2e54c9

Please sign in to comment.