Skip to content

Commit

Permalink
added configurable custom prompt
Browse files Browse the repository at this point in the history
This makes it easier to add to the existing internal prompt instead of
completely overwriting it using the localization mechanism.
  • Loading branch information
splitbrain committed Jul 29, 2024
1 parent 120aaf7 commit 666b8ea
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions conf/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
$conf['embedmodel'] = 'OpenAI text-embedding-ada-002';
$conf['storage'] = 'SQLite';

$conf['customprompt'] = '';

$conf['openai_apikey'] = '';
$conf['openai_org'] = '';

Expand Down
2 changes: 2 additions & 0 deletions conf/metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
)
);

$meta['customprompt'] = array();

$meta['openai_apikey'] = array('password');
$meta['openai_org'] = array('string');

Expand Down
1 change: 1 addition & 0 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ public function askQuestion($question, $history = [], $contextQuestion = '')
$prompt = $this->getPrompt('question', [
'context' => $context,
'question' => $question,
'customprompt' => $this->getConf('customprompt'),
]);
} else {
$prompt = $this->getPrompt('noanswer', [
Expand Down
2 changes: 1 addition & 1 deletion lang/en/question.prompt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Your Task: Use the following documents as context to answer the users question. If you don't know the answer, just say that you don't know, don't try to make up an answer. {{LANGUAGE}}
Your Task: Use the following documents as context to answer the users question. If you don't know the answer, just say that you don't know, don't try to make up an answer. {{LANGUAGE}} {{CUSTOMPROMPT}}

----------------
{{CONTEXT}}
Expand Down
2 changes: 1 addition & 1 deletion lang/en/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
$lang['rephrasemodel'] = 'The 🧠 model to use for rephrasing questions. Configure required credentials below.';
$lang['embedmodel'] = 'The 🧠 model to use for text embedding. Configure required credentials below.<br>🔄 You need to rebuild the vector storage when changing this setting.';
$lang['storage'] = 'Which 📥 vector storage to use. Configure required credentials below.<br>🔄 You need to rebuild the vector storage when changing this setting.';

$lang['customprompt'] = 'A custom prompt that is added to the prompt used by this plugin when querying the AI model. For consistency, it should be in English.';

$lang['openai_apikey'] = '🧠 <b>OpenAI</b> API key';
$lang['openai_org'] = '🧠 <b>OpenAI</b> Organization ID (if any)';
Expand Down

0 comments on commit 666b8ea

Please sign in to comment.