Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit 8b6dae3

Browse files
committed
style: apply CS Fixer and Rector suggestions
- Add backslash prefix to global PHP constants - Cast to string in rtrim() calls - Fix indentation in heredoc strings - Add missing newlines at end of files
1 parent 257541e commit 8b6dae3

File tree

4 files changed

+33
-33
lines changed

4 files changed

+33
-33
lines changed

examples/albert/chat.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@
1515
$albertApiUrl = $_ENV['ALBERT_API_URL'] ?? null;
1616

1717
if (empty($albertApiKey)) {
18-
echo 'Please set the ALBERT_API_KEY environment variable.'.PHP_EOL;
18+
echo 'Please set the ALBERT_API_KEY environment variable.'.\PHP_EOL;
1919
exit(1);
2020
}
2121

2222
if (empty($albertApiUrl)) {
23-
echo 'Please set the ALBERT_API_URL environment variable (e.g., https://your-albert-instance.com).'.PHP_EOL;
23+
echo 'Please set the ALBERT_API_URL environment variable (e.g., https://your-albert-instance.com).'.\PHP_EOL;
2424
exit(1);
2525
}
2626

2727
// Albert API is OpenAI-compatible, so we use the OpenAI platform factory
2828
// with a custom base URL pointing to your Albert instance
2929
$platform = PlatformFactory::create(
3030
apiKey: $albertApiKey,
31-
baseUrl: rtrim($albertApiUrl, '/').'/v1/', // Ensure proper URL format
31+
baseUrl: rtrim((string) $albertApiUrl, '/').'/v1/', // Ensure proper URL format
3232
);
3333

3434
// Use the model name provided by your Albert instance
@@ -44,6 +44,6 @@
4444

4545
$response = $chain->call($messages);
4646

47-
echo 'Albert API Response:'.PHP_EOL;
48-
echo '==================='.PHP_EOL;
49-
echo $response->getContent().PHP_EOL;
47+
echo 'Albert API Response:'.\PHP_EOL;
48+
echo '==================='.\PHP_EOL;
49+
echo $response->getContent().\PHP_EOL;

examples/albert/rag.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
$albertApiUrl = $_ENV['ALBERT_API_URL'] ?? null;
1616

1717
if (empty($albertApiKey)) {
18-
echo 'Please set the ALBERT_API_KEY environment variable.'.PHP_EOL;
18+
echo 'Please set the ALBERT_API_KEY environment variable.'.\PHP_EOL;
1919
exit(1);
2020
}
2121

2222
if (empty($albertApiUrl)) {
23-
echo 'Please set the ALBERT_API_URL environment variable (e.g., https://your-albert-instance.com).'.PHP_EOL;
23+
echo 'Please set the ALBERT_API_URL environment variable (e.g., https://your-albert-instance.com).'.\PHP_EOL;
2424
exit(1);
2525
}
2626

2727
$platform = PlatformFactory::create(
2828
apiKey: $albertApiKey,
29-
baseUrl: rtrim($albertApiUrl, '/').'/v1/',
29+
baseUrl: rtrim((string) $albertApiUrl, '/').'/v1/',
3030
);
3131

3232
$model = new GPT($_ENV['ALBERT_MODEL'] ?? 'albert-7b-v2');
@@ -35,17 +35,17 @@
3535
// Albert API supports RAG out of the box
3636
// You can pass document context as part of your messages
3737
$documentContext = <<<'CONTEXT'
38-
Document: AI Strategy of France
38+
Document: AI Strategy of France
3939
40-
France has launched a comprehensive national AI strategy with the following key objectives:
41-
1. Strengthening the AI ecosystem and attracting talent
42-
2. Developing sovereign AI capabilities
43-
3. Ensuring ethical and responsible AI development
44-
4. Supporting AI adoption in public services
45-
5. Investing €1.5 billion in AI research and development
40+
France has launched a comprehensive national AI strategy with the following key objectives:
41+
1. Strengthening the AI ecosystem and attracting talent
42+
2. Developing sovereign AI capabilities
43+
3. Ensuring ethical and responsible AI development
44+
4. Supporting AI adoption in public services
45+
5. Investing €1.5 billion in AI research and development
4646
47-
The Albert project is part of this strategy, providing a sovereign AI solution for French public administration.
48-
CONTEXT;
47+
The Albert project is part of this strategy, providing a sovereign AI solution for French public administration.
48+
CONTEXT;
4949

5050
$messages = new MessageBag(
5151
Message::forSystem(
@@ -58,6 +58,6 @@
5858

5959
$response = $chain->call($messages);
6060

61-
echo 'Albert API RAG Response:'.PHP_EOL;
62-
echo '========================'.PHP_EOL;
63-
echo $response->getContent().PHP_EOL;
61+
echo 'Albert API RAG Response:'.\PHP_EOL;
62+
echo '========================'.\PHP_EOL;
63+
echo $response->getContent().\PHP_EOL;

examples/albert/stream.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
$albertApiUrl = $_ENV['ALBERT_API_URL'] ?? null;
1616

1717
if (empty($albertApiKey)) {
18-
echo 'Please set the ALBERT_API_KEY environment variable.'.PHP_EOL;
18+
echo 'Please set the ALBERT_API_KEY environment variable.'.\PHP_EOL;
1919
exit(1);
2020
}
2121

2222
if (empty($albertApiUrl)) {
23-
echo 'Please set the ALBERT_API_URL environment variable (e.g., https://your-albert-instance.com).'.PHP_EOL;
23+
echo 'Please set the ALBERT_API_URL environment variable (e.g., https://your-albert-instance.com).'.\PHP_EOL;
2424
exit(1);
2525
}
2626

2727
$platform = PlatformFactory::create(
2828
apiKey: $albertApiKey,
29-
baseUrl: rtrim($albertApiUrl, '/').'/v1/',
29+
baseUrl: rtrim((string) $albertApiUrl, '/').'/v1/',
3030
);
3131

3232
$model = new GPT($_ENV['ALBERT_MODEL'] ?? 'albert-7b-v2');
@@ -40,13 +40,13 @@
4040
// Enable streaming for real-time response
4141
$response = $chain->call($messages, ['stream' => true]);
4242

43-
echo 'Albert API Streaming Response:'.PHP_EOL;
44-
echo '=============================='.PHP_EOL;
43+
echo 'Albert API Streaming Response:'.\PHP_EOL;
44+
echo '=============================='.\PHP_EOL;
4545

4646
// Stream the response token by token
4747
foreach ($response->getContent() as $token) {
4848
echo $token;
4949
flush(); // Ensure immediate output
5050
}
5151

52-
echo PHP_EOL;
52+
echo \PHP_EOL;

examples/albert/toolcall.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
$albertApiUrl = $_ENV['ALBERT_API_URL'] ?? null;
1919

2020
if (empty($albertApiKey)) {
21-
echo 'Please set the ALBERT_API_KEY environment variable.'.PHP_EOL;
21+
echo 'Please set the ALBERT_API_KEY environment variable.'.\PHP_EOL;
2222
exit(1);
2323
}
2424

2525
if (empty($albertApiUrl)) {
26-
echo 'Please set the ALBERT_API_URL environment variable (e.g., https://your-albert-instance.com).'.PHP_EOL;
26+
echo 'Please set the ALBERT_API_URL environment variable (e.g., https://your-albert-instance.com).'.\PHP_EOL;
2727
exit(1);
2828
}
2929

@@ -57,7 +57,7 @@ public function __invoke(string $departmentNumber): array
5757
// Initialize Albert API
5858
$platform = PlatformFactory::create(
5959
apiKey: $albertApiKey,
60-
baseUrl: rtrim($albertApiUrl, '/').'/v1/',
60+
baseUrl: rtrim((string) $albertApiUrl, '/').'/v1/',
6161
);
6262

6363
$model = new GPT($_ENV['ALBERT_MODEL'] ?? 'albert-7b-v2');
@@ -76,6 +76,6 @@ public function __invoke(string $departmentNumber): array
7676

7777
$response = $chain->call($messages);
7878

79-
echo 'Albert API Tool Calling Response:'.PHP_EOL;
80-
echo '================================='.PHP_EOL;
81-
echo $response->getContent().PHP_EOL;
79+
echo 'Albert API Tool Calling Response:'.\PHP_EOL;
80+
echo '================================='.\PHP_EOL;
81+
echo $response->getContent().\PHP_EOL;

0 commit comments

Comments
 (0)