Skip to content

Commit

Permalink
Readme: Move Completion section below Chat
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Brand committed Aug 2, 2023
1 parent 5b1e430 commit 2633d49
Showing 1 changed file with 54 additions and 54 deletions.
108 changes: 54 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,60 +148,6 @@ $response->deleted; // true
$response->toArray(); // ['id' => 'curie:ft-acmeco-2021-03-03-21-44-20', ...]
```

### `Completions` Resource (legacy)

#### `create`

Creates a completion for the provided prompt and parameters.

```php
$response = $client->completions()->create([
'model' => 'text-davinci-003',
'prompt' => 'Say this is a test',
'max_tokens' => 6,
'temperature' => 0
]);

$response->id; // 'cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7'
$response->object; // 'text_completion'
$response->created; // 1589478378
$response->model; // 'text-davinci-003'

foreach ($response->choices as $result) {
$result->text; // '\n\nThis is a test'
$result->index; // 0
$result->logprobs; // null
$result->finishReason; // 'length' or null
}

$response->usage->promptTokens; // 5,
$response->usage->completionTokens; // 6,
$response->usage->totalTokens; // 11

$response->toArray(); // ['id' => 'cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7', ...]
```

#### `create streamed`

Creates a streamed completion for the provided prompt and parameters.

```php
$stream = $client->completions()->createStreamed([
'model' => 'text-davinci-003',
'prompt' => 'Hi',
'max_tokens' => 10,
]);

foreach($stream as $response){
$response->choices[0]->text;
}
// 1. iteration => 'I'
// 2. iteration => ' am'
// 3. iteration => ' very'
// 4. iteration => ' excited'
// ...
```

### `Chat` Resource

#### `create`
Expand Down Expand Up @@ -305,6 +251,60 @@ foreach($stream as $response){
// ...
```

### `Completions` Resource (legacy)

#### `create`

Creates a completion for the provided prompt and parameters.

```php
$response = $client->completions()->create([
'model' => 'text-davinci-003',
'prompt' => 'Say this is a test',
'max_tokens' => 6,
'temperature' => 0
]);

$response->id; // 'cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7'
$response->object; // 'text_completion'
$response->created; // 1589478378
$response->model; // 'text-davinci-003'

foreach ($response->choices as $result) {
$result->text; // '\n\nThis is a test'
$result->index; // 0
$result->logprobs; // null
$result->finishReason; // 'length' or null
}

$response->usage->promptTokens; // 5,
$response->usage->completionTokens; // 6,
$response->usage->totalTokens; // 11

$response->toArray(); // ['id' => 'cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7', ...]
```

#### `create streamed`

Creates a streamed completion for the provided prompt and parameters.

```php
$stream = $client->completions()->createStreamed([
'model' => 'text-davinci-003',
'prompt' => 'Hi',
'max_tokens' => 10,
]);

foreach($stream as $response){
$response->choices[0]->text;
}
// 1. iteration => 'I'
// 2. iteration => ' am'
// 3. iteration => ' very'
// 4. iteration => ' excited'
// ...
```

### `Audio` Resource

#### `transcribe`
Expand Down

0 comments on commit 2633d49

Please sign in to comment.