Skip to content

Commit b2500a8

Browse files
committed
chore: Update Groq facade for simplified access to GroqPHP library methods
1 parent aee513a commit b2500a8

File tree

1 file changed

+72
-8
lines changed

1 file changed

+72
-8
lines changed

src/Facades/Groq.php

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,89 @@
44

55
use Illuminate\Support\Facades\Facade;
66
use LucianoTonet\GroqPHP\Groq as GroqPHP;
7+
use LucianoTonet\GroqPHP\GroqException;
78

9+
/**
10+
* Class Groq
11+
* This class serves as a facade for the GroqPHP library, providing a simplified interface
12+
* for accessing Groq API methods within a Laravel application.
13+
*/
814
class Groq extends Facade
915
{
10-
protected static function getFacadeAccessor()
16+
/**
17+
* Retrieve the class name of the GroqPHP instance.
18+
*
19+
* @return string The class name of the GroqPHP instance.
20+
*/
21+
protected static function getFacadeAccessor(): string
1122
{
1223
return GroqPHP::class;
1324
}
1425

15-
protected $apiKey;
16-
protected $options;
26+
/**
27+
* Initiate a chat session with the Groq API.
28+
*
29+
* @return \LucianoTonet\GroqPHP\Chat An instance of the Chat class for managing chat sessions.
30+
* @throws GroqException
31+
*/
32+
public static function chat(): \LucianoTonet\GroqPHP\Chat
33+
{
34+
return app(GroqPHP::class)->chat();
35+
}
36+
37+
/**
38+
* Initiate an audio session with the Groq API.
39+
*
40+
* @return \LucianoTonet\GroqPHP\Audio An instance of the Audio class for managing audio sessions.
41+
* @throws GroqException
42+
*/
43+
public static function audio(): \LucianoTonet\GroqPHP\Audio
44+
{
45+
return app(GroqPHP::class)->audio();
46+
}
47+
48+
/**
49+
* Retrieve the list of available models from the Groq API.
50+
*
51+
* @return \LucianoTonet\GroqPHP\Models An instance of the Models class containing available models.
52+
* @throws GroqException
53+
*/
54+
public static function models(): \LucianoTonet\GroqPHP\Models
55+
{
56+
return app(GroqPHP::class)->models();
57+
}
58+
59+
/**
60+
* Set configuration options for the Groq instance.
61+
*
62+
* @param array $options An associative array of options to configure the Groq instance.
63+
* @return void
64+
* @throws GroqException
65+
*/
66+
public static function setOptions(array $options): void
67+
{
68+
app(GroqPHP::class)->setOptions($options);
69+
}
1770

18-
public function __construct($apiKey = null, $options = [])
71+
/**
72+
* Retrieve the base URL for the Groq API.
73+
*
74+
* @return string The base URL used for API requests.
75+
* @throws GroqException
76+
*/
77+
public static function baseUrl(): string
1978
{
20-
$this->apiKey = $apiKey;
21-
$this->options = $options;
79+
return app(GroqPHP::class)->baseUrl();
2280
}
2381

24-
public function chat()
82+
/**
83+
* Retrieve the API key used for authentication with the Groq API.
84+
*
85+
* @return string The API key for authenticating requests.
86+
* @throws GroqException
87+
*/
88+
public static function apiKey(): string
2589
{
26-
return (new GroqPHP($this->apiKey, $this->options))->chat();
90+
return app(GroqPHP::class)->apiKey();
2791
}
2892
}

0 commit comments

Comments
 (0)