Skip to content

Commit

Permalink
added support for stability.sd3-5-large
Browse files Browse the repository at this point in the history
  • Loading branch information
techthoughts2 committed Jan 5, 2025
1 parent eba68aa commit c3fc3f9
Show file tree
Hide file tree
Showing 19 changed files with 87 additions and 17 deletions.
4 changes: 3 additions & 1 deletion docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.2.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.50.0] - **BREAKING CHANGES**
## [0.51.0] - **BREAKING CHANGES**

- Module changes:
- Added two new properties to all model documentation objects:
Expand All @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `CfgScale` parameter maximum adjusted from 10 to 9.9
- Meta
- Removed `meta.llama2-13b-chat-v1` and `meta.llama2-70b-chat-v1` from all functions as Bedrock has EOL these two models. - ***Breaking Change***
- stability.ai
- Updated `Invoke-StabilityAIImageModel` to support new model: `stability.sd3-5-large-v1:0`

## [0.33.0] - **BREAKING CHANGES**

Expand Down
2 changes: 1 addition & 1 deletion docs/pwshBedrock.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Module Name: pwshBedrock
Module Guid: b4f9e4dc-0229-44ef-99a1-08be4c5e81f2
Download Help Link: NA
Help Version: 0.50.0
Help Version: 0.51.0
Locale: en-US
---

Expand Down
1 change: 1 addition & 0 deletions src/Tests/Integration/ConverseAPI.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ InModuleScope 'pwshBedrock' {
# 'stability.stable-image-ultra-v1:0', # *note: not supported by Converse API
# 'stability.stable-image-core-v1:0' # *note: not supported by Converse API
# 'stability.sd3-large-v1:0' # *note: not supported by Converse API
# 'stability.sd3-5-large-v1:0' # *note: not supported by Converse API
)
}
BeforeAll {
Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Integration/StabilityAI.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ InModuleScope 'pwshBedrock' {
$eval | Should -Not -BeNullOrEmpty
} #it

It 'should return an image when using image-to-image for <_.ModelId>' -Foreach ($script:stabilityAIModelInfo | Where-Object { $_.ModelID -eq 'stability.sd3-large-v1:0' }) {
It 'should return an image when using image-to-image for <_.ModelId>' -Foreach ($script:stabilityAIModelInfo | Where-Object { $_.ModelID -like '*sd3*' }) {
$ModelID = $_.ModelID
$invokeStabilityAIImageModelSplat = @{
ImagesSavePath = $outFile
Expand Down
3 changes: 2 additions & 1 deletion src/Tests/Integration/SupportedModels-Checks.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ Describe 'Supported Models Checks' -Tag Integration {
'stability.stable-diffusion-xl-v1',
'stability.stable-image-ultra-v1:0',
'stability.stable-image-core-v1:0'
'stability.sd3-large-v1:0'
'stability.sd3-large-v1:0',
'stability.sd3-5-large-v1:0'
)
$filesWithAllModelsReferences = @(
'Add-ModelCostEstimate.ps1'
Expand Down
7 changes: 7 additions & 0 deletions src/Tests/Unit/Public/Get-ModelContext.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,13 @@ InModuleScope 'pwshBedrock' {
content = 'test'
}
}
[PSCustomObject]@{
ModelId = 'stability.sd3-5-large-v1:0'
Context = [PSCustomObject]@{
role = 'user'
content = 'test'
}
}
)
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tests/Unit/Public/Get-ModelTally.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ InModuleScope 'pwshBedrock' {

It 'should get the tally for all models' {
$eval = Get-ModelTally -AllModels
$eval.Count | Should -BeExactly 44
$eval.Count | Should -BeExactly 45
foreach ($model in $eval) {
if ($null -ne $model.ImageCount) {
$model.ImageCount | Should -BeExactly 0
Expand Down
14 changes: 14 additions & 0 deletions src/Tests/Unit/Public/Reset-ModelContext.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,20 @@ User: "Hi there!
}
)
}
[PSCustomObject]@{
ModelID = 'stability.sd3-5-large-v1:0'
Context = @(
[PSCustomObject]@{
role = 'user'
content = @(
[PSCustomObject]@{
type = 'text'
text = 'SD3 large v1 context'
}
)
}
)
}
)
} #beforeEach

Expand Down
36 changes: 36 additions & 0 deletions src/pwshBedrock/Imports.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ $Global:pwshBedRockSessionModelTally = @(
ImageCount = 0
ImageCost = 0
}
[PSCustomObject]@{
ModelId = 'stability.sd3-5-large-v1:0'
ImageCount = 0
ImageCost = 0
}
)

#endregion
Expand Down Expand Up @@ -520,6 +525,10 @@ $Global:pwshBedrockModelContext = @(
ModelId = 'stability.sd3-large-v1:0'
Context = New-Object System.Collections.Generic.List[object]
}
[PSCustomObject]@{
ModelId = 'stability.sd3-5-large-v1:0'
Context = New-Object System.Collections.Generic.List[object]
}
)

#endregion
Expand Down Expand Up @@ -1691,6 +1700,33 @@ $script:stabilityAIModelInfo = @(
# OutputTokenCost = 0.012
# pricing structure is different for image models
}
[PSCustomObject]@{
ProviderName = 'Stability AI'
ModelName = 'Stable Diffusion 3.5 Large'
ModelId = 'stability.sd3-5-large-v1:0'
Model = ''
Description = 'the most powerful model in the Stable Diffusion family at 8.1 billion parameters, with superior quality and prompt adherence'
Strength = 'Story boarding, concept art creation, and rapid prototyping of visual effects. typography, intricate compositions, dynamic lighting, vibrant colors, and artistic cohesion.'
Multilingual = $false
Text = $false
Image = $true
Video = $false
Document = $false
Vision = $false
SystemPrompt = $false
ToolUse = $false
ResponseStreamingSupported = $false
ChatHistorySupported = $false
InferenceProfile = $false
ContextWindow = ''
MaxOutput = ''
TrainingCutoff = ''
PayloadLimit = '' #! Couldn't find in documentation
ImageCost = 0.08
# InputTokenCost = 0.01
# OutputTokenCost = 0.012
# pricing structure is different for image models
}
) #ai21ModelInfo

#endregion
Expand Down
3 changes: 2 additions & 1 deletion src/pwshBedrock/Private/Add-ModelCostEstimate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ function Add-ModelCostEstimate {
'stability.stable-diffusion-xl-v1',
'stability.stable-image-ultra-v1:0',
'stability.stable-image-core-v1:0',
'stability.sd3-large-v1:0'
'stability.sd3-large-v1:0',
'stability.sd3-5-large-v1:0'
)]
[string]$ModelID,

Expand Down
1 change: 1 addition & 0 deletions src/pwshBedrock/Public/Get-ModelContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ function Get-ModelContext {
'stability.stable-image-ultra-v1:0',
'stability.stable-image-core-v1:0',
'stability.sd3-large-v1:0',
'stability.sd3-5-large-v1:0',
'Converse'
)]
[string]$ModelID
Expand Down
3 changes: 2 additions & 1 deletion src/pwshBedrock/Public/Get-ModelCostEstimate.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ function Get-ModelCostEstimate {
'stability.stable-diffusion-xl-v1',
'stability.stable-image-ultra-v1:0',
'stability.stable-image-core-v1:0',
'stability.sd3-large-v1:0'
'stability.sd3-large-v1:0',
'stability.sd3-5-large-v1:0'
)]
[string]$ModelID
)
Expand Down
3 changes: 2 additions & 1 deletion src/pwshBedrock/Public/Get-ModelInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ function Get-ModelInfo {
'stability.stable-diffusion-xl-v1',
'stability.stable-image-ultra-v1:0',
'stability.stable-image-core-v1:0',
'stability.sd3-large-v1:0'
'stability.sd3-large-v1:0',
'stability.sd3-5-large-v1:0'
)]
[string]$ModelID,

Expand Down
3 changes: 2 additions & 1 deletion src/pwshBedrock/Public/Get-ModelTally.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ function Get-ModelTally {
'stability.stable-diffusion-xl-v1',
'stability.stable-image-ultra-v1:0',
'stability.stable-image-core-v1:0',
'stability.sd3-large-v1:0'
'stability.sd3-large-v1:0',
'stability.sd3-5-large-v1:0'
)]
[string]$ModelID,

Expand Down
9 changes: 5 additions & 4 deletions src/pwshBedrock/Public/Invoke-StabilityAIImageModel.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ function Invoke-StabilityAIImageModel {
[ValidateSet(
'stability.stable-image-core-v1:0',
'stability.stable-image-ultra-v1:0',
'stability.sd3-large-v1:0'
'stability.sd3-large-v1:0',
'stability.sd3-5-large-v1:0'
)]
[string]$ModelID = 'stability.stable-image-core-v1:0',

Expand Down Expand Up @@ -244,11 +245,11 @@ function Invoke-StabilityAIImageModel {

#region image-to-image parameters

if ($InitImagePath -and $ModelID -ne 'stability.sd3-large-v1:0') {
Write-Warning -Message 'Only stability.sd3-large-v1:0 supports image-to-image requests.'
if ($InitImagePath -and $ModelID -notlike '*sd3*') {
Write-Warning -Message 'Only stability sd3 models support image-to-image requests.'
throw ('Model {0} does not support image-to-image requests.' -f $ModelID)
}
elseif ($InitImagePath -and $ModelID -eq 'stability.sd3-large-v1:0') {
elseif ($InitImagePath -and $ModelID -like '*sd3*') {
$bodyObj.Add('mode', 'image-to-image')

Write-Debug -Message 'Validating InitImage'
Expand Down
3 changes: 2 additions & 1 deletion src/pwshBedrock/Public/Reset-ModelContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ function Reset-ModelContext {
'stability.stable-diffusion-xl-v1',
'stability.stable-image-ultra-v1:0',
'stability.stable-image-core-v1:0',
'stability.sd3-large-v1:0'
'stability.sd3-large-v1:0',
'stability.sd3-5-large-v1:0'
)]
[string]$ModelID,

Expand Down
3 changes: 2 additions & 1 deletion src/pwshBedrock/Public/Reset-ModelTally.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ function Reset-ModelTally {
'stability.stable-diffusion-xl-v1',
'stability.stable-image-ultra-v1:0',
'stability.stable-image-core-v1:0',
'stability.sd3-large-v1:0'
'stability.sd3-large-v1:0',
'stability.sd3-5-large-v1:0'
)]
[string]$ModelID,

Expand Down
3 changes: 2 additions & 1 deletion src/pwshBedrock/Public/Save-ModelContext.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ function Save-ModelContext {
'stability.stable-diffusion-xl-v1',
'stability.stable-image-ultra-v1:0',
'stability.stable-image-core-v1:0',
'stability.sd3-large-v1:0'
'stability.sd3-large-v1:0',
'stability.sd3-5-large-v1:0'
)]
[string]$ModelID,

Expand Down
2 changes: 1 addition & 1 deletion src/pwshBedrock/pwshBedrock.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'pwshBedrock.psm1'

# Version number of this module.
ModuleVersion = '0.50.0'
ModuleVersion = '0.51.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down

0 comments on commit c3fc3f9

Please sign in to comment.