Commit 9dbeb09e authored by Mohamad Bashar Desoki's avatar Mohamad Bashar Desoki

empty response issue

parent fd6838ff
......@@ -16,15 +16,23 @@ public class llama3 {
// " \"Assistant\": \" أهلا، أسألني عن أحدث التقنيات لأجيبك\",\n" +
" \"prompt\": \""+ chat +"\"\n" +
"}";
String response = null;
response = sendRequestToAPI(prompt);
String response = sendRequestToAPI(prompt);
// System.out.println(response);
String jsonString = "";
jsonString = response.toString().substring(0,response.length()-51);
return jsonString;
if (response != null) {
jsonString = response.toString().substring(0, response.length() - 51);
jsonString = jsonString + "\n \uD83D\uDC50\uD83C\uDFFB";
return jsonString;
} else {
jsonString = " \n \uD83D\uDC50\uD83C\uDFFB please try again! \uD83D\uDE0A";
return jsonString;
}
}
public String sendRequestToAPI(String prompt) {
public String sendRequestToAPI(String prompt) {
try {
URL url = new URL("https://fumes-api.onrender.com/llama3");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment