@@ -15,9 +15,9 @@ protected function getPackageProviders($app)
15
15
16
16
protected function getEnvironmentSetUp ($ app )
17
17
{
18
- // Use a chave real da API para testes de integração
18
+ // Use the real API key for integration tests
19
19
$ app ['config ' ]->set ('groq.api_key ' , env ('GROQ_API_KEY ' ));
20
- $ app ['config ' ]->set ('groq.model ' , 'llama3- 8b-8192 ' );
20
+ $ app ['config ' ]->set ('groq.model ' , 'llama-3.1- 8b-instant ' );
21
21
}
22
22
23
23
/** @test */
@@ -34,9 +34,9 @@ public function it_can_list_models()
34
34
public function it_can_create_chat_completion ()
35
35
{
36
36
$ response = Groq::chat ()->completions ()->create ([
37
- 'model ' => 'llama3- 8b-8192 ' ,
37
+ 'model ' => 'llama-3.1- 8b-instant ' ,
38
38
'messages ' => [
39
- ['role ' => 'user ' , 'content ' => 'Diga olá em português ' ]
39
+ ['role ' => 'user ' , 'content ' => 'Say hello in Portuguese ' ]
40
40
]
41
41
]);
42
42
@@ -50,9 +50,10 @@ public function it_can_create_chat_completion()
50
50
/** @test */
51
51
public function it_can_analyze_image ()
52
52
{
53
- $ imageUrl = 'https://raw.githubusercontent.com/lucianotonet/groq-laravel/main/docs/art.png ' ;
53
+ // Using a small embedded test image as Base64 to avoid external dependency
54
+ $ base64Image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFElEQVR42mP8z8BQz0AEYBxVSF+FABJADveWkH6oAAAAAElFTkSuQmCC ' ;
54
55
55
- $ response = Groq::vision ()->analyze ($ imageUrl , 'Descreva esta imagem ' );
56
+ $ response = Groq::vision ()->analyze ($ base64Image , 'Describe this image ' );
56
57
57
58
$ this ->assertIsArray ($ response );
58
59
$ this ->assertArrayHasKey ('choices ' , $ response );
@@ -67,18 +68,18 @@ public function it_can_handle_errors_gracefully()
67
68
$ this ->expectException (\LucianoTonet \GroqPHP \GroqException::class);
68
69
69
70
Groq::chat ()->completions ()->create ([
70
- 'model ' => 'llama3- 8b-8192 ' ,
71
- 'messages ' => [] // Mensagens vazias devem gerar erro
71
+ 'model ' => 'llama-3.1- 8b-instant ' ,
72
+ 'messages ' => [] // Empty messages should generate an error
72
73
]);
73
74
}
74
75
75
76
/** @test */
76
77
public function it_can_use_different_models ()
77
78
{
78
79
$ response = Groq::chat ()->completions ()->create ([
79
- 'model ' => 'llama3- 8b-8192 ' , // Usando o modelo padrão ao invés do mixtral
80
+ 'model ' => 'llama-3.1- 8b-instant ' , // Using the default model instead of mixtral
80
81
'messages ' => [
81
- ['role ' => 'user ' , 'content ' => 'Diga olá em português ' ]
82
+ ['role ' => 'user ' , 'content ' => 'Say hello in Portuguese ' ]
82
83
]
83
84
]);
84
85
@@ -89,9 +90,9 @@ public function it_can_use_different_models()
89
90
/** @test */
90
91
public function it_can_handle_file_operations ()
91
92
{
92
- // Criar arquivo JSONL temporário
93
+ // Create temporary JSONL file
93
94
$ tempFile = tempnam (sys_get_temp_dir (), 'groq_test_ ' ) . '.jsonl ' ;
94
- file_put_contents ($ tempFile , json_encode (['prompt ' => 'Olá ' ]) . "\n" . json_encode (['prompt ' => 'Mundo ' ]) . "\n" );
95
+ file_put_contents ($ tempFile , json_encode (['prompt ' => 'Hello ' ]) . "\n" . json_encode (['prompt ' => 'World ' ]) . "\n" );
95
96
96
97
// Upload
97
98
$ file = Groq::files ()->upload ($ tempFile , 'batch ' );
@@ -115,23 +116,27 @@ public function it_can_handle_file_operations()
115
116
/** @test */
116
117
public function it_respects_configuration_options ()
117
118
{
118
- // Configurando para gerar respostas curtas, mas com limite de tokens maior
119
+ // Configure to generate short responses with stricter token limit
119
120
Groq::setConfig ([
120
121
'temperature ' => 0.1 ,
121
- 'max_tokens ' => 30 // Usando um valor muito mais restritivo para o teste
122
+ 'max_tokens ' => 30 // Using a much more restrictive value for testing
122
123
]);
123
124
124
125
$ response = Groq::chat ()->completions ()->create ([
125
- 'model ' => 'llama3- 8b-8192 ' ,
126
+ 'model ' => 'llama-3.1- 8b-instant ' ,
126
127
'messages ' => [
127
- ['role ' => 'user ' , 'content ' => 'Diga apenas "Olá, mundo !" ' ]
128
+ ['role ' => 'user ' , 'content ' => 'Just say "Hello, world !" ' ]
128
129
],
129
- 'max_tokens ' => 30 // Garantindo que o valor seja passado na requisição também
130
+ 'max_tokens ' => 30 // Ensuring the value is also passed in the request
130
131
]);
131
132
132
133
$ this ->assertIsArray ($ response );
133
134
$ this ->assertArrayHasKey ('choices ' , $ response );
134
- // Vamos apenas verificar se há resposta, sem verificar o tamanho
135
+ // Let's just check if there's a response, without verifying the size
135
136
$ this ->assertNotEmpty ($ response ['choices ' ][0 ]['message ' ]['content ' ]);
137
+
138
+ // Verify the response is reasonably constrained by max_tokens
139
+ $ content = $ response ['choices ' ][0 ]['message ' ]['content ' ];
140
+ $ this ->assertLessThanOrEqual (100 , strlen ($ content ), 'Response should be constrained by max_tokens ' );
136
141
}
137
142
}
0 commit comments