Skip to content

Commit 00d3b04

Browse files
first commit
1 parent 72c815f commit 00d3b04

File tree

4 files changed

+122
-8
lines changed

4 files changed

+122
-8
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ ___
4949
- [Results](#Results)
5050
- [3D](#3D)
5151
- [Video](#Video)
52+
- [Other Features of Version 1](#Other-Features-of-Version-1)
53+
- [Model list](#Model-list)
5254
- [Contributing](#contributing)
5355
- [License](#license)
5456

@@ -1168,6 +1170,29 @@ Detailed settings on the [official documentation](https://platform.stability.ai/
11681170

11691171
<br/>
11701172

1173+
# Other Features of Version 1
1174+
1175+
## Model list
1176+
1177+
```Pascal
1178+
//uses
1179+
// StabilityAI, StabilityAI.Types, StabilityAI.Common, FMX.Stability.Tutorial,
1180+
// SStabilityAI.Version1.Engines;
1181+
1182+
Stability.Version1.Engines.List(
1183+
function : TAsynEngines
1184+
begin
1185+
Result.Sender := StabilityResult;
1186+
Result.OnStart := Start;
1187+
Result.OnSuccess := Display;
1188+
Result.OnError := Display;
1189+
end);
1190+
```
1191+
1192+
Detailed settings on the [official documentation](https://platform.stability.ai/docs/api-reference#tag/Engines/operation/listEngines)
1193+
1194+
<br/>
1195+
11711196
# Contributing
11721197

11731198
Pull requests are welcome. If you're planning to make a major change, please open an issue first to discuss your proposed changes.

source/FMX.Stability.Tutorial.pas

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface
1515
uses
1616
System.SysUtils, System.Classes, System.Types, FMX.Memo, FMX.Objects, FMX.Forms,
1717
StabilityAI.Common, StabilityAI.Version1.SDXL1AndSD1_6, StabilityAI.VideoAnd3D.Stable3D,
18-
StabilityAI.VideoAnd3D.Video;
18+
StabilityAI.VideoAnd3D.Video, StabilityAI.Version1.Engines;
1919

2020
type
2121
TFMXStabilitySender = class
@@ -39,6 +39,7 @@ TFMXStabilitySender = class
3939
procedure Display(Sender: TObject; Value: TResults); overload;
4040
procedure Display(Sender: TObject; Value: TModel3D); overload;
4141
procedure Display(Sender: TObject; Value: TJobVideo); overload;
42+
procedure Display(Sender: TObject; Value: TEngines); overload;
4243

4344
var
4445
StabilityResult: TFMXStabilitySender = nil;
@@ -47,7 +48,7 @@ implementation
4748

4849
procedure Start(Sender: TObject);
4950
begin
50-
Display(Sender, 'The generation has started. Please wait...');
51+
Display(Sender, 'Request dended. Please wait....');
5152
end;
5253

5354
procedure Display(Sender: TObject; Value: string);
@@ -67,7 +68,7 @@ procedure Display(Sender: TObject; Result: TStableImage);
6768
{--- Display only images }
6869
if not Result.Image.IsEmpty then
6970
T.Image.Bitmap.LoadFromStream(Stream);
70-
Display(Sender, 'Generation ended successfully');
71+
Display(Sender, 'Operation ended successfully');
7172
finally
7273
Stream.Free;
7374
end;
@@ -81,7 +82,7 @@ procedure Display(Sender: TObject; Result: TArtifacts);
8182
if not T.FileName.IsEmpty then
8283
Result.SaveToFile(T.FileName);
8384
T.Image. BitMap.LoadFromStream(Stream);
84-
Display(Sender, 'Generation ended successfully');
85+
Display(Sender, 'Operation ended successfully');
8586
finally
8687
Stream.Free;
8788
end;
@@ -119,6 +120,12 @@ procedure Display(Sender: TObject; Value: TJobVideo);
119120
Display(Sender, Value.Id);
120121
end;
121122

123+
procedure Display(Sender: TObject; Value: TEngines);
124+
begin
125+
for var Item in Value.Result do
126+
Display(Sender, Item.Name);
127+
end;
128+
122129
{ TFMXStabilitySender }
123130

124131
constructor TFMXStabilitySender.Create(const AMemo: TMemo;

source/StabilityAI.Version1.Engines.pas

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,83 @@ TEngines = class
138138
/// </remarks>
139139
TAsynEngines = TAsynCallBack<TEngines>;
140140

141+
/// <summary>
142+
/// Represents the API route for managing StabilityAI engines.
143+
/// </summary>
144+
/// <remarks>
145+
/// The <c>TEnginesRoute</c> class provides methods for retrieving a list of engines available to the user or organization.
146+
/// It supports both synchronous and asynchronous operations to cater to different usage scenarios.
147+
/// </remarks>
141148
TEnginesRoute = class(TStabilityAIAPIRoute)
149+
/// <summary>
150+
/// List all engines available to your organization/user
151+
/// <para>
152+
/// NOTE: This method is <c>synchronous</c>
153+
/// </para>
154+
/// </summary>
155+
/// <returns>
156+
/// Returns a <c>TEngines</c> object that contains model informations.
157+
/// </returns>
158+
/// <exception cref="StabilityAIException">
159+
/// Thrown when there is an error in the communication with the API or other underlying issues in the API call.
160+
/// </exception>
161+
/// <exception cref="StabilityAIExceptionBadRequestError">
162+
/// Thrown when the request is invalid, such as when required parameters are missing or values exceed allowed limits.
163+
/// </exception>
164+
/// <remarks>
165+
/// <code>
166+
/// var Stability := TStabilityAIFactory.CreateInstance(BaererKey);
167+
/// var Data := Stability.Version1.Engines.List;
168+
/// try
169+
/// for var Itel in Data.Result do
170+
/// showMesage(Item.Name);
171+
/// finally
172+
/// Data.Free;
173+
/// end;
174+
/// </code>
175+
/// </remarks>
142176
function List: TEngines; overload;
177+
/// <summary>
178+
/// List all engines available to your organization/user
179+
/// <para>
180+
/// NOTE: This method is <c>asynchronous</c>
181+
/// </para>
182+
/// </summary>
183+
/// <param name="ParamProc">
184+
/// A procedure used to configure the parameters for the image creation, such as image, the the format of the output image etc.
185+
/// </param>
186+
/// <param name="CallBacks">
187+
/// A function that returns a record containing event handlers for asynchronous image creation, such as <c>onSuccess</c> and <c>onError</c>.
188+
/// </param>
189+
/// <exception cref="StabilityAIException">
190+
/// Thrown when there is an error in the communication with the API or other underlying issues in the API call.
191+
/// </exception>
192+
/// <exception cref="StabilityAIExceptionBadRequestError">
193+
/// Thrown when the request is invalid, such as when required parameters are missing or values exceed allowed limits.
194+
/// </exception>
195+
/// <remarks>
196+
/// <code>
197+
/// // WARNING - Move the following line to the main OnCreate method for maximum scope.
198+
/// // var Stability := TStabilityAIFactory.CreateInstance(BaererKey);
199+
/// Stability.Version1.Engines.List(
200+
/// function : TAsynEngines
201+
/// begin
202+
/// Result.Sender := my_obj; // Instance passed to callback parameter
203+
///
204+
/// Result.OnStart := nil; // If nil then; Can be omitted
205+
///
206+
/// Result.OnSuccess := procedure (Sender: TObject; Data: TEngines)
207+
/// begin
208+
/// // Handle success operation
209+
/// end;
210+
///
211+
/// Result.OnError := procedure (Sender: TObject; Error: string)
212+
/// begin
213+
/// // Handle error message
214+
/// end;
215+
/// end);
216+
/// </code>
217+
/// </remarks>
143218
procedure List(CallBacks: TFunc<TAsynEngines>); overload;
144219
end;
145220

source/VCL.Stability.Tutorial.pas

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface
1515
uses
1616
System.SysUtils, System.Classes, Vcl.StdCtrls, Vcl.ExtCtrls, Vcl.Controls, Vcl.Forms,
1717
StabilityAI.Common, StabilityAI.Version1.SDXL1AndSD1_6, StabilityAI.VideoAnd3D.Stable3D,
18-
StabilityAI.VideoAnd3D.Video;
18+
StabilityAI.VideoAnd3D.Video, StabilityAI.Version1.Engines;
1919

2020
type
2121
TVCLStabilitySender = class
@@ -39,6 +39,7 @@ TVCLStabilitySender = class
3939
procedure Display(Sender: TObject; Value: TResults); overload;
4040
procedure Display(Sender: TObject; Value: TModel3D); overload;
4141
procedure Display(Sender: TObject; Value: TJobVideo); overload;
42+
procedure Display(Sender: TObject; Value: TEngines); overload;
4243

4344
var
4445
StabilityResult: TVCLStabilitySender = nil;
@@ -47,7 +48,7 @@ implementation
4748

4849
procedure Start(Sender: TObject);
4950
begin
50-
Display(Sender, 'The generation has started. Please wait...');
51+
Display(Sender, 'Request dended. Please wait...');
5152
end;
5253

5354
procedure Display(Sender: TObject; Value: string);
@@ -67,7 +68,7 @@ procedure Display(Sender: TObject; Result: TStableImage);
6768
{--- Display only images }
6869
if not Result.Image.IsEmpty then
6970
T.Image.Picture.LoadFromStream(Stream);
70-
Display(Sender, 'Generation ended successfully');
71+
Display(Sender, 'Operation ended successfully');
7172
finally
7273
Stream.Free;
7374
end;
@@ -81,7 +82,7 @@ procedure Display(Sender: TObject; Result: TArtifacts);
8182
if not T.FileName.IsEmpty then
8283
Result.SaveToFile(T.FileName);
8384
T.Image.Picture.LoadFromStream(Stream);
84-
Display(Sender, 'Generation ended successfully');
85+
Display(Sender, 'Operation ended successfully');
8586
finally
8687
Stream.Free;
8788
end;
@@ -119,6 +120,12 @@ procedure Display(Sender: TObject; Value: TJobVideo);
119120
Display(Sender, Value.Id);
120121
end;
121122

123+
procedure Display(Sender: TObject; Value: TEngines);
124+
begin
125+
for var Item in Value.Result do
126+
Display(Sender, Item.Name);
127+
end;
128+
122129
{ TVCLStabilitySender }
123130

124131
constructor TVCLStabilitySender.Create(const AMemo: TMemo;

0 commit comments

Comments
 (0)