Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #20 from tectalichq/feature/readme
Browse files Browse the repository at this point in the history
Use a more relevant GPT-4 example code snippet
  • Loading branch information
thejamescollins authored Mar 17, 2023
2 parents 7439292 + 829902c commit 2a343b6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,30 @@ Integrating OpenAI into your application is now as simple as a few lines of code
### Chat Completion using ChatGPT (GPT-3.5 & GPT-4)

```php
$openaiClient = \Tectalic\OpenAi\Manager::build(new \GuzzleHttp\Client(), new \Tectalic\OpenAi\Authentication(getenv('OPENAI_API_KEY')));
$openaiClient = \Tectalic\OpenAi\Manager::build(
new \GuzzleHttp\Client(),
new \Tectalic\OpenAi\Authentication(getenv('OPENAI_API_KEY'))
);

/** @var \Tectalic\OpenAi\Models\ChatCompletions\CreateResponse $response */
$response = $openaiClient->chatCompletions()->create(
new \Tectalic\OpenAi\Models\ChatCompletions\CreateRequest([
'model' => 'gpt-4',
'messages' => [
['role' => 'user', 'content' => 'Tell the world about GPT-4 in the style of a pirate'],
[
'role' => 'user',
'content' => 'Will using a well designed and supported third party package save time?'
],
],
])
)->toModel();

echo $response->choices[0]->message->content;
Ahoy there, ye landlubbers and sea dogs! Gather 'round for a tale of a treasure like no other - the mystical, the enigmatic, GPT-4. ...

// Yes, using a well-designed and supported third-party package can save time during software development.
// It allows you to focus on the core functionality of your application without having to reinvent the wheel or spend resources developing the same functionality from scratch.
// A good third-party package can provide reliability, efficiency, and continued support with updates and bug fixes, which in turn facilitates faster development and a more stable final product.
// Additionally, using widely adopted packages can also increase the chances of compatibility with other software components and make it easier for other developers to understand and work with your code.
```

[Learn more about chat completion](https://platform.openai.com/docs/guides/chat).
Expand Down

0 comments on commit 2a343b6

Please sign in to comment.