Commit 3b8104ad authored by Kavindu Randika's avatar Kavindu Randika

bug fixing 2

parent ca4e7ca5
...@@ -93,7 +93,8 @@ public class ChatFragment extends Fragment { ...@@ -93,7 +93,8 @@ public class ChatFragment extends Fragment {
chatRvAdpater.notifyDataSetChanged(); chatRvAdpater.notifyDataSetChanged();
String url = "http://10.0.2.2:8000/api/chatbot"; String url = "http://10.0.2.2:8000/api/chatbot";
String baseurl = "http://10.0.2.2:8000/api/chatbot"; String baseurl = "http://10.0.2.2:8000/api/chatbot";
String quary = "{\n \"msg\": \"hi\"\n}"; String userText = userEdittext.getText().toString();
String quary = "{\n \"msg\": \""+userText+"\"\n}";
JSONObject jsonBody = new JSONObject(quary); JSONObject jsonBody = new JSONObject(quary);
System.out.println("here"); System.out.println("here");
JsonObjectRequest req = new JsonObjectRequest(Request.Method.POST,url, jsonBody, new Response.Listener<JSONObject>() { JsonObjectRequest req = new JsonObjectRequest(Request.Method.POST,url, jsonBody, new Response.Listener<JSONObject>() {
...@@ -103,6 +104,16 @@ public class ChatFragment extends Fragment { ...@@ -103,6 +104,16 @@ public class ChatFragment extends Fragment {
System.out.println(response); System.out.println(response);
try { try {
String bot_msg = (String) response.get("msg"); String bot_msg = (String) response.get("msg");
String tag_1 = "<pad>";
String tag_2 = "</s>";
if(bot_msg.contains(tag_1)){
bot_msg = bot_msg.replaceAll(tag_1,"");
}
if(bot_msg.contains(tag_2)){
bot_msg = bot_msg.replaceAll(tag_2,"");
}
System.out.println(bot_msg); System.out.println(bot_msg);
chatModals.add(new ChatModal(bot_msg,BOT_KEY)); chatModals.add(new ChatModal(bot_msg,BOT_KEY));
chatRvAdpater.notifyDataSetChanged(); chatRvAdpater.notifyDataSetChanged();
......
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