Skip to content

Commit

Permalink
Merge branch 'main' into add-header-information
Browse files Browse the repository at this point in the history
  • Loading branch information
gehrisandro committed Aug 21, 2023
2 parents e529ac9 + 0d64fdb commit 1b4e9a4
Show file tree
Hide file tree
Showing 32 changed files with 126 additions and 89 deletions.
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## v0.6.3 (2023-07-07)
### Fixed
- Breaking change on OpenAI API regarding "transient" field in Audio ([#160](https://github.com/openai-php/client/pull/160))

## v0.6.2 (2023-06-23)
### Changed
- Error handling: use error code as exception message if error message is empty ([#150](https://github.com/openai-php/client/pull/150))

### Fixed
- Error handling: Catch error in stream responses ([#150](https://github.com/openai-php/client/pull/150))
- Error handling: Handle errors where message is an array ([#150](https://github.com/openai-php/client/pull/150))

## v0.6.1 (2023-06-15)
### Fixed
- Chat/CreateResponse faking with function_call ([#145](https://github.com/openai-php/client/issues/145))
Expand Down Expand Up @@ -92,7 +104,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## v0.2.0 (2022-11-07)
### Added
- Add `images()` resource to interact with [DALL-E](https://beta.openai.com/docs/api-reference/images)
- Add `images()` resource to interact with [DALL-E](https://platform.openai.com/docs/api-reference/images)

### Fixed
- Parse completions create response with logprobs correctly
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</p>

------
**OpenAI PHP** is a community-maintained PHP API client that allows you to interact with the [Open AI API](https://beta.openai.com/docs/api-reference/introduction). If you or your business relies on this package, it's important to support the developers who have contributed their time and effort to create and maintain this valuable tool:
**OpenAI PHP** is a community-maintained PHP API client that allows you to interact with the [Open AI API](https://platform.openai.com/docs/api-reference/introduction). If you or your business relies on this package, it's important to support the developers who have contributed their time and effort to create and maintain this valuable tool:

- Nuno Maduro: **[github.com/sponsors/nunomaduro](https://github.com/sponsors/nunomaduro)**
- Sandro Gehri: **[github.com/sponsors/gehrisandro](https://github.com/sponsors/gehrisandro)**
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"require": {
"php": "^8.1.0",
"php-http/discovery": "^1.18.1",
"php-http/discovery": "^1.19.0",
"php-http/multipart-stream-builder": "^1.3.0",
"psr/http-client": "^1.0.2",
"psr/http-client-implementation": "^1.0.1",
Expand All @@ -24,15 +24,15 @@
"require-dev": {
"guzzlehttp/guzzle": "^7.7.0",
"guzzlehttp/psr7": "^2.5.0",
"laravel/pint": "^1.10.2",
"nunomaduro/collision": "^7.5.2",
"laravel/pint": "^1.10.3",
"nunomaduro/collision": "^7.7.0",
"pestphp/pest": "dev-develop as 2.6.2",
"pestphp/pest-plugin-arch": "^2.2.0",
"pestphp/pest-plugin-arch": "^2.2.1",
"pestphp/pest-plugin-mock": "^2.0.0",
"pestphp/pest-plugin-type-coverage": "^2.0.0",
"phpstan/phpstan": "^1.10.15",
"phpstan/phpstan": "^1.10.25",
"rector/rector": "^0.16.0",
"symfony/var-dumper": "^6.3.0"
"symfony/var-dumper": "^6.3.1"
},
"autoload": {
"psr-4": {
Expand Down
16 changes: 8 additions & 8 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(private readonly TransporterContract $transporter)
* Given a prompt, the model will return one or more predicted completions, and can also return the probabilities
* of alternative tokens at each position.
*
* @see https://beta.openai.com/docs/api-reference/completions
* @see https://platorm.openai.com/docs/api-reference/completions
*/
public function completions(): Completions
{
Expand All @@ -51,7 +51,7 @@ public function chat(): Chat
/**
* Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
*
* @see https://beta.openai.com/docs/api-reference/embeddings
* @see https://platorm.openai.com/docs/api-reference/embeddings
*/
public function embeddings(): Embeddings
{
Expand All @@ -71,7 +71,7 @@ public function audio(): Audio
/**
* Given a prompt and an instruction, the model will return an edited version of the prompt.
*
* @see https://beta.openai.com/docs/api-reference/edits
* @see https://platorm.openai.com/docs/api-reference/edits
*/
public function edits(): Edits
{
Expand All @@ -81,7 +81,7 @@ public function edits(): Edits
/**
* Files are used to upload documents that can be used with features like Fine-tuning.
*
* @see https://beta.openai.com/docs/api-reference/files
* @see https://platorm.openai.com/docs/api-reference/files
*/
public function files(): Files
{
Expand All @@ -91,7 +91,7 @@ public function files(): Files
/**
* List and describe the various models available in the API.
*
* @see https://beta.openai.com/docs/api-reference/models
* @see https://platorm.openai.com/docs/api-reference/models
*/
public function models(): Models
{
Expand All @@ -101,7 +101,7 @@ public function models(): Models
/**
* Manage fine-tuning jobs to tailor a model to your specific training data.
*
* @see https://beta.openai.com/docs/api-reference/fine-tunes
* @see https://platorm.openai.com/docs/api-reference/fine-tunes
*/
public function fineTunes(): FineTunes
{
Expand All @@ -111,7 +111,7 @@ public function fineTunes(): FineTunes
/**
* Given a input text, outputs if the model classifies it as violating OpenAI's content policy.
*
* @see https://beta.openai.com/docs/api-reference/moderations
* @see https://platorm.openai.com/docs/api-reference/moderations
*/
public function moderations(): Moderations
{
Expand All @@ -121,7 +121,7 @@ public function moderations(): Moderations
/**
* Given a prompt and/or an input image, the model will generate a new image.
*
* @see https://beta.openai.com/docs/api-reference/images
* @see https://platorm.openai.com/docs/api-reference/images
*/
public function images(): Images
{
Expand Down
16 changes: 8 additions & 8 deletions src/Contracts/ClientContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ interface ClientContract
* Given a prompt, the model will return one or more predicted completions, and can also return the probabilities
* of alternative tokens at each position.
*
* @see https://beta.openai.com/docs/api-reference/completions
* @see https://platorm.openai.com/docs/api-reference/completions
*/
public function completions(): CompletionsContract;

Expand All @@ -33,7 +33,7 @@ public function chat(): ChatContract;
/**
* Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
*
* @see https://beta.openai.com/docs/api-reference/embeddings
* @see https://platorm.openai.com/docs/api-reference/embeddings
*/
public function embeddings(): EmbeddingsContract;

Expand All @@ -47,42 +47,42 @@ public function audio(): AudioContract;
/**
* Given a prompt and an instruction, the model will return an edited version of the prompt.
*
* @see https://beta.openai.com/docs/api-reference/edits
* @see https://platorm.openai.com/docs/api-reference/edits
*/
public function edits(): EditsContract;

/**
* Files are used to upload documents that can be used with features like Fine-tuning.
*
* @see https://beta.openai.com/docs/api-reference/files
* @see https://platorm.openai.com/docs/api-reference/files
*/
public function files(): FilesContract;

/**
* List and describe the various models available in the API.
*
* @see https://beta.openai.com/docs/api-reference/models
* @see https://platorm.openai.com/docs/api-reference/models
*/
public function models(): ModelsContract;

/**
* Manage fine-tuning jobs to tailor a model to your specific training data.
*
* @see https://beta.openai.com/docs/api-reference/fine-tunes
* @see https://platorm.openai.com/docs/api-reference/fine-tunes
*/
public function fineTunes(): FineTunesContract;

/**
* Given a input text, outputs if the model classifies it as violating OpenAI's content policy.
*
* @see https://beta.openai.com/docs/api-reference/moderations
* @see https://platorm.openai.com/docs/api-reference/moderations
*/
public function moderations(): ModerationsContract;

/**
* Given a prompt and/or an input image, the model will generate a new image.
*
* @see https://beta.openai.com/docs/api-reference/images
* @see https://platorm.openai.com/docs/api-reference/images
*/
public function images(): ImagesContract;
}
4 changes: 2 additions & 2 deletions src/Contracts/Resources/CompletionsContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface CompletionsContract
/**
* Creates a completion for the provided prompt and parameters
*
* @see https://beta.openai.com/docs/api-reference/completions/create-completion
* @see https://platorm.openai.com/docs/api-reference/completions/create-completion
*
* @param array<string, mixed> $parameters
*/
Expand All @@ -20,7 +20,7 @@ public function create(array $parameters): CreateResponse;
/**
* Creates a streamed completion for the provided prompt and parameters
*
* @see https://beta.openai.com/docs/api-reference/completions/create-completion
* @see https://platorm.openai.com/docs/api-reference/completions/create-completion
*
* @param array<string, mixed> $parameters
* @return StreamResponse<CreateStreamedResponse>
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Resources/EditsContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface EditsContract
/**
* Creates a new edit for the provided input, instruction, and parameters.
*
* @see https://beta.openai.com/docs/api-reference/edits/create
* @see https://platorm.openai.com/docs/api-reference/edits/create
*
* @param array<string, mixed> $parameters
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Contracts/Resources/EmbeddingsContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface EmbeddingsContract
/**
* Creates an embedding vector representing the input text.
*
* @see https://beta.openai.com/docs/api-reference/embeddings/create
* @see https://platorm.openai.com/docs/api-reference/embeddings/create
*
* @param array<string, mixed> $parameters
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Contracts/Resources/FilesContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ interface FilesContract
/**
* Returns a list of files that belong to the user's organization.
*
* @see https://beta.openai.com/docs/api-reference/files/list
* @see https://platorm.openai.com/docs/api-reference/files/list
*/
public function list(): ListResponse;

/**
* Returns information about a specific file.
*
* @see https://beta.openai.com/docs/api-reference/files/retrieve
* @see https://platorm.openai.com/docs/api-reference/files/retrieve
*/
public function retrieve(string $file): RetrieveResponse;

/**
* Returns the contents of the specified file.
*
* @see https://beta.openai.com/docs/api-reference/files/retrieve-content
* @see https://platorm.openai.com/docs/api-reference/files/retrieve-content
*/
public function download(string $file): string;

/**
* Upload a file that contains document(s) to be used across various endpoints/features.
*
* @see https://beta.openai.com/docs/api-reference/files/upload
* @see https://platorm.openai.com/docs/api-reference/files/upload
*
* @param array<string, mixed> $parameters
*/
Expand All @@ -42,7 +42,7 @@ public function upload(array $parameters): CreateResponse;
/**
* Delete a file.
*
* @see https://beta.openai.com/docs/api-reference/files/delete
* @see https://platorm.openai.com/docs/api-reference/files/delete
*/
public function delete(string $file): DeleteResponse;
}
12 changes: 6 additions & 6 deletions src/Contracts/Resources/FineTunesContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ interface FineTunesContract
*
* Response includes details of the enqueued job including job status and the name of the fine-tuned models once complete.
*
* @see https://beta.openai.com/docs/api-reference/fine-tunes/create
* @see https://platorm.openai.com/docs/api-reference/fine-tunes/create
*
* @param array<string, mixed> $parameters
*/
Expand All @@ -24,35 +24,35 @@ public function create(array $parameters): RetrieveResponse;
/**
* List your organization's fine-tuning jobs.
*
* @see https://beta.openai.com/docs/api-reference/fine-tunes/list
* @see https://platorm.openai.com/docs/api-reference/fine-tunes/list
*/
public function list(): ListResponse;

/**
* Gets info about the fine-tune job.
*
* @see https://beta.openai.com/docs/api-reference/fine-tunes/list
* @see https://platorm.openai.com/docs/api-reference/fine-tunes/list
*/
public function retrieve(string $fineTuneId): RetrieveResponse;

/**
* Immediately cancel a fine-tune job.
*
* @see https://beta.openai.com/docs/api-reference/fine-tunes/cancel
* @see https://platorm.openai.com/docs/api-reference/fine-tunes/cancel
*/
public function cancel(string $fineTuneId): RetrieveResponse;

/**
* Get fine-grained status updates for a fine-tune job.
*
* @see https://beta.openai.com/docs/api-reference/fine-tunes/events
* @see https://platorm.openai.com/docs/api-reference/fine-tunes/events
*/
public function listEvents(string $fineTuneId): ListEventsResponse;

/**
* Get streamed fine-grained status updates for a fine-tune job.
*
* @see https://beta.openai.com/docs/api-reference/fine-tunes/events
* @see https://platorm.openai.com/docs/api-reference/fine-tunes/events
*
* @return StreamResponse<RetrieveStreamedResponseEvent>
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Contracts/Resources/ImagesContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface ImagesContract
/**
* Creates an image given a prompt.
*
* @see https://beta.openai.com/docs/api-reference/images/create
* @see https://platorm.openai.com/docs/api-reference/images/create
*
* @param array<string, mixed> $parameters
*/
Expand All @@ -20,7 +20,7 @@ public function create(array $parameters): CreateResponse;
/**
* Creates an edited or extended image given an original image and a prompt.
*
* @see https://beta.openai.com/docs/api-reference/images/create-edit
* @see https://platorm.openai.com/docs/api-reference/images/create-edit
*
* @param array<string, mixed> $parameters
*/
Expand All @@ -29,7 +29,7 @@ public function edit(array $parameters): EditResponse;
/**
* Creates a variation of a given image.
*
* @see https://beta.openai.com/docs/api-reference/images/create-variation
* @see https://platorm.openai.com/docs/api-reference/images/create-variation
*
* @param array<string, mixed> $parameters
*/
Expand Down
6 changes: 3 additions & 3 deletions src/Contracts/Resources/ModelsContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ interface ModelsContract
/**
* Lists the currently available models, and provides basic information about each one such as the owner and availability.
*
* @see https://beta.openai.com/docs/api-reference/models/list
* @see https://platorm.openai.com/docs/api-reference/models/list
*/
public function list(): ListResponse;

/**
* Retrieves a model instance, providing basic information about the model such as the owner and permissioning.
*
* @see https://beta.openai.com/docs/api-reference/models/retrieve
* @see https://platorm.openai.com/docs/api-reference/models/retrieve
*/
public function retrieve(string $model): RetrieveResponse;

/**
* Delete a fine-tuned model. You must have the Owner role in your organization.
*
* @see https://beta.openai.com/docs/api-reference/fine-tunes/delete-model
* @see https://platorm.openai.com/docs/api-reference/fine-tunes/delete-model
*/
public function delete(string $model): DeleteResponse;
}
2 changes: 1 addition & 1 deletion src/Contracts/Resources/ModerationsContract.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface ModerationsContract
/**
* Classifies if text violates OpenAI's Content Policy.
*
* @see https://beta.openai.com/docs/api-reference/moderations/create
* @see https://platorm.openai.com/docs/api-reference/moderations/create
*
* @param array<string, mixed> $parameters
*/
Expand Down
Loading

0 comments on commit 1b4e9a4

Please sign in to comment.