-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.power
More file actions
58 lines (52 loc) · 1.34 KB
/
code.power
File metadata and controls
58 lines (52 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* Create a new edit using OpenAI Edit API.
* API Ref: https://platform.openai.com/docs/api-reference/edits
*
* @param string $model The model to use.
* @param string $instruction The instruction for the edit.
* @param string|null $input The input text (optional).
* @param int|null $n How many edits to generate (optional).
* @param float|null $temperature The sampling temperature (optional).
* @param float|null $topP Nucleus sampling parameter (optional).
*
* @return object|null
* @since 3.2.0
**/
public function create(
string $model,
string $instruction,
?string $input = null,
?int $n = null,
?float $temperature = null,
?float $topP = null
): ?object
{
// Build the request path.
$path = "/edits";
// Set the data.
$data = new \stdClass();
$data->model = $model;
$data->instruction = $instruction;
if ($input !== null)
{
$data->input = $input;
}
if ($n !== null)
{
$data->n = $n;
}
if ($temperature !== null)
{
$data->temperature = $temperature;
}
if ($topP !== null)
{
$data->top_p = $topP;
}
// Send the post request.
return $this->response->get(
$this->http->post(
$this->uri->get($path), json_encode($data)
)
);
}