Skip to content

Commit 3b07398

Browse files
committed
Update the tinystruct framework version to be 1.4.5
1 parent 10b542f commit 3b07398

File tree

6 files changed

+62
-56
lines changed

6 files changed

+62
-56
lines changed

bin/dispatcher

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env sh
22
ROOT="$(pwd)"
3-
VERSION="1.4.1"
3+
VERSION="1.4.5"
44
cd "$(dirname "$0")" || exit
55
cd "../"
66
# Navigate to the root directory

bin/dispatcher.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ set "JAVA_CMD=%JAVA_HOME%\bin\java.exe"
3333

3434
@REM Consolidate classpath entries, initialize ROOT and VERSION
3535
set "ROOT=%~dp0..\"
36-
set "VERSION=1.4.2"
36+
set "VERSION=1.4.5"
3737
set "classpath=%ROOT%target\classes;%ROOT%lib\tinystruct-%VERSION%-jar-with-dependencies.jar;%ROOT%lib\tinystruct-%VERSION%.jar;%ROOT%lib\*;%ROOT%WEB-INF\lib\*;%ROOT%WEB-INF\classes;%USERPROFILE%\.m2\repository\org\tinystruct\tinystruct\%VERSION%\tinystruct-%VERSION%-jar-with-dependencies.jar;%USERPROFILE%\.m2\repository\org\tinystruct\tinystruct\%VERSION%\tinystruct-%VERSION%.jar"
3838

3939
@REM Run Java application

src/main/java/custom/ai/OpenAI.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,27 @@ public class OpenAI extends AbstractApplication implements Provider {
2020

2121
@Action("openai")
2222
public Builder call() throws ApplicationException {
23-
if (this.context.getAttribute("api") == null) {
23+
if (getContext().getAttribute("api") == null) {
2424
throw new ApplicationException("API is required");
2525
}
2626
Builder payload = null;
2727
String contentType = "application/json";
2828
Object image = null, mask = null;
29-
if (this.context.getAttribute("content-type") != null && this.context.getAttribute("content-type").toString().equalsIgnoreCase("multipart/form-data")) {
29+
if (getContext().getAttribute("content-type") != null && getContext().getAttribute("content-type").toString().equalsIgnoreCase("multipart/form-data")) {
3030
contentType = "multipart/form-data";
3131

32-
if ((image = this.context.getAttribute("image")) != null && image.toString().startsWith("data:image/png;base64,")) {
32+
if ((image = getContext().getAttribute("image")) != null && image.toString().startsWith("data:image/png;base64,")) {
3333
image = image.toString().substring("data:image/png;base64,".length());
3434
}
3535

36-
if ((mask = this.context.getAttribute("mask")) != null && mask.toString().startsWith("data:image/png;base64,")) {
36+
if ((mask = getContext().getAttribute("mask")) != null && mask.toString().startsWith("data:image/png;base64,")) {
3737
mask = mask.toString().substring("data:image/png;base64,".length());
3838
}
39-
} else if (this.context.getAttribute("payload") == null) {
39+
} else if (getContext().getAttribute("payload") == null) {
4040
throw new ApplicationException("Payload is required");
4141
}
4242

43-
String api = this.context.getAttribute("api").toString();
43+
String api = getContext().getAttribute("api").toString();
4444

4545
// Replace YOUR_API_KEY with your actual API key
4646
String API_KEY = this.config.get("openai.api_key");
@@ -52,8 +52,8 @@ public Builder call() throws ApplicationException {
5252
HttpRequestBuilder builder = new HttpRequestBuilder();
5353
builder.setHeaders(headers).setMethod(Method.POST);
5454

55-
if (this.context.getAttribute("payload") != null) {
56-
payload = (Builder) this.context.getAttribute("payload");
55+
if (getContext().getAttribute("payload") != null) {
56+
payload = (Builder) getContext().getAttribute("payload");
5757
if (contentType.equalsIgnoreCase("multipart/form-data")) {
5858
builder.setParameter("prompt", payload.get("prompt").toString());
5959
builder.setParameter("user", payload.get("user").toString());

src/main/java/custom/ai/SearchAI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ public class SearchAI extends AbstractApplication implements Provider {
3030
@Action("search")
3131
@Override
3232
public Builder call() throws ApplicationException {
33-
if (this.context.getAttribute("--query") == null) {
33+
if (getContext().getAttribute("--query") == null) {
3434
throw new ApplicationException("query is required");
3535
}
36-
String query = this.context.getAttribute("--query").toString().trim();
36+
String query = getContext().getAttribute("--query").toString().trim();
3737

3838
HttpRequestBuilder builder = new HttpRequestBuilder();
3939
Headers headers = new Headers();

src/main/java/custom/ai/StabilityAI.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ public class StabilityAI extends AbstractApplication implements Provider {
1717

1818
@Action("stability")
1919
public Builder call() throws ApplicationException {
20-
if (this.context.getAttribute("api") == null) {
20+
if (getContext().getAttribute("api") == null) {
2121
throw new ApplicationException("API is required");
2222
}
2323
Builder payload = null;
2424
String contentType = "application/json";
2525
Object image = null;
26-
if (this.context.getAttribute("content-type") != null && this.context.getAttribute("content-type").toString().equalsIgnoreCase("multipart/form-data")) {
26+
if (getContext().getAttribute("content-type") != null && getContext().getAttribute("content-type").toString().equalsIgnoreCase("multipart/form-data")) {
2727
contentType = "multipart/form-data";
2828

29-
if ((image = this.context.getAttribute("image")) != null && image.toString().startsWith("data:image/png;base64,")) {
29+
if ((image = getContext().getAttribute("image")) != null && image.toString().startsWith("data:image/png;base64,")) {
3030
image = image.toString().substring("data:image/png;base64,".length());
3131
}
32-
} else if (this.context.getAttribute("payload") == null) {
32+
} else if (getContext().getAttribute("payload") == null) {
3333
throw new ApplicationException("Payload is required");
3434
}
3535

36-
String api = this.context.getAttribute("api").toString();
36+
String api = getContext().getAttribute("api").toString();
3737

3838
// Replace YOUR_API_KEY with your actual API key
3939
String API_KEY = this.config.get("stability.api_key");
@@ -47,8 +47,8 @@ public Builder call() throws ApplicationException {
4747
builder.setVersion(Version.HTTP1_1);
4848
builder.setHeaders(headers).setMethod(Method.POST);
4949

50-
if (this.context.getAttribute("payload") != null) {
51-
payload = (Builder) this.context.getAttribute("payload");
50+
if (getContext().getAttribute("payload") != null) {
51+
payload = (Builder) getContext().getAttribute("payload");
5252
if (contentType.equalsIgnoreCase("multipart/form-data")) {
5353
builder.setParameter("text_prompts[0][text]", payload.get("text_prompts[0][text]").toString());
5454
builder.setParameter("cfg_scale", Float.parseFloat(payload.get("cfg_scale").toString()));

0 commit comments

Comments
 (0)