From 49a318558532564accc17f47997ea96b98e7701e Mon Sep 17 00:00:00 2001 From: hibobmaster <32976627+hibobmaster@users.noreply.github.com> Date: Sun, 24 Dec 2023 22:44:02 +0800 Subject: [PATCH] Make LocalAI Stable Diffusion work in plugin. --- privet/ailabs/controller/dalle.php | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/privet/ailabs/controller/dalle.php b/privet/ailabs/controller/dalle.php index ffc1d81..73e7c86 100644 --- a/privet/ailabs/controller/dalle.php +++ b/privet/ailabs/controller/dalle.php @@ -66,22 +66,10 @@ class dalle extends GenericController protected function prepare($opts) { - if (filter_var($this->job['request'], FILTER_VALIDATE_URL)) { - // https://platform.openai.com/docs/api-reference/images/create-variation - // The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square. - $image = curl_file_create($this->job['request'], 'image/png'); - $opts += [ - 'image' => $image, - 'n' => $this->cfg->n, - 'response_format' => $this->cfg->response_format, - ]; - } else { - $opts += [ - 'prompt' => trim($this->job['request']), - 'n' => $this->cfg->n, - 'response_format' => $this->cfg->response_format, - ]; - } + + $opts += [ + 'prompt' => trim($this->job['request']), + ]; return $opts; } @@ -93,13 +81,7 @@ class dalle extends GenericController $result = new resultSubmit(); - if (empty($opts['image'])) { - // https://api.openai.com/v1/images/generations - $result->response = $api->sendRequest($this->cfg->url_generations, 'POST', $opts); - } else { - // https://api.openai.com/v1/images/variations - $result->response = $api->sendRequest($this->cfg->url_variations, 'POST', $opts); - } + $result->response = $api->sendRequest($this->cfg->url_generations, 'POST', $opts); $result->responseCodes = $api->responseCodes; @@ -173,4 +155,4 @@ class dalle extends GenericController return $result; } -} +} \ No newline at end of file