Skip to content

Commit

Permalink
feat: Add OpenAI facade (#667)
Browse files Browse the repository at this point in the history
Co-authored-by: Deeka Wong <[email protected]>
  • Loading branch information
huangdijia and huangdijia committed Jun 7, 2024
1 parent e3d2156 commit d84763f
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/Facade/OpenAI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

declare(strict_types=1);
/**
* This file is part of friendsofhyperf/components.
*
* @link https://github.com/friendsofhyperf/components
* @document https://github.com/friendsofhyperf/components/blob/main/README.md
* @contact [email protected]
*/

namespace FriendsOfHyperf\OpenAi\Facade;

use Hyperf\Context\ApplicationContext;
use OpenAI\Contracts\ClientContract;

/**
* @method static \OpenAI\Resources\Assistants assistants()
* @method static \OpenAI\Resources\Audio audio()
* @method static \OpenAI\Resources\Batches batches()
* @method static \OpenAI\Resources\Chat chat()
* @method static \OpenAI\Resources\Completions completions()
* @method static \OpenAI\Resources\Embeddings embeddings()
* @method static \OpenAI\Resources\Edits edits()
* @method static \OpenAI\Resources\Files files()
* @method static \OpenAI\Resources\FineTunes fineTunes()
* @method static \OpenAI\Resources\Images images()
* @method static \OpenAI\Resources\Models models()
* @method static \OpenAI\Resources\Moderations moderations()
* @method static \OpenAI\Resources\Threads threads()
* @method static \OpenAI\Resources\VectorStores vectorStores()
*/
class OpenAI
{
public static function __callStatic($name, $arguments)
{
$instance = ApplicationContext::getContainer()->get(ClientContract::class);

return $instance->{$name}(...$arguments);
}
}

0 comments on commit d84763f

Please sign in to comment.