Skip to content

Commit

Permalink
Unify comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Traub authored and meyertst-aws committed Oct 18, 2024
1 parent c26dcc4 commit 8992349
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 80 deletions.
57 changes: 27 additions & 30 deletions php/example_code/bedrock-runtime/BedrockRuntimeService.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

#snippet-start:[php.example_code.bedrock-runtime.service]

// snippet-start:[php.example_code.bedrock-runtime.service]
namespace BedrockRuntime;

use Aws\BedrockRuntime\BedrockRuntimeClient;
Expand All @@ -21,17 +19,17 @@ public function __construct()
]);
}

#snippet-start:[php.example_code.bedrock-runtime.service.invokeClaude]
// snippet-start:[php.example_code.bedrock-runtime.service.invokeClaude]
public function invokeClaude($prompt)
{
# The different model providers have individual request and response formats.
# For the format, ranges, and default values for Anthropic Claude, refer to:
# https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html
// The different model providers have individual request and response formats.
// For the format, ranges, and default values for Anthropic Claude, refer to:
// https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-claude.html

$completion = "";
try {
$modelId = 'anthropic.claude-v2';
# Claude requires you to enclose the prompt as follows:
// Claude requires you to enclose the prompt as follows:
$prompt = "\n\nHuman: {$prompt}\n\nAssistant:";
$body = [
'prompt' => $prompt,
Expand All @@ -52,9 +50,9 @@ public function invokeClaude($prompt)

return $completion;
}
#snippet-end:[php.example_code.bedrock-runtime.service.invokeClaude]
// snippet-end:[php.example_code.bedrock-runtime.service.invokeClaude]

#snippet-start:[php.example_code.bedrock-runtime.service.invokeJurassic2]
// snippet-start:[php.example_code.bedrock-runtime.service.invokeJurassic2]
public function invokeJurassic2($prompt)
{
# The different model providers have individual request and response formats.
Expand Down Expand Up @@ -82,14 +80,14 @@ public function invokeJurassic2($prompt)

return $completion;
}
#snippet-end:[php.example_code.bedrock-runtime.service.invokeJurassic2]
// snippet-end:[php.example_code.bedrock-runtime.service.invokeJurassic2]

#snippet-start:[php.example_code.bedrock-runtime.service.invokeLlama2]
// snippet-start:[php.example_code.bedrock-runtime.service.invokeLlama2]
public function invokeLlama2($prompt)
{
# The different model providers have individual request and response formats.
# For the format, ranges, and default values for Meta Llama 2 Chat, refer to:
# https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-meta.html
// The different model providers have individual request and response formats.
// For the format, ranges, and default values for Meta Llama 2 Chat, refer to:
// https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-meta.html

$completion = "";
try {
Expand All @@ -112,14 +110,14 @@ public function invokeLlama2($prompt)

return $completion;
}
#snippet-end:[php.example_code.bedrock-runtime.service.invokeLlama2]
// snippet-end:[php.example_code.bedrock-runtime.service.invokeLlama2]

#snippet-start:[php.example_code.bedrock-runtime.service.invokeStableDiffusion]
// snippet-start:[php.example_code.bedrock-runtime.service.invokeStableDiffusion]
public function invokeStableDiffusion(string $prompt, int $seed, string $style_preset)
{
# The different model providers have individual request and response formats.
# For the format, ranges, and available style_presets of Stable Diffusion models refer to:
# https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-stability-diffusion.html
// The different model providers have individual request and response formats.
// For the format, ranges, and available style_presets of Stable Diffusion models refer to:
// https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-stability-diffusion.html

$base64_image_data = "";
try {
Expand Down Expand Up @@ -149,14 +147,14 @@ public function invokeStableDiffusion(string $prompt, int $seed, string $style_p

return $base64_image_data;
}
#snippet-end:[php.example_code.bedrock-runtime.service.invokeStableDiffusion]
// snippet-end:[php.example_code.bedrock-runtime.service.invokeStableDiffusion]

#snippet-start:[php.example_code.bedrock-runtime.service.invokeTitanImage]
// snippet-start:[php.example_code.bedrock-runtime.service.invokeTitanImage]
public function invokeTitanImage(string $prompt, int $seed)
{
# The different model providers have individual request and response formats.
# For the format, ranges, and default values for Titan Image models refer to:
# https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-image.html
// The different model providers have individual request and response formats.
// For the format, ranges, and default values for Titan Image models refer to:
// https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters-titan-image.html

$base64_image_data = "";
try {
Expand Down Expand Up @@ -188,7 +186,6 @@ public function invokeTitanImage(string $prompt, int $seed)

return $base64_image_data;
}
#snippet-end:[php.example_code.bedrock-runtime.service.invokeTitanImage]
// snippet-end:[php.example_code.bedrock-runtime.service.invokeTitanImage]
}

#snippet-end:[php.example_code.bedrock-runtime.service]
// snippet-end:[php.example_code.bedrock-runtime.service]
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

/**
* Purpose
* Shows how to use the AWS SDK for PHP with the Amazon Bedrock Runtime to:
* - ...
**/

# snippet-start:[php.example_code.bedrock-runtime.basics.scenario]
// snippet-start:[php.example_code.bedrock-runtime.basics.scenario]
namespace BedrockRuntime;

class GettingStartedWithBedrockRuntime
Expand Down Expand Up @@ -66,5 +65,4 @@ private function saveImage($base64_image_data, $model_id): string
return $file_path;
}
}

# snippet-end:[php.example_code.bedrock-runtime.basics.scenario]
// snippet-end:[php.example_code.bedrock-runtime.basics.scenario]
10 changes: 5 additions & 5 deletions php/example_code/bedrock-runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,23 @@ functions within the same service.

### AI21 Labs Jurassic-2

- [InvokeModel](BedrockRuntimeService.php#L57)
- [InvokeModel](BedrockRuntimeService.php#L55)

### Amazon Titan Image Generator

- [InvokeModel](BedrockRuntimeService.php#L154)
- [InvokeModel](BedrockRuntimeService.php#L152)

### Anthropic Claude

- [InvokeModel](BedrockRuntimeService.php#L24)
- [InvokeModel](BedrockRuntimeService.php#L22)

### Meta Llama

- [InvokeModel: Llama 2](BedrockRuntimeService.php#L87)
- [InvokeModel: Llama 2](BedrockRuntimeService.php#L85)

### Stable Diffusion

- [InvokeModel](BedrockRuntimeService.php#L117)
- [InvokeModel](BedrockRuntimeService.php#L115)


<!--custom.examples.start-->
Expand Down
1 change: 0 additions & 1 deletion php/example_code/bedrock-runtime/Runner.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

Expand Down
12 changes: 6 additions & 6 deletions php/example_code/bedrock-runtime/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions php/example_code/bedrock-runtime/tests/BedrockRuntimeTests.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

#
# Integration tests for the Amazon Bedrock Runtime service.
#
/**
* Integration tests for the Amazon Bedrock Runtime service.
*/

namespace bedrockruntime\tests;

Expand Down
13 changes: 6 additions & 7 deletions php/example_code/bedrock/BedrockService.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

#snippet-start:[php.example_code.bedrock.service]
// snippet-start:[php.example_code.bedrock.service]
namespace Bedrock;

use Aws\Bedrock\BedrockClient;
use AwsUtilities\AWSServiceClass;

class BedrockService extends AWSServiceClass
{
#snippet-start:[php.example_code.bedrock.service.listFoundationModels]
// snippet-start:[php.example_code.bedrock.service.listFoundationModels]
public function listFoundationModels()
{
$bedrockClient = new BedrockClient([
Expand All @@ -21,6 +20,6 @@ public function listFoundationModels()
$response = $bedrockClient->listFoundationModels();
return $response['modelSummaries'];
}
#snippet-end:[php.example_code.bedrock.service.listFoundationModels]
// snippet-end:[php.example_code.bedrock.service.listFoundationModels]
}
#snippet-end:[php.example_code.bedrock.service]
// snippet-end:[php.example_code.bedrock.service]
9 changes: 4 additions & 5 deletions php/example_code/bedrock/GettingStartedWithBedrock.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
<?php

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

/**
* Purpose
* Shows how to use the AWS SDK for PHP with Amazon Bedrock to:
* List information about the available foundation models.
**/

# snippet-start:[php.example_code.bedrock.basics.scenario]
// snippet-start:[php.example_code.bedrock.basics.scenario]
namespace Bedrock;

class GettingStartedWithBedrock
Expand Down Expand Up @@ -38,4 +37,4 @@ public function runExample()
}
}
}
# snippet-end:[php.example_code.bedrock.basics.scenario]
// snippet-end:[php.example_code.bedrock.basics.scenario]
2 changes: 1 addition & 1 deletion php/example_code/bedrock/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ For prerequisites, see the [README](../../README.md#Prerequisites) in the `php`

Code excerpts that show you how to call individual service functions.

- [ListFoundationModels](BedrockService.php#L14)
- [ListFoundationModels](BedrockService.php#L13)


<!--custom.examples.start-->
Expand Down
1 change: 0 additions & 1 deletion php/example_code/bedrock/Runner.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

Expand Down
12 changes: 6 additions & 6 deletions php/example_code/bedrock/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions php/example_code/bedrock/tests/BedrockBasicsTests.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

#
# Integration test runner for Amazon Bedrock files.
#
/**
* Integration test runner for Amazon Bedrock files.
*/

namespace bedrock\tests;

Expand Down

0 comments on commit 8992349

Please sign in to comment.