Skip to content

Commit cfaf6b3

Browse files
committed
tell the model to fall back to current language if it's unsure
The model defaulted to spanish if no sources were found
1 parent 2e4b1fa commit cfaf6b3

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

helper.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function askQuestion($question, $previous = [])
179179
'language' => $this->getLanguagePrompt()
180180
]);
181181
} else {
182-
$prompt = $this->getPrompt('noanswer');
182+
$prompt = $this->getPrompt('noanswer') . ' ' . $this->getLanguagePrompt();
183183
}
184184

185185
$messages = [
@@ -273,16 +273,19 @@ protected function getPrompt($type, $vars = [])
273273
protected function getLanguagePrompt()
274274
{
275275
global $conf;
276+
$isoLangnames = include(__DIR__ . '/lang/languages.php');
277+
278+
$currentLang = $isoLangnames[$conf['lang']] ?? 'English';
276279

277280
if ($this->getConf('preferUIlanguage') > AIChat::LANG_AUTO_ALL) {
278-
$isoLangnames = include(__DIR__ . '/lang/languages.php');
279281
if (isset($isoLangnames[$conf['lang']])) {
280282
$languagePrompt = 'Always answer in ' . $isoLangnames[$conf['lang']] . '.';
281283
return $languagePrompt;
282284
}
283285
}
284286

285-
$languagePrompt = 'Always answer in the user\'s language.';
287+
$languagePrompt = 'Always answer in the user\'s language.' .
288+
"If you are unsure about the language, speak $currentLang.";
286289
return $languagePrompt;
287290
}
288291

lang/en/prompt_noanswer.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Given the user's question, tell them that you can't answer it because you couldn't find any matching wiki pages, which is likely because the user has insufficient permissions to access them or the question was off-topic. Answer in the same language as the question.
1+
Given the user's question, tell them that you can't answer it because you couldn't find any matching wiki pages, which is likely because the user has insufficient permissions to access them or the question was off-topic.

0 commit comments

Comments
 (0)