Posts

styles.css

  body {     font-family : Arial , sans-serif ;     background-color : # f4f4f4 ;     display : flex ;     justify-content : center ;     align-items : center ;     height : 100 vh ;     margin : 0 ; } . chat-container {     width : 400 px ;     max-width : 100 % ;     background-color : white ;     padding : 20 px ;     border-radius : 8 px ;     box-shadow : 0 0 10 px rgba ( 0 , 0 , 0 , 0.1 ); } . chat-box {     height : 300 px ;     overflow-y : auto ;     border-bottom : 1 px solid # ddd ;     margin-bottom : 10 px ; } . user-message , . bot-message {     padding : 10 px ;     margin : 5 px 0 ;     border-radius : 8 px ; } . user-message {     background-color : # dcf8c6 ;     align-self : flex-end ;     text-align...

index.html

  <!DOCTYPE html > <html lang = " en " > <head>     <meta charset = " UTF-8 " >     <meta name = " viewport " content = " width=device-width, initial-scale=1.0 " >     <title> Chatbot </title>     <link rel = " stylesheet " href = " /static/styles.css " > </head> <body>     <div class = " chat-container " >         <div id = " chat-box " class = " chat-box " ></div>         <input type = " text " id = " user-input " placeholder = " Type your message here... " onkeydown = " if ( event . key === ' Enter ' ) sendMessage () " >         <button onclick = " sendMessage () " > Send </button>     </div>     <script>         async function sendMessage () {             const inputBox = document...

App.py(Python Web framework using flask)

  from flask import Flask , request , jsonify , render_template import json from difflib import get_close_matches from typing import Optional , List , Dict # File path as a constant KNOWLEDGE_BASE_FILE = ' knowledgeBase.json ' app = Flask ( __name__ ) def load_knowledge_base ( file_path : str ) -> Dict :     with open ( file_path , ' r ' ) as file:         data = json . load (file)     return data def save_knowledge_base ( file_path : str , data : Dict ) -> None :     with open ( file_path , ' w ' ) as file:         json . dump ( data , file, indent = 2 ) def find_best_match ( user_question : str , questions : List [ str ] ) -> Optional [ str ]:     matches = get_close_matches ( user_question , questions , n = 1 , cutoff = 0.75 )     return matches [ 0 ] if matches else None def get_answer_for_question ( question : str , knowledge_...

knowledgeBase.json

  {   " questions " : [     {       " question " : "hello" ,       " answer " : "Hey There!"     },     {       " question " : "How are you?" ,       " answer " : "I am fine . What's about you?"     },     {       " question " : "I am also fine." ,       " answer " : "That's great!"     },     {       " question " : "Do you know that you are a Bot?" ,       " answer " : "Yes, I know. "     },     {       " question " : "What's Your name?" ,       " answer " : "I am Kulpi."     },     {       " question " : "who are you?" ,       " answer " : "I am Kulpi."     },     {       " question " : "how do you do?" ,       " answer " : "I...

Main.py(poulami,Shreya)

  import json from difflib import get_close_matches from typing import Optional , List , Dict # File path as a constant KNOWLEDGE_BASE_FILE = ' knowledgeBase.json ' def load_knowledge_base ( file_path : str ) -> Dict :     with open ( file_path , ' r ' ) as file:         data = json . load (file)     return data def save_knowledge_base ( file_path : str , data : Dict ) -> None :     with open ( file_path , ' w ' ) as file:         json . dump ( data , file, indent = 2 ) def find_best_match ( user_question : str , questions : List [ str ] ) -> Optional [ str ]:     matches = get_close_matches ( user_question , questions , n = 1 , cutoff = 0.9 )     return matches [ 0 ] if matches else None def get_answer_for_question ( question : str , knowledge_base : Dict ) -> Optional [ str ]:     return knowledge_base [ " questions " ...