File tree Expand file tree Collapse file tree 2 files changed +59
-0
lines changed
Expand file tree Collapse file tree 2 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace GrokPHP \Laravel \Facades ;
4+
5+ use Illuminate \Support \Facades \Facade ;
6+
7+ /**
8+ * @method static array chat(array $messages, \GrokPHP\Client\Config\ChatOptions $options)
9+ */
10+ class GrokAI extends Facade
11+ {
12+ protected static function getFacadeAccessor (): string
13+ {
14+ return 'grok-ai ' ;
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace GrokPHP \Laravel \Providers ;
4+
5+ use Illuminate \Support \ServiceProvider ;
6+ use GrokPHP \Client \Clients \GrokClient ;
7+ use GrokPHP \Client \Config \GrokConfig ;
8+ use GrokPHP \Client \Enums \DefaultConfig ;
9+
10+ class GrokServiceProvider extends ServiceProvider
11+ {
12+ public function register (): void
13+ {
14+ $ this ->mergeConfigFrom (__DIR__ . '/../../config/grok.php ' , 'grok ' );
15+
16+ $ this ->app ->singleton (GrokConfig::class, function () {
17+ return new GrokConfig (
18+ apiKey: config ('grok.api_key ' ),
19+ baseUri: config ('grok.base_uri ' , DefaultConfig::BASE_URI ->value ),
20+ timeout: (int ) config ('grok.timeout ' , (int ) DefaultConfig::TIMEOUT ->value ),
21+ );
22+ });
23+
24+ $ this ->app ->singleton (GrokClient::class, function ($ app ) {
25+ return new GrokClient ($ app ->make (GrokConfig::class));
26+ });
27+
28+ $ this ->app ->alias (GrokClient::class, 'grok-ai ' );
29+ }
30+
31+ public function boot (): void
32+ {
33+ if ($ this ->app ->runningInConsole ()) {
34+ $ this ->commands ([
35+ \GrokPHP \Laravel \Commands \InstallGrokCommand::class,
36+ ]);
37+
38+ $ this ->publishes ([
39+ __DIR__ . '/../Config/grok.php ' => config_path ('grok.php ' ),
40+ ], 'config ' );
41+ }
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments