You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://packagist.org/packages/lucianotonet/groq-laravel)[](https://packagist.org/packages/lucianotonet/groq-laravel)[](https://packagist.org/packages/lucianotonet/groq-laravel)[](https://packagist.org/packages/lucianotonet/groq-laravel)[](https://packagist.org/packages/lucianotonet/groq-laravel)
6
6
7
-
Groq Laravel é um pacote poderoso para integração entre suas aplicações Laravel a API da[Groq](https://groq.com/), permitindo que você aproveite velocidades ultra-rápidas de inferência de IA com alguns dos LLMs mais populares, como o Llama3.1 ou Mixtral.
7
+
Groq Laravel is a powerful package for integrating your Laravel applications with the[Groq](https://groq.com/) API, allowing you to leverage ultra-fast AI inference speeds with some of the most popular LLMs, such as Llama3.1 or Mixtral.
8
8
9
9
## Features
10
10
11
-
-**Interface Simples e Intuitiva:**Interaja com a API Groq usando a facade`Groq`, simplificando o acesso às funcionalidades de chat, tradução e transcrição de áudio e chamadas à funções.
12
-
-**Tratamento Robusto de Erros:**Gerencie eficientemente erros de comunicação e respostas da API Groq, capturando exceções específicas e fornecendo mensagens informativas.
13
-
-**Configuração Flexível:**Defina várias instâncias da API Groq, personalize timeouts de requisição, configure opções de cache e ajuste o comportamento do pacote conforme suas necessidades.
14
-
-**Exemplos Práticos Detalhados:** Explore exemplos de código que demonstram como usar o pacote Groq Laravel em cenários reais, incluindo chatbots, transcrição de áudio e muito mais.
15
-
-**Testes Abrangentes:**Garanta a qualidade e confiabilidade do pacote com um conjunto de testes que cobrem aspectos de integração, testes unitários e configuração.
11
+
-**Simple and Intuitive Interface:**Interact with the Groq API using the`Groq` facade, simplifying access to chat, translation, audio transcription, function call, and image analysis functionalities.
12
+
-**Robust Error Handling:**Efficiently manage communication errors and responses from the Groq API, capturing specific exceptions and providing informative messages.
13
+
-**Flexible Configuration:**Define multiple Groq API instances, customize request timeouts, configure caching options, and adjust the package's behavior to suit your needs.
14
+
-**Detailed Practical Examples:** Explore code examples that demonstrate how to use the Groq Laravel package in real-world scenarios, including chatbots, audio transcription, and more.
15
+
-**Comprehensive Testing:**Ensure the quality and reliability of the package with a suite of tests covering integration, unit testing, and configuration.
3. Configure suas credenciais da API Groq no arquivo`.env`:
31
+
3. Configure your Groq API credentials in the`.env` file:
32
32
33
33
```
34
34
GROQ_API_KEY=your_api_key_here
35
35
GROQ_API_BASE=https://api.groq.com/openai/v1
36
36
```
37
37
38
-
4. (Opcional) Configure o cache definindo as seguintes variáveis de ambiente no arquivo `.env`:
38
+
4. (Optional) Configure caching by setting the following environment variables in the `.env` file:
39
39
40
40
```
41
41
GROQ_CACHE_DRIVER=file
42
42
GROQ_CACHE_TTL=3600
43
43
```
44
44
45
-
5.Importe a facade `Groq`em suas classes:
45
+
5.Import the `Groq`facade into your classes:
46
46
47
47
```php
48
48
use LucianoTonet\GroqLaravel\Facades\Groq;
49
49
```
50
50
51
-
## Uso
51
+
## Usage
52
52
53
-
Aqui está um exemplo simples de como criar uma conclusão de chat:
53
+
Here is a simple example of how to create a chat completion:
54
54
55
55
```php
56
56
$response = Groq::chat()->completions()->create([
57
57
'model' => 'llama-3.1-8b-instant',
58
58
'messages' => [
59
-
['role' => 'user', 'content' => 'Olá, como você está?'],
59
+
['role' => 'user', 'content' => 'Hello, how are you?'],
60
60
],
61
61
]);
62
62
```
63
63
64
-
## Tratamento de Erros
64
+
## Error Handling
65
65
66
-
O pacote Groq Laravel facilita o tratamento de erros que podem ocorrer ao interagir com a API Groq. Use um bloco `try-catch`para capturar e gerenciar exceções:
66
+
The Groq Laravel package makes it easy to handle errors that may occur when interacting with the Groq API. Use a `try-catch`block to capture and manage exceptions:
67
67
68
68
```php
69
69
try {
@@ -72,37 +72,79 @@ try {
72
72
// ...
73
73
]);
74
74
} catch (GroqException $e) {
75
-
Log::error('Erro na API Groq: ' . $e->getMessage());
76
-
abort(500, 'Erro ao processar sua solicitação.');
75
+
Log::error('Error in Groq API: ' . $e->getMessage());
76
+
abort(500, 'Error processing your request.');
77
77
}
78
78
```
79
79
80
-
## Testes
80
+
## Vision API
81
81
82
-
Os testes são uma parte essencial do desenvolvimento de software de qualidade. O pacote Groq Laravel inclui uma suíte de testes que cobre integração, unidade e configuração. Para executar os testes, siga os passos abaixo:
82
+
The Groq Laravel package also provides access to the Groq Vision API, allowing you to analyze images and extract information from them.
83
83
84
-
1.**Instale as dependências do projeto:**
84
+
**Example of use with image URL:**
85
+
86
+
```php
87
+
use LucianoTonet\GroqLaravel\Facades\Groq;
88
+
89
+
// ...
90
+
91
+
$imageUrl = 'https://example.com/image.jpg'; // Replace with your image URL
- The Vision API requires a model compatible with image analysis, such as `llava-v1.5-7b-4096-preview`. You can configure the default model for Vision in the `config/groq.php` configuration file.
120
+
- The Vision API is an experimental feature and may not meet expectations, as well as not having long-term support.
121
+
122
+
## Testing
123
+
124
+
Testing is an essential part of quality software development. The Groq Laravel package includes a test suite that covers integration, unit, and configuration. To run the tests, follow the steps below:
125
+
126
+
1.**Install the project dependencies:**
85
127
86
128
```bash
87
129
composer install
88
130
```
89
131
90
-
2.**Execute os testes:**
132
+
2.**Run the tests:**
91
133
92
134
```bash
93
135
vendor/bin/phpunit ./tests/Feature
94
136
```
95
137
96
-
ou individualmente:
138
+
or individually:
97
139
98
140
```bash
99
141
vendor/bin/phpunit ./tests/Feature/FacadeTest.php
100
142
```
101
143
102
-
## Contribuindo
144
+
## Contributing
103
145
104
-
Contribuições são bem-vindas! Siga as diretrizes descritas no arquivo[CONTRIBUTING.md](CONTRIBUTING.md).
146
+
Contributions are welcome! Follow the guidelines described in the[CONTRIBUTING.md](CONTRIBUTING.md) file.
105
147
106
-
## Licença
148
+
## License
107
149
108
-
Este pacote é um software de código aberto licenciado sob a [licença MIT](LICENSE).
150
+
This package is open-source software licensed under the [MIT license](LICENSE).
0 commit comments