@@ -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 ());
0 commit comments