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)
|
protected function prepare($opts)
|
||||||
{
|
{
|
||||||
if (filter_var($this->job['request'], FILTER_VALIDATE_URL)) {
|
|
||||||
// https://platform.openai.com/docs/api-reference/images/create-variation
|
$opts += [
|
||||||
// The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
|
'prompt' => trim($this->job['request']),
|
||||||
$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,
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $opts;
|
return $opts;
|
||||||
}
|
}
|
||||||
|
@ -93,13 +81,7 @@ class dalle extends GenericController
|
||||||
|
|
||||||
$result = new resultSubmit();
|
$result = new resultSubmit();
|
||||||
|
|
||||||
if (empty($opts['image'])) {
|
$result->response = $api->sendRequest($this->cfg->url_generations, 'POST', $opts);
|
||||||
// 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->responseCodes = $api->responseCodes;
|
$result->responseCodes = $api->responseCodes;
|
||||||
|
|
||||||
|
@ -173,4 +155,4 @@ class dalle extends GenericController
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue