Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
Django Mantenga la conexión con la ruta a través de la interfaz independiente

Estoy trabajando en un chatbot y quiero implementarlo en Django pero estoy usando una interfaz independiente. Tengo poco o ningún conocimiento sobre JavaScript y copié este script de algún lado:

 onSendButton(chatbox) { var textField=chatbox.querySelector('input'); let text1=textField.value if(text1==="") { return; } let msg1={name: "User", message: text1} this.messages.push(msg1); this.updateChatText(chatbox) textField.value='' fetch('http://localhost:8000/chat', { method: 'POST', body: JSON.stringify({message: text1}), mode: 'cors', headers: { 'Content-Type': 'application/json' }, }) .then(r => r.json()) .then(r => { console.log(r) let msg2={name: "CareAll", message: r.answer}; this.messages.push(msg2); if("follow_up" in r) { let msg3={name: "CareAll", message: r.follow_up}; this.messages.push(msg3) } this.updateChatText(chatbox) textField.value='' }).catch((error) => { console.error('Error:', error); this.updateChatText(chatbox) textField.value='' }); }

Esta función es para / ruta de chat

 def chat_bot_response(request): if request.method == "POST": u_msg = json.loads(request.body)["message"] ints = predict_class(u_msg, cb_model) resp = {"answer": getResponse(ints, intents)} maxConf = max(ints, key=lambda x: x["probability"]) if maxConf["intent"] not in [ "greeting", "farewell", "about_self", "about_self_function", "question", "unknown", "yes_to_symptom", "no_to_symptom"]: RESP_LIST.append(resp["answer"]) resp["answer"] = "Do You Have other symptoms?" if maxConf["intent"] == "yes_to_symptom": print(RESP_LIST) elif maxConf["intent"] == "no_to_symptom": resp["answer"] = RESP_LIST[0] return JsonResponse(resp)

Lo que estoy tratando de hacer es permanecer en esta función cuando se abra el cuadro de chat hasta que el usuario abandone la página. ¿Tendré que mejorar JavaScript? usar la plantilla de Django? cual es la posible solucion.

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!