Skip to content

Commit 11639a5

Browse files
committed
Add Vision API functionality
- Added 'vision' configuration for Vision API model and max tokens in the `config/groq.php` file. - Included examples of analyzing images with the Groq Vision API using URLs and local image files. - Provided information on configuring the default model for Vision in the `config/groq.php` file. - Mentioned that the Vision API is experimental and may not have long-term support.
1 parent 9868df6 commit 11639a5

File tree

8 files changed

+95
-40
lines changed

8 files changed

+95
-40
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ yarn-error.log
1818
/.idea
1919
/.vscode
2020
composer.lock
21-
proj2md.py
21+
proj2md.py
22+
CHANGELOG_GEN.sh

CHANGELOG.md

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,29 @@
11
# Changelog
22

3-
Todas as mudanças notáveis neste projeto serão documentadas neste arquivo.
43

5-
O formato é baseado em [Keep a Changelog](https://keepachangelog.com/pt-BR/1.0.0/),
6-
e este projeto adere ao [Versionamento Semântico](https://semver.org/lang/pt-BR/).
7-
8-
## [0.0.8] - 2024-03-XX
9-
10-
### Adicionado
11-
- Novo arquivo `.env.example` com exemplos de configuração da API Groq.
12-
- Suporte para configuração de múltiplas instâncias da API Groq.
13-
- Novos métodos de validação em requisições para facilitar a integração da API.
14-
- Implementação de controle de taxa para evitar abusos da API.
15-
- Adição de testes abrangentes, incluindo testes de integração, unitários e de configuração.
16-
- Novo middleware `GroqRateLimiter` para limitar requisições à API.
17-
- Arquivos de linguagem para suporte a internacionalização de mensagens de erro.
18-
19-
### Alterado
20-
- Atualização do README.md com documentação simplificada e exemplos práticos de uso.
21-
- Refatoração do código para melhorar a legibilidade e manutenibilidade.
22-
- Expansão da configuração com variáveis para ajuste de modelo e limites de taxa.
23-
- Atualização da fachada Groq para acesso simplificado aos métodos da biblioteca GroqPHP.
24-
- Melhoria na flexibilidade de configuração da integração com a API Groq.
25-
26-
### Corrigido
27-
- Correção de problemas de compatibilidade com diferentes versões do Laravel.
28-
29-
### Segurança
30-
- Implementação de melhores práticas de segurança na manipulação de chaves de API.
31-
32-
## [0.0.7] - 2024-XX-XX
33-
34-
### Adicionado
35-
- Versão inicial do pacote Groq Laravel.
36-
- Integração básica com a API Groq.
37-
- Configuração inicial do pacote.
38-
39-
[0.0.8]: https://github.com/lucianotonet/groq-laravel/compare/v0.0.7...v0.0.8
40-
[0.0.7]: https://github.com/lucianotonet/groq-laravel/releases/tag/v0.0.7
4+
*🚧 Next Relesase*
5+
* [03/09/2024](https://github.com/lucianotonet/groq-laravel/commits/9868df67da994a011c573f4cd037d8a2eafb52cd) Atualiza links de badge para HTTPS no README
6+
* [03/09/2024](https://github.com/lucianotonet/groq-laravel/commits/6515f555cd92cd79d2c0bdfe8c002f6b4859d933) Atualiza badges no README para incluir versões instáveis
7+
8+
## v0.0.8
9+
* [03/09/2024](https://github.com/lucianotonet/groq-laravel/commits/3505dc510883ed34fae610524292cbb014750aa8) Update README.md
10+
* [03/09/2024](https://github.com/lucianotonet/groq-laravel/commits/6c36e8ff9f953ce3eead317b1b40865c065be012) Adiciona documentação e melhora a configuração do Groq Laravel
11+
* [02/09/2024](https://github.com/lucianotonet/groq-laravel/commits/62af4e4ba5674ffb13cc5ae48cfab0c1aad8fedc) Atualiza integração do Groq com novas funcionalidades
12+
* [29/07/2024](https://github.com/lucianotonet/groq-laravel/commits/c078490e3b5c20c815097c8d247b9541b8d25426) docs: Update README to reflect changes
13+
* [29/07/2024](https://github.com/lucianotonet/groq-laravel/commits/959a5cf1d8c393b95b300c47384a58a5c4e284e5) feat: Integrate GROQ API with configuration flexibility
14+
* [29/07/2024](https://github.com/lucianotonet/groq-laravel/commits/b2500a8e4af9505222db7b4be54e63de81e57011) chore: Update Groq facade for simplified access to GroqPHP library methods
15+
* [29/07/2024](https://github.com/lucianotonet/groq-laravel/commits/aee513a150845068e062b5e7bf707bee6bddf08b) chore: Update composer.json description and version
16+
* [20/04/2024](https://github.com/lucianotonet/groq-laravel/commits/049dac61eff527a6dc16c303e513720475732fb8) Refactored code to improve readability and maintainability.
17+
18+
## v0.0.4
19+
* [20/04/2024](https://github.com/lucianotonet/groq-laravel/commits/cf503b1326cd7126eda08acda4323e7b2bbb994e) Refactored code to improve readability and maintainability.
20+
21+
## v0.0.3
22+
* [30/03/2024](https://github.com/lucianotonet/groq-laravel/commits/5caedeae2e250fb2287e9aa47ac4c1ad1b673d37) Udpate version dependency
23+
* [28/03/2024](https://github.com/lucianotonet/groq-laravel/commits/4b7e53f25e9918c512d0b6cdeec833bb3d880d65) Udpate readme
24+
25+
## v0.0.2
26+
* [28/03/2024](https://github.com/lucianotonet/groq-laravel/commits/9c67dbf59149b8de7bee19be83aebe7fabd9617c) Udpate readme
27+
* [28/03/2024](https://github.com/lucianotonet/groq-laravel/commits/59993d56c3ee35f97ec644b165ae2c0c502f26ba) Add basic stuff
28+
* [27/03/2024](https://github.com/lucianotonet/groq-laravel/commits/9bdbe7592acaa19b960ffc359fe2ee8c52b7143f) WIP
29+
* [22/03/2024](https://github.com/lucianotonet/groq-laravel/commits/0b5eb656b3930880654e0562f56859554b5cf15e) First commit. Add base skeleton.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Groq Laravel
22

3+
![Groq Laravel](./docs/art.png)
4+
35
[![Latest Stable Version](https://poser.pugx.org/lucianotonet/groq-laravel/v)](https://packagist.org/packages/lucianotonet/groq-laravel) [![Total Downloads](https://poser.pugx.org/lucianotonet/groq-laravel/downloads)](https://packagist.org/packages/lucianotonet/groq-laravel) [![Latest Unstable Version](https://poser.pugx.org/lucianotonet/groq-laravel/v/unstable)](https://packagist.org/packages/lucianotonet/groq-laravel) [![License](https://poser.pugx.org/lucianotonet/groq-laravel/license)](https://packagist.org/packages/lucianotonet/groq-laravel) [![PHP Version Require](https://poser.pugx.org/lucianotonet/groq-laravel/require/php)](https://packagist.org/packages/lucianotonet/groq-laravel)
46

57
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.

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "lucianotonet/groq-laravel",
33
"description": "Laravel package to access Groq REST API",
44
"type": "library",
5-
"version": "0.0.8",
5+
"version": "0.0.9",
66
"license": "MIT",
77
"authors": [
88
{
@@ -12,7 +12,7 @@
1212
],
1313
"require": {
1414
"php": "^8.1",
15-
"lucianotonet/groq-php": "^0.0.8",
15+
"lucianotonet/groq-php": "^0.0.9",
1616
"illuminate/support": "*",
1717
"illuminate/contracts": "*"
1818
},

config/groq.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,9 @@
2525
],
2626

2727
'rate_limit' => env('GROQ_RATE_LIMIT', 60),
28+
29+
'vision' => [
30+
'model' => env('GROQ_VISION_MODEL', 'llava-v1.5-7b-4096-preview'),
31+
'max_tokens' => env('GROQ_VISION_MAX_TOKENS', 300),
32+
],
2833
];

docs/art.png

18.4 KB
Loading

docs/practical-examples.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,51 @@ try {
116116
}
117117
```
118118

119+
## 6. Analyzing an Image with Vision
120+
121+
To analyze an image with the Groq Vision API, you can use the `vision()` method of the `Groq` facade. This method requires two parameters:
122+
123+
- `$imagePathOrUrl`: The path to the local image file or the URL of the image.
124+
- `$prompt`: The question or context for the image analysis.
125+
126+
**Example of use with image URL:**
127+
128+
```php
129+
use LucianoTonet\GroqLaravel\Facades\Groq;
130+
131+
// ...
132+
133+
$imageUrl = 'https://example.com/image.jpg'; // Replace with your image URL
134+
$prompt = 'Describe the image';
135+
136+
$response = Groq::vision()->analyze($imageUrl, $prompt);
137+
138+
$imageDescription = $response['choices'][0]['message']['content'];
139+
140+
// ... do something with the image description
141+
```
142+
143+
**Example of use with local image file:**
144+
145+
```php
146+
use LucianoTonet\GroqLaravel\Facades\Groq;
147+
148+
// ...
149+
150+
$imagePath = '/path/to/your/image.jpg'; // Replace with the actual path
151+
$prompt = 'What do you see in this image?';
152+
153+
$response = Groq::vision()->analyze($imagePath, $prompt);
154+
155+
$imageAnalysis = $response['choices'][0]['message']['content'];
156+
157+
// ... do something with the image analysis
158+
```
159+
160+
**Remember:**
161+
- 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.
162+
- The Vision API is an experimental feature and may not meet expectations, as well as not having long-term support.
163+
164+
## 7. More examples
165+
119166
These are just a few examples of how to use the Groq Laravel package. Explore the documentation and experiment with different approaches to integrate the Groq API into your projects.

src/Facades/Groq.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,15 @@ public static function apiKey(): string
8989
{
9090
return app(GroqPHP::class)->apiKey();
9191
}
92+
93+
/**
94+
* Iniciar uma sessão de visão com a API Groq.
95+
*
96+
* @return \LucianoTonet\GroqPHP\Vision Uma instância da classe Vision para gerenciar sessões de visão.
97+
* @throws GroqException
98+
*/
99+
public static function vision(): \LucianoTonet\GroqPHP\Vision
100+
{
101+
return app(GroqPHP::class)->vision();
102+
}
92103
}

0 commit comments

Comments
 (0)