4
4
5
5
use Illuminate \Support \Facades \Facade ;
6
6
use LucianoTonet \GroqPHP \Groq as GroqPHP ;
7
+ use LucianoTonet \GroqPHP \GroqException ;
7
8
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
+ */
8
14
class Groq extends Facade
9
15
{
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
11
22
{
12
23
return GroqPHP::class;
13
24
}
14
25
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
+ }
17
70
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
19
78
{
20
- $ this ->apiKey = $ apiKey ;
21
- $ this ->options = $ options ;
79
+ return app (GroqPHP::class)->baseUrl ();
22
80
}
23
81
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
25
89
{
26
- return ( new GroqPHP ( $ this -> apiKey , $ this -> options ))-> chat ();
90
+ return app ( GroqPHP::class)-> apiKey ();
27
91
}
28
92
}
0 commit comments