//Chatbot Question -> NLP Nonsense model public OffensivenessModelRequest(ChatbotNewQuestionModel chatbotNewQuestionModel) { this.question = chatbotNewQuestionModel.question; this.question_id = chatbotNewQuestionModel.chatbot_temp_id; this.msg_id = ServerUtilities.getAndGenerateMsgIDForGivenQuestion(chatbotNewQuestionModel.user_id, chatbotNewQuestionModel.question, chatbotNewQuestionModel.chatbot_temp_id); this.action = "IS_NONSENSE".ToLower(); }
internal static void CheckIfQuestionIsNonsense(ChatbotNewQuestionModel chatbotNewQuestionModel) { var temp = new OffensivenessModelRequest(chatbotNewQuestionModel); if (connections.ContainsKey("NLP") && connections["NLP"] != null && connections["NLP"].State == WebSocketState.Open && temp != null) { String json = JsonSerializer.Serialize(temp); connections["NLP"].SendAsync(new ArraySegment <byte>(usedEncoding.GetBytes(json), 0, json.Length), WebSocketMessageType.Text, true, CancellationToken.None); } else { taskQueue.Enqueue(new NLPTask <ChatbotNewQuestionModel>(chatbotNewQuestionModel, CheckIfQuestionIsNonsense)); } }