Skip to content

Commit 25477d6

Browse files
committed
Remove PHP examples for Jurassic-2 (deprecated)
1 parent 53d6232 commit 25477d6

File tree

6 files changed

+12
-50
lines changed

6 files changed

+12
-50
lines changed

.doc_gen/metadata/bedrock-runtime_metadata.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ bedrock-runtime_Converse_AmazonNovaText:
124124
genai: some
125125
snippet_tags:
126126
- Bedrock.ConverseTool.dotnetv3.SendConverseRequest
127+
PHP:
128+
versions:
129+
- sdk_version: 3
130+
github: php/example_code/bedrock-runtime
131+
excerpts:
132+
- description: Send a text message to Amazon Nova, using Bedrock's Converse API.
133+
snippet_tags:
134+
- php.example_code.bedrock-runtime.service.Converse_AmazonNovaText
127135
Python:
128136
versions:
129137
- sdk_version: 3
@@ -792,14 +800,6 @@ bedrock-runtime_InvokeModel_Ai21LabsJurassic2:
792800
snippet_tags:
793801
- gov2.bedrock-runtime.InvokeModelWrapper.struct
794802
- gov2.bedrock-runtime.InvokeJurassic2
795-
PHP:
796-
versions:
797-
- sdk_version: 3
798-
github: php/example_code/bedrock-runtime
799-
excerpts:
800-
- description: Use the Invoke Model API to send a text message.
801-
snippet_tags:
802-
- php.example_code.bedrock-runtime.service.invokeJurassic2
803803
services:
804804
bedrock-runtime: {InvokeModel}
805805

php/example_code/bedrock-runtime/BedrockRuntimeService.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -63,36 +63,6 @@ public function invokeClaude($prompt)
6363
}
6464
// snippet-end:[php.example_code.bedrock-runtime.service.invokeClaude]
6565

66-
// snippet-start:[php.example_code.bedrock-runtime.service.invokeJurassic2]
67-
public function invokeJurassic2($prompt)
68-
{
69-
# The different model providers have individual request and response formats.
70-
# For the format, ranges, and default values for AI21 Labs Jurassic-2, refer to:
71-
# https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-jurassic2.html
72-
73-
$completion = "";
74-
try {
75-
$modelId = 'ai21.j2-mid-v1';
76-
$body = [
77-
'prompt' => $prompt,
78-
'temperature' => 0.5,
79-
'maxTokens' => 200,
80-
];
81-
$result = $this->bedrockRuntimeClient->invokeModel([
82-
'contentType' => 'application/json',
83-
'body' => json_encode($body),
84-
'modelId' => $modelId,
85-
]);
86-
$response_body = json_decode($result['body']);
87-
$completion = $response_body->completions[0]->data->text;
88-
} catch (Exception $e) {
89-
echo "Error: ({$e->getCode()}) - {$e->getMessage()}\n";
90-
}
91-
92-
return $completion;
93-
}
94-
// snippet-end:[php.example_code.bedrock-runtime.service.invokeJurassic2]
95-
9666
// snippet-start:[php.example_code.bedrock-runtime.service.invokeStableDiffusion]
9767
public function invokeStableDiffusion(string $prompt, int $seed, string $style_preset)
9868
{

php/example_code/bedrock-runtime/GettingStartedWithBedrockRuntime.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public function runExample()
2525
echo "\nPrompt: " . $prompt;
2626
echo "\n\nAnthropic Claude:\n";
2727
echo $bedrockRuntimeService->invokeClaude($prompt);
28-
echo "\n\nAI21 Labs Jurassic-2:\n";
29-
echo $bedrockRuntimeService->invokeJurassic2($prompt);
3028
echo "\n---------------------------------------------------------------------\n";
3129
$image_prompt = 'stylized picture of a cute old steampunk robot';
3230
echo "\nImage prompt: " . $image_prompt;

php/example_code/bedrock-runtime/Models/AmazonNova/Text/Converse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// SPDX-License-Identifier: Apache-2.0
44

55
namespace BedrockRuntime\Models\AmazonNova\Text;
6+
67
require_once __DIR__ . '/../../../vendor/autoload.php';
78

89
// snippet-start:[php.example_code.bedrock-runtime.service.Converse_AmazonNovaText]
@@ -48,7 +49,6 @@ public function converse(): string
4849
// Extract and return the response text.
4950
$responseText = $response['output']['message']['content'][0]['text'];
5051
return $responseText;
51-
5252
} catch (AwsException $e) {
5353
echo "ERROR: Can't invoke {$modelId}. Reason: {$e->getAwsErrorMessage()}";
5454
throw new RuntimeException("Failed to invoke model: " . $e->getAwsErrorMessage(), 0, $e);
@@ -59,4 +59,4 @@ public function converse(): string
5959
$demo = new Converse();
6060
echo $demo->converse();
6161

62-
// snippet-end:[php.example_code.bedrock-runtime.service.Converse_AmazonNovaText]
62+
// snippet-end:[php.example_code.bedrock-runtime.service.Converse_AmazonNovaText]

php/example_code/bedrock-runtime/tests/BedrockRuntimeTests.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Integration tests for the Amazon Bedrock Runtime service.
77
*/
88

9-
namespace bedrockruntime\tests;
9+
namespace BedrockRuntime\tests;
1010

1111
use Aws\BedrockRuntime\BedrockRuntimeClient;
1212
use BedrockRuntime\BedrockRuntimeService;
@@ -47,12 +47,6 @@ public function test_claude_can_be_invoked()
4747
self::assertNotEmpty($completion);
4848
}
4949

50-
public function test_jurassic2_can_be_invoked()
51-
{
52-
$completion = $this->bedrockRuntimeService->invokeJurassic2($this->prompt);
53-
self::assertNotEmpty($completion);
54-
}
55-
5650
public function test_stable_diffusion_can_be_invoked()
5751
{
5852
$seed = 0;

php/example_code/bedrock-runtime/tests/ConverseTests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ public function test_amazon_nova_text(): void
1616
self::assertIsString($result);
1717
self::assertNotEmpty($result);
1818
}
19-
}
19+
}

0 commit comments

Comments
 (0)