Make LocalAI Stable Diffusion work in plugin.
This commit is contained in:
parent
625c47ab44
commit
49a3185585
1 changed files with 6 additions and 24 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue