Added LocalAI

This commit is contained in:
johnnyq
2024-02-10 21:25:18 -05:00
parent a1d642c54b
commit 48ba4445bf
2 changed files with 5 additions and 1 deletions

View File

@@ -12,11 +12,14 @@ if (isset($_GET['ai_reword'])) {
$inputJSON = file_get_contents('php://input'); $inputJSON = file_get_contents('php://input');
$input = json_decode($inputJSON, TRUE); // Convert JSON into array. $input = json_decode($inputJSON, TRUE); // Convert JSON into array.
// Prefix the input text with "reword: "
$prefixedText = "reword: " . $input['text'];
// Preparing the data for the OpenAI Chat API request. // Preparing the data for the OpenAI Chat API request.
$data = [ $data = [
"model" => "$config_ai_model", // Specify the model "model" => "$config_ai_model", // Specify the model
"messages" => [ "messages" => [
["role" => "user", "content" => $input['text']] ["role" => "user", "content" => $prefixedText]
], ],
"temperature" => 0.7 "temperature" => 0.7
]; ];

View File

@@ -21,6 +21,7 @@ require_once "inc_all_settings.php";
<option value="" <?php if($config_ai_enable == 0) { echo "selected"; } ?> >Disabled</option> <option value="" <?php if($config_ai_enable == 0) { echo "selected"; } ?> >Disabled</option>
<option <?php if($config_ai_provider == "Ollama") { echo "selected"; } ?> >Ollama</option> <option <?php if($config_ai_provider == "Ollama") { echo "selected"; } ?> >Ollama</option>
<option <?php if($config_ai_provider == "OpenAI") { echo "selected"; } ?> >OpenAI</option> <option <?php if($config_ai_provider == "OpenAI") { echo "selected"; } ?> >OpenAI</option>
<option <?php if($config_ai_provider == "LocalAI") { echo "selected"; } ?> >LocalAI</option>
</select> </select>
</div> </div>
</div> </div>