|
1 | 1 | # Groq Laravel
|
2 | 2 |
|
3 |
| -Groq Laravel is a powerful package that provides seamless integration between Laravel applications and the Groq API, enabling you to leverage the capabilities of language models (LLMs) like LLaMa directly within your PHP projects. |
| 3 | +Groq Laravel é um pacote poderoso que fornece integração perfeita entre aplicações Laravel e a API Groq, permitindo que você aproveite a velocidade ultra-rápida de inferência de IA com alguns dos LLMs abertos mais populares, como o Llama3.1 ou Mixtral, em seus projetos PHP. |
4 | 4 |
|
5 | 5 | ## Features
|
6 | 6 |
|
7 |
| -- **Simple and Intuitive Interface:** Interact with the Groq API using the `Groq` facade, simplifying access to chat, audio, and model functionalities. |
8 |
| -- **Robust Error Handling:** Efficiently handle communication errors and Groq API responses by capturing specific exceptions and providing informative messages. |
9 |
| -- **Flexible Configuration:** Define multiple Groq API instances, customize request timeouts, configure cache options, and adjust the package behavior to your needs. |
10 |
| -- **Detailed Practical Examples:** Explore code examples that demonstrate how to use the Groq Laravel package in real scenarios, including chatbots, audio transcription, and more. |
11 |
| -- **Comprehensive Testing:** Ensure the package's quality and reliability with a suite of tests covering integration, unit testing, and configuration aspects. |
| 7 | +- **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. |
| 8 | +- **Tratamento Robusto de Erros:** Gerencie eficientemente erros de comunicação e respostas da API Groq, capturando exceções específicas e fornecendo mensagens informativas. |
| 9 | +- **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. |
| 10 | +- **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. |
| 11 | +- **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. |
12 | 12 |
|
13 |
| -## Installation |
| 13 | +## Instalação |
14 | 14 |
|
15 |
| -1. Install the package via Composer: |
| 15 | +1. Instale o pacote via Composer: |
16 | 16 |
|
17 |
| -```bash |
18 |
| -composer require lucianotonet/groq-laravel |
19 |
| -``` |
| 17 | + ```bash |
| 18 | + composer require lucianotonet/groq-laravel |
| 19 | + ``` |
20 | 20 |
|
21 |
| -2. Publish the configuration file: |
| 21 | +2. Publique o arquivo de configuração: |
22 | 22 |
|
23 |
| -```bash |
24 |
| -php artisan vendor:publish --provider="LucianoTonet\GroqLaravel\GroqServiceProvider" |
25 |
| -``` |
| 23 | + ```bash |
| 24 | + php artisan vendor:publish --provider="LucianoTonet\GroqLaravel\GroqServiceProvider" |
| 25 | + ``` |
26 | 26 |
|
27 |
| -3. Configure your Groq API credentials in the `.env` file: |
| 27 | +3. Configure suas credenciais da API Groq no arquivo `.env`: |
28 | 28 |
|
29 |
| -``` |
30 |
| -GROQ_API_KEY=your_api_key_here |
31 |
| -GROQ_API_BASE=https://api.groq.com/openai/v1 |
32 |
| -``` |
| 29 | + ``` |
| 30 | + GROQ_API_KEY=your_api_key_here |
| 31 | + GROQ_API_BASE=https://api.groq.com/openai/v1 |
| 32 | + ``` |
33 | 33 |
|
34 |
| -4. (Optional) Configure caching by defining the following environment variables in the `.env` file: |
| 34 | +4. (Opcional) Configure o cache definindo as seguintes variáveis de ambiente no arquivo `.env`: |
35 | 35 |
|
36 |
| -``` |
37 |
| -GROQ_CACHE_DRIVER=file |
38 |
| -GROQ_CACHE_TTL=3600 |
39 |
| -``` |
| 36 | + ``` |
| 37 | + GROQ_CACHE_DRIVER=file |
| 38 | + GROQ_CACHE_TTL=3600 |
| 39 | + ``` |
40 | 40 |
|
41 |
| -5. Import the `Groq` facade in your classes: |
| 41 | +5. Importe a facade `Groq` em suas classes: |
42 | 42 |
|
43 |
| -```php |
44 |
| -use LucianoTonet\GroqLaravel\Facades\Groq; |
45 |
| -``` |
| 43 | + ```php |
| 44 | + use LucianoTonet\GroqLaravel\Facades\Groq; |
| 45 | + ``` |
46 | 46 |
|
47 |
| -## Usage |
| 47 | +## Uso |
48 | 48 |
|
49 |
| -Here's a simple example of creating a chat completion: |
| 49 | +Aqui está um exemplo simples de como criar uma conclusão de chat: |
50 | 50 |
|
51 | 51 | ```php
|
52 |
| -$response = Groq::chat()->completion()->create([ |
| 52 | +$response = Groq::chat()->completions()->create([ |
53 | 53 | 'model' => 'llama-3.1-8b-instant',
|
54 | 54 | 'messages' => [
|
55 |
| - ['role' => 'user', 'content' => 'Hello, how are you?'], |
| 55 | + ['role' => 'user', 'content' => 'Olá, como você está?'], |
56 | 56 | ],
|
57 | 57 | ]);
|
58 | 58 | ```
|
59 | 59 |
|
60 |
| -Refer to the [documentation](docs/index.md) for more detailed information on available methods, configuration options, and practical examples. |
| 60 | +## Tratamento de Erros |
| 61 | + |
| 62 | +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: |
| 63 | + |
| 64 | +```php |
| 65 | +try { |
| 66 | + $response = Groq::chat()->completions()->create([ |
| 67 | + 'model' => 'llama-3.1-8b-instant', |
| 68 | + // ... |
| 69 | + ]); |
| 70 | +} catch (GroqException $e) { |
| 71 | + Log::error('Erro na API Groq: ' . $e->getMessage()); |
| 72 | + abort(500, 'Erro ao processar sua solicitação.'); |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +## Testes |
| 77 | + |
| 78 | +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: |
| 79 | + |
| 80 | +1. **Instale as dependências do projeto:** |
| 81 | + |
| 82 | + ```bash |
| 83 | + composer install |
| 84 | + ``` |
| 85 | + |
| 86 | +2. **Execute os testes:** |
| 87 | + |
| 88 | + ```bash |
| 89 | + vendor/bin/phpunit ./tests/Feature |
| 90 | + ``` |
| 91 | + |
| 92 | + ou individualmente: |
| 93 | + |
| 94 | + ```bash |
| 95 | + vendor/bin/phpunit ./tests/Feature/FacadeTest.php |
| 96 | + ``` |
61 | 97 |
|
62 |
| -## Contributing |
| 98 | +## Contribuindo |
63 | 99 |
|
64 |
| -Contributions are welcome! Please follow the guidelines outlined in the [CONTRIBUTING.md](CONTRIBUTING.md) file. |
| 100 | +Contribuições são bem-vindas! Siga as diretrizes descritas no arquivo [CONTRIBUTING.md](CONTRIBUTING.md). |
65 | 101 |
|
66 |
| -## License |
| 102 | +## Licença |
67 | 103 |
|
68 |
| -This package is open-source software licensed under the [MIT license](LICENSE). |
| 104 | +Este pacote é um software de código aberto licenciado sob a [licença MIT](LICENSE). |
0 commit comments