Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
pom.xml
CHANGED
|
@@ -37,7 +37,11 @@
|
|
| 37 |
</dependency>
|
| 38 |
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
<!-- JavaMail API -->
|
| 43 |
<dependency>
|
|
@@ -93,11 +97,7 @@
|
|
| 93 |
</dependency>
|
| 94 |
|
| 95 |
|
| 96 |
-
|
| 97 |
-
<groupId>io.github.cdimascio</groupId>
|
| 98 |
-
<artifactId>java-dotenv</artifactId>
|
| 99 |
-
<version>5.2.2</version>
|
| 100 |
-
</dependency>
|
| 101 |
<dependency>
|
| 102 |
<groupId>javax</groupId>
|
| 103 |
<artifactId>javaee-web-api</artifactId>
|
|
|
|
| 37 |
</dependency>
|
| 38 |
|
| 39 |
|
| 40 |
+
<dependency>
|
| 41 |
+
<groupId>io.github.cdimascio</groupId>
|
| 42 |
+
<artifactId>java-dotenv</artifactId>
|
| 43 |
+
<version>5.2.2</version>
|
| 44 |
+
</dependency>
|
| 45 |
|
| 46 |
<!-- JavaMail API -->
|
| 47 |
<dependency>
|
|
|
|
| 97 |
</dependency>
|
| 98 |
|
| 99 |
|
| 100 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
<dependency>
|
| 102 |
<groupId>javax</groupId>
|
| 103 |
<artifactId>javaee-web-api</artifactId>
|
src/main/java/CrewAIUtil/Communicator.java
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
package CrewAIUtil;
|
| 2 |
|
|
|
|
| 3 |
import java.io.*;
|
| 4 |
import java.net.HttpURLConnection;
|
| 5 |
import java.net.SocketTimeoutException;
|
|
@@ -12,7 +13,38 @@ import org.json.JSONTokener;
|
|
| 12 |
*/
|
| 13 |
public class Communicator {
|
| 14 |
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
private static final int CONNECT_TIMEOUT = 15000; // 15 sec
|
| 18 |
private static final int READ_TIMEOUT = 300000; // 5 min
|
|
|
|
| 1 |
package CrewAIUtil;
|
| 2 |
|
| 3 |
+
import io.github.cdimascio.dotenv.Dotenv;
|
| 4 |
import java.io.*;
|
| 5 |
import java.net.HttpURLConnection;
|
| 6 |
import java.net.SocketTimeoutException;
|
|
|
|
| 13 |
*/
|
| 14 |
public class Communicator {
|
| 15 |
|
| 16 |
+
|
| 17 |
+
private static final Dotenv dotenv;
|
| 18 |
+
static {
|
| 19 |
+
Dotenv tempDotenv = null;
|
| 20 |
+
try {
|
| 21 |
+
tempDotenv = Dotenv.configure()
|
| 22 |
+
.filename("/.env") // Leading slash instructs classpath lookup
|
| 23 |
+
.ignoreIfMalformed()
|
| 24 |
+
.ignoreIfMissing()
|
| 25 |
+
.load();
|
| 26 |
+
} catch (Exception e) {
|
| 27 |
+
// Suppress initialization container logging errors safely
|
| 28 |
+
}
|
| 29 |
+
dotenv = tempDotenv;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
private static String getEnvVar(String key) {
|
| 33 |
+
if (dotenv != null) {
|
| 34 |
+
String value = dotenv.get(key);
|
| 35 |
+
if (value != null && !value.trim().isEmpty()) {
|
| 36 |
+
return value.trim();
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
// Fallback directly to System OS Environment or Properties
|
| 40 |
+
String systemVal = System.getenv(key);
|
| 41 |
+
if (systemVal != null && !systemVal.trim().isEmpty()) {
|
| 42 |
+
return systemVal.trim();
|
| 43 |
+
}
|
| 44 |
+
return System.getProperty(key, "");
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
private static final String BASE_URL = getEnvVar("BASE_URL");
|
| 48 |
|
| 49 |
private static final int CONNECT_TIMEOUT = 15000; // 15 sec
|
| 50 |
private static final int READ_TIMEOUT = 300000; // 5 min
|
src/main/java/CrewAIUtil/CrewResponseStream.java
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
package CrewAIUtil;
|
| 2 |
|
|
|
|
| 3 |
import org.json.JSONObject;
|
| 4 |
import javax.servlet.ServletException;
|
| 5 |
import javax.servlet.annotation.WebServlet;
|
|
@@ -21,8 +22,43 @@ import java.io.PrintWriter;
|
|
| 21 |
*/
|
| 22 |
@WebServlet(name = "CrewResponseStreamServlet", urlPatterns = {"/CrewResponseStream"})
|
| 23 |
public class CrewResponseStream extends HttpServlet {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
private static final int POLL_DELAY = 5000; // ms between status polls
|
| 27 |
private static final int MAX_POLLS = 72; // 72 × 5s = 6 minutes max wait
|
| 28 |
|
|
|
|
| 1 |
package CrewAIUtil;
|
| 2 |
|
| 3 |
+
import io.github.cdimascio.dotenv.Dotenv;
|
| 4 |
import org.json.JSONObject;
|
| 5 |
import javax.servlet.ServletException;
|
| 6 |
import javax.servlet.annotation.WebServlet;
|
|
|
|
| 22 |
*/
|
| 23 |
@WebServlet(name = "CrewResponseStreamServlet", urlPatterns = {"/CrewResponseStream"})
|
| 24 |
public class CrewResponseStream extends HttpServlet {
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
private static final Dotenv dotenv;
|
| 28 |
+
static {
|
| 29 |
+
Dotenv tempDotenv = null;
|
| 30 |
+
try {
|
| 31 |
+
tempDotenv = Dotenv.configure()
|
| 32 |
+
.filename("/.env") // Leading slash instructs classpath lookup
|
| 33 |
+
.ignoreIfMalformed()
|
| 34 |
+
.ignoreIfMissing()
|
| 35 |
+
.load();
|
| 36 |
+
} catch (Exception e) {
|
| 37 |
+
// Suppress initialization container logging errors safely
|
| 38 |
+
}
|
| 39 |
+
dotenv = tempDotenv;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
private static String getEnvVar(String key) {
|
| 43 |
+
if (dotenv != null) {
|
| 44 |
+
String value = dotenv.get(key);
|
| 45 |
+
if (value != null && !value.trim().isEmpty()) {
|
| 46 |
+
return value.trim();
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
// Fallback directly to System OS Environment or Properties
|
| 50 |
+
String systemVal = System.getenv(key);
|
| 51 |
+
if (systemVal != null && !systemVal.trim().isEmpty()) {
|
| 52 |
+
return systemVal.trim();
|
| 53 |
+
}
|
| 54 |
+
return System.getProperty(key, "");
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
private static final String BASE_URL = getEnvVar("BASE_URL");
|
| 58 |
+
|
| 59 |
+
|
| 60 |
|
| 61 |
+
|
| 62 |
private static final int POLL_DELAY = 5000; // ms between status polls
|
| 63 |
private static final int MAX_POLLS = 72; // 72 × 5s = 6 minutes max wait
|
| 64 |
|