This repository has been archived by the owner on Nov 22, 2023. It is now read-only.
generated from spatie/package-skeleton-php
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
18 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,31 @@ | ||
# A PHP wrapper for the OpenAI API | ||
# Archive Notice for the OpenAI PHP Wrapper | ||
|
||
[![Latest Version on Packagist](https://badgen.net/packagist/v/siteorigin/openai-api)](https://packagist.org/packages/siteorigin/openai-api) | ||
[![PHP Version Requirement](https://badgen.net/packagist/php/siteorigin/openai-api)](https://packagist.org/packages/siteorigin/openai-api) | ||
[![GitHub Tests Action Status](https://github.com/siteorigin/openai-api/actions/workflows/run-tests.yml/badge.svg)](https://github.com/siteorigin/openai-api/actions?query=workflow%3ATests+branch%3Amaster) | ||
[![GitHub Code Style Action Status](https://github.com/siteorigin/openai-api/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/siteorigin/openai-api/actions?query=workflow%3A"Check+%26+fix+styling"+branch%3Amaster) | ||
[![Total Downloads](https://badgen.net/packagist/dt/siteorigin/openai-api)](https://packagist.org/packages/siteorigin/openai-api) | ||
This repository for the OpenAI PHP Wrapper, developed by SiteOrigin, is now archived. For updated and ongoing PHP integration with OpenAI's API, please refer to the [OpenAI PHP Client](https://github.com/openai-php/client) instead. | ||
|
||
--- | ||
## Original Repository Details: | ||
|
||
GPT-3 lets you inject a little bit of AI magic into your apps, and this PHP wrapper makes it even easier to access. Covers the entire OpenAI API, in a familiar PHP way, without limiting any functionality. | ||
- **Repository:** [OpenAI PHP Wrapper by SiteOrigin](https://github.com/siteorigin/openai-api) | ||
- **Packagist:** [siteorigin/openai-api](https://packagist.org/packages/siteorigin/openai-api) | ||
- **Functionality:** Facilitated integration with the OpenAI API, offering a PHP-based approach for incorporating GPT-3 into applications. | ||
|
||
```php | ||
use SiteOrigin\OpenAI\Client; | ||
$client = new Client($_ENV['OPENAI_API_KEY']); | ||
$completions = $client->completions('davinci')->complete("The most important technology for humanity is", [ | ||
'max_tokens' => 32, | ||
'temperature' => 0.8, | ||
'n' => 4, | ||
'stop' => ["\n", '.'] | ||
]); | ||
foreach($completions as $c) { | ||
echo $c->text . "\n"; | ||
} | ||
``` | ||
|
||
Read more on the [documentation wiki](https://github.com/siteorigin/openai-api/wiki). | ||
### Features: | ||
|
||
## Installation | ||
- Provided a comprehensive interface for the OpenAI API in PHP. | ||
- Simplified syntax for common tasks like generating completions. | ||
- Supported full API functionality without constraints. | ||
|
||
You can install the package via composer: | ||
|
||
```bash | ||
composer require siteorigin/openai-api | ||
``` | ||
|
||
## Usage | ||
|
||
For most of the features of this wrapper, you should have an understanding of the [OpenAI API](https://beta.openai.com/docs/api-reference/introduction). | ||
### Example Code Snippet: | ||
|
||
```php | ||
// Set up a client with your API key. | ||
use SiteOrigin\OpenAI\Client; | ||
use SiteOrigin\OpenAI\Models; | ||
|
||
$client = new Client($_ENV['OPENAI_API_KEY']); | ||
|
||
// Create a completion call | ||
$c = $client->completions(Models::BABBAGE)->complete('The meaning of life is: ', [ /* ... */]); | ||
|
||
// List all the available engines | ||
$e = $client->engines()->list(); | ||
|
||
// Classify safe/unsafe content | ||
$f = $client->filter()->classify('ponies are fantastic!'); // 'safe' | ||
``` | ||
|
||
## Testing | ||
|
||
```bash | ||
composer test | ||
// Example usage for generating completions | ||
$completions = $client->completions('davinci')->complete("Sample prompt", [/* parameters */]); | ||
foreach($completions as $c) { | ||
echo $c->text . "\n"; | ||
} | ||
``` | ||
|
||
## Changelog | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. | ||
|
||
## Contributing | ||
|
||
Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details. | ||
|
||
## Security Vulnerabilities | ||
|
||
Please email [email protected] if you find any security vulnerabilities. | ||
|
||
## Credits | ||
|
||
- [Greg Priday](https://github.com/gregpriday) | ||
- [All Contributors](../../contributors) | ||
|
||
## License | ||
### Further Information: | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. | ||
For those who previously utilized or are interested in this PHP wrapper, it's recommended to transition to the [new OpenAI PHP Client](https://github.com/openai-php/client) for the latest updates and continued support. |