Skip to content

Commit b48ff42

Browse files
committed
feat: update batch processing configuration and enhance validation
- Added support for JSONL file format in batch processing, restricting file extensions to `.jsonl`. - Updated `composer.json` to require `groq-php` version `^1.3`. - Enhanced validation for batch processing, including allowed MIME types and content validation. - Updated `.env.example` to include new configuration options for batch processing.
1 parent 85a3a38 commit b48ff42

File tree

5 files changed

+62
-3
lines changed

5 files changed

+62
-3
lines changed

.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Groq API Configuration
22
GROQ_API_KEY=your-api-key-here
3-
GROQ_MODEL=llama-3.1-8b-instant
43
GROQ_API_BASE=https://api.groq.com/openai/v1
4+
GROQ_MODEL=llama-3.1-8b-instant
55
GROQ_TIMEOUT=30
66

77
# Cache Configuration
@@ -28,6 +28,7 @@ GROQ_VISION_MAX_TOKENS=300
2828
GROQ_BATCH_COMPLETION_WINDOW=5m
2929
GROQ_BATCH_MAX_SIZE=20
3030
GROQ_BATCH_AUTO_PROCESS=true
31+
GROQ_BATCH_VALIDATE_CONTENT=true
3132

3233
# Speech Configuration
3334
GROQ_SPEECH_MODEL=playai-tts

CHANGELOG.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,36 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6767
* [28/03/2024](https://github.com/lucianotonet/groq-laravel/commits/9c67dbf59149b8de7bee19be83aebe7fabd9617c) Udpate readme
6868
* [28/03/2024](https://github.com/lucianotonet/groq-laravel/commits/59993d56c3ee35f97ec644b165ae2c0c502f26ba) Add basic stuff
6969
* [27/03/2024](https://github.com/lucianotonet/groq-laravel/commits/9bdbe7592acaa19b960ffc359fe2ee8c52b7143f) WIP
70-
* [22/03/2024](https://github.com/lucianotonet/groq-laravel/commits/0b5eb656b3930880654e0562f56859554b5cf15e) First commit. Add base skeleton.
70+
* [22/03/2024](https://github.com/lucianotonet/groq-laravel/commits/0b5eb656b3930880654e0562f56859554b5cf15e) First commit. Add base skeleton.
71+
72+
## [1.3.0] - 2025-08-04
73+
74+
### Breaking Changes in Files/Batches Module
75+
- Updated JSONL file format requirements for batch processing to match groq-php v1.3.0
76+
- Restricted file extensions to `.jsonl` only (removed support for `.json`, `.txt`, `.ndjson`)
77+
- Added stricter validation for file contents and structure
78+
79+
### Changed
80+
- Updated groq-php dependency to ^1.3.0
81+
- Updated Files API validation to properly handle 'batch' purpose
82+
- Added support for additional MIME types in batch processing
83+
- Updated JSONL file format documentation and examples
84+
- Improved file validation in batch processing
85+
- Enhanced error messages for file validation
86+
87+
### Added
88+
- Support for audio transcription and translation in batch processing
89+
- Support for chat completions in batch processing
90+
- New examples for batch processing with JSONL files
91+
- Improved error messages for file validation
92+
93+
### Migration Guide for Files/Batches Module
94+
If you are using the Files/Batches module, you will need to:
95+
1. Update your JSONL files to include required fields:
96+
- `custom_id`: Your unique identifier for tracking
97+
- `method`: Must be "POST"
98+
- `url`: One of: /v1/chat/completions, /v1/audio/transcriptions, or /v1/audio/translations
99+
- `body`: Request parameters matching the endpoint format
100+
2. Ensure all files use `.jsonl` extension
101+
3. Update file content to match new validation requirements
102+
4. Review the updated documentation for complete format specifications

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"php": "^8.1",
1414
"illuminate/support": "*",
1515
"illuminate/contracts": "*",
16-
"lucianotonet/groq-php": "^1.2"
16+
"lucianotonet/groq-php": "^1.3"
1717
},
1818
"require-dev": {
1919
"orchestra/testbench": "^6.0|^7.0|^8.0",

config/groq.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@
9898
'completion_window' => env('GROQ_BATCH_COMPLETION_WINDOW', '5m'),
9999
'max_batch_size' => env('GROQ_BATCH_MAX_SIZE', 20),
100100
'auto_process' => env('GROQ_BATCH_AUTO_PROCESS', true),
101+
'allowed_extensions' => ['.jsonl'], // Apenas arquivos JSONL são suportados
102+
'allowed_mime_types' => [ // MIME types suportados para arquivos JSONL
103+
'application/x-jsonlines',
104+
'application/jsonl',
105+
'application/x-ndjson',
106+
'application/x-ndjason',
107+
'text/jsonl'
108+
],
109+
'validate_content' => env('GROQ_BATCH_VALIDATE_CONTENT', true), // Validar conteúdo do arquivo
110+
'endpoints' => [ // Endpoints suportados para processamento em lote
111+
'/v1/chat/completions',
112+
'/v1/audio/transcriptions',
113+
'/v1/audio/translations'
114+
]
101115
],
102116

103117
/*

src/GroqClient.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ protected function getDefaultConfig(): array
6464
'top_p' => config('groq.options.top_p', 1.0),
6565
'frequency_penalty' => config('groq.options.frequency_penalty', 0),
6666
'presence_penalty' => config('groq.options.presence_penalty', 0),
67+
'batch' => [
68+
'allowed_extensions' => ['.jsonl'],
69+
'allowed_mime_types' => [
70+
'application/x-jsonlines',
71+
'application/jsonl',
72+
'application/x-ndjson',
73+
'application/x-ndjason',
74+
'text/jsonl'
75+
],
76+
'validate_content' => true
77+
]
6778
];
6879
}
6980

@@ -141,6 +152,7 @@ public function speech()
141152
* Get batch instance
142153
*
143154
* @return \LucianoTonet\GroqPHP\BatchManager
155+
* @deprecated Use batches() instead
144156
*/
145157
public function batch()
146158
{

0 commit comments

Comments
 (0)