srinidhidevaraj commited on
Commit
53a8795
1 Parent(s): 7f694dd

Add application file

Browse files
Dockerfile ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9
2
+
3
+ RUN useradd -m -u 1000 user
4
+
5
+ WORKDIR /app
6
+
7
+ COPY --chown=user ./requirements.txt requirements.txt
8
+
9
+ RUN pip install --no-cache-dir --upgrade -r requirements.txt
10
+
11
+ COPY --chown=user . /app
12
+
13
+ CMD ["flask", "run", "--host", "0.0.0.0:7860"]
14
+ # CMD ["gunicorn", "-b", "--host", "0.0.0.0:7860", "main:app"]
app.py ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask,render_template,jsonify,request
2
+ from src.helper import *
3
+ from src.prompt import *
4
+
5
+ from langchain_groq import ChatGroq
6
+ from langchain_community.document_loaders import WebBaseLoader
7
+ from langchain_community.embeddings import OllamaEmbeddings
8
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
9
+ from langchain.chains.combine_documents import create_stuff_documents_chain
10
+ from langchain_core.prompts import ChatPromptTemplate
11
+ from langchain.chains import create_retrieval_chain
12
+ from langchain_community.vectorstores import FAISS
13
+ from langchain_community.document_loaders import PyPDFLoader
14
+ from langchain_community.document_loaders import PyPDFDirectoryLoader
15
+ from langchain_community.embeddings import HuggingFaceBgeEmbeddings
16
+ # from langchain.vectorstores.cassandra import Cassandra
17
+ from langchain_community.vectorstores import Cassandra
18
+ from langchain.prompts import PromptTemplate
19
+ from langchain_community.llms import Ollama
20
+ from cassandra.auth import PlainTextAuthProvider
21
+ import tempfile
22
+ import cassio
23
+ from PyPDF2 import PdfReader
24
+ from cassandra.cluster import Cluster
25
+ import warnings
26
+ warnings.filterwarnings("ignore")
27
+ import os
28
+ from dotenv import load_dotenv
29
+ import time
30
+ load_dotenv()
31
+ app = Flask(__name__)
32
+
33
+ groq_api_key=os.environ['GROQ_API_KEY']
34
+ LANGCHAIN_TRACING_V2="true"
35
+ LANGCHAIN_API_KEY=os.getenv('LANGCHAIN_API_KEY')
36
+ LANGCHAIN_PROJECT="medical_bot"
37
+ LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
38
+
39
+ prompt=PromptTemplate(template=prompt_template, input_variables=["context", "question"])
40
+ # print(PROMPT)
41
+ llm=ChatGroq(groq_api_key=groq_api_key,model_name="mixtral-8x7b-32768")
42
+ file_path="data/Medical_book.pdf"
43
+ pinecone_vector_store=doc_loader(file_path)
44
+
45
+ print(type(pinecone_vector_store))
46
+ def generate_response(llm,prompt,pinecone_vector_store,question):
47
+
48
+ # print('HELLO!Im from gen reponse fn')
49
+ document_chain=create_stuff_documents_chain(llm,prompt)
50
+ # print('document chain:',prompt)
51
+ retriever=pinecone_vector_store.as_retriever(search_type="similarity",search_kwargs={"k":5})
52
+ # print('HELLO!Im after retriever')
53
+ retrieval_chain=create_retrieval_chain(retriever,document_chain)
54
+ # print('HELLO!Im after retrieval chain')
55
+ response=retrieval_chain.invoke({"input":question})
56
+ # print('im response from fn',response)
57
+ return response
58
+
59
+ @app.route("/")
60
+ def index():
61
+ return render_template('chat.html')
62
+
63
+ @app.route("/get", methods=["GET", "POST"])
64
+ def chat():
65
+ msg = request.form["msg"]
66
+ question = msg
67
+ print(question)
68
+ result=generate_response(llm,prompt,pinecone_vector_store,question)
69
+ # print("Response : ", result['answer'])
70
+ return result['answer']
71
+
72
+
73
+ if __name__ == '__main__':
74
+ app.run(host="0.0.0.0", port= 8080, debug= True)
75
+
requirements.txt ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ctransformers==0.2.5
2
+ sentence-transformers==2.2.2
3
+ langchain
4
+ pinecone-client
5
+ # langchain==0.0.225
6
+ flask
7
+ streamlit
8
+ google-generativeai
9
+ python-dotenv
10
+ langchain
11
+ PyPDF2
12
+ chromadb
13
+ faiss-cpu
14
+ langchain_google_genai
15
+ langchain-community
16
+ pdf2image
17
+ langsmith
18
+ ollama
19
+ langserve
20
+ fastapi
21
+ uvicorn
22
+ sse_starlette
23
+ bs4
24
+ wikipedia
25
+ arxiv
26
+ langchainhub
27
+ cassio
28
+ beautifulsoup4
29
+ langchain-groq
30
+ sentence_transformers
31
+ astrapy
32
+ langchain_pinecone
33
+ flask
34
+ huggingface_hub[cli]
35
+ -e .
src/__init__.py ADDED
File without changes
src/__pycache__/__init__.cpython-310.pyc ADDED
Binary file (134 Bytes). View file
 
src/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (150 Bytes). View file
 
src/__pycache__/helper.cpython-310.pyc ADDED
Binary file (2.78 kB). View file
 
src/__pycache__/helper.cpython-311.pyc ADDED
Binary file (5.12 kB). View file
 
src/__pycache__/prompt.cpython-311.pyc ADDED
Binary file (446 Bytes). View file
 
src/helper.py ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ from langchain_groq import ChatGroq
4
+ from langchain_community.document_loaders import WebBaseLoader
5
+ from langchain_community.embeddings import OllamaEmbeddings
6
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
7
+ from langchain.chains.combine_documents import create_stuff_documents_chain
8
+ from langchain_core.prompts import ChatPromptTemplate
9
+ from langchain.chains import create_retrieval_chain
10
+ from langchain_community.vectorstores import FAISS
11
+ from langchain_community.document_loaders import PyPDFLoader
12
+ from langchain_community.document_loaders import PyPDFDirectoryLoader
13
+ from langchain_community.embeddings import HuggingFaceBgeEmbeddings
14
+ # from langchain.vectorstores.cassandra import Cassandra
15
+ from langchain_community.vectorstores import Cassandra
16
+ from langchain_community.llms import Ollama
17
+ from cassandra.auth import PlainTextAuthProvider
18
+ import tempfile
19
+ import cassio
20
+ from PyPDF2 import PdfReader
21
+ from cassandra.cluster import Cluster
22
+ import warnings
23
+ from langchain.vectorstores import Pinecone
24
+ import pinecone
25
+ from pinecone import Pinecone, ServerlessSpec
26
+ from langchain_pinecone import PineconeVectorStore
27
+ warnings.filterwarnings("ignore")
28
+
29
+ from dotenv import load_dotenv
30
+ import time
31
+ load_dotenv()
32
+
33
+ ASTRA_DB_SECURE_BUNDLE_PATH ="G:/GENAI/Medical_chat_bot/src/secure-connect-medical-bot.zip"
34
+ LANGCHAIN_TRACING_V2"]="true"
35
+ LANGCHAIN_API_KEY=os.getenv('LANGCHAIN_API_KEY')
36
+ LANGCHAIN_PROJECT="Medical_chatbot"
37
+ LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
38
+
39
+ def doc_loader(pdf_reader):
40
+ # print('im from doc_loc fn')
41
+ encode_kwargs = {'normalize_embeddings': True}
42
+ huggigface_embeddings=HuggingFaceBgeEmbeddings(
43
+ model_name='BAAI/bge-small-en-v1.5',
44
+ # model_name='sentence-transformers/all-MiniLM-16-v2',
45
+ model_kwargs={'device':'cpu'},
46
+ encode_kwargs=encode_kwargs)
47
+
48
+
49
+ loader=PyPDFLoader(pdf_reader)
50
+ documents=loader.load_and_split()
51
+ # print('iam after documents loader called')
52
+
53
+ text_splitter=RecursiveCharacterTextSplitter(chunk_size=1000,chunk_overlap=200)
54
+ final_documents=text_splitter.split_documents(documents)
55
+ # print('iam after final_documents called',final_documents)
56
+
57
+ os.environ['PINECONE_API_KEY'] = os.environ['pinecone']
58
+ os.environ['PINECONE_API_ENV'] = "pdf_query_db"
59
+ pc = Pinecone(api_key=os.getenv('PINECONE_API_KEY'))
60
+
61
+ index = pc.Index("pdf-query-index")
62
+ namespace = "pdf_query_medical"
63
+
64
+ def namespace_exists(index, namespace):
65
+ try:
66
+ stats = index.describe_index_stats()
67
+ return namespace in stats['namespaces']
68
+ except pinecone.core.client.exceptions.NotFoundException:
69
+ return False
70
+ if namespace_exists(index, namespace):
71
+ print(f"Namespace '{namespace}' exist.")
72
+ pinecone_vector_store = PineconeVectorStore(embedding=huggigface_embeddings,index_name="pdf-query-index", namespace=namespace)
73
+ # pinecone_vector_store = index.query(f"SELECT * FROM {namespace}")
74
+ # return pinecone_vector_store
75
+ else:
76
+ print(f"Namespace '{namespace}' does not exist. It will be created upon upsertion.")
77
+
78
+
79
+ pinecone_vector_store=PineconeVectorStore(embedding=huggigface_embeddings,index_name="pdf-query-index",namespace=namespace)
80
+
81
+ pinecone_vector_store.add_documents(final_documents)
82
+
83
+ return pinecone_vector_store
84
+
85
+
86
+
87
+
88
+ # def doc_loader(pdf_reader):
89
+ # # print('im from doc_loc fn')
90
+ # encode_kwargs = {'normalize_embeddings': True}
91
+ # huggigface_embeddings=HuggingFaceBgeEmbeddings(
92
+ # model_name='BAAI/bge-small-en-v1.5',
93
+ # # model_name='sentence-transformers/all-MiniLM-16-v2',
94
+ # model_kwargs={'device':'cpu'},
95
+ # encode_kwargs=encode_kwargs)
96
+
97
+
98
+ # loader=PyPDFLoader(pdf_reader)
99
+ # documents=loader.load_and_split()
100
+ # # print('iam after documents loader called')
101
+
102
+ # text_splitter=RecursiveCharacterTextSplitter(chunk_size=1000,chunk_overlap=200)
103
+ # final_documents=text_splitter.split_documents(documents)
104
+ # # print('iam after final_documents called',final_documents)
105
+
106
+ # astrasession = Cluster(
107
+ # cloud={"secure_connect_bundle": ASTRA_DB_SECURE_BUNDLE_PATH},
108
+ # auth_provider=PlainTextAuthProvider("token", ASTRA_DB_APPLICATION_TOKEN),
109
+ # ).connect()
110
+
111
+
112
+
113
+ # check_table_query = f"""
114
+ # SELECT table_name FROM system_schema.tables
115
+ # WHERE keyspace_name='{ASTRA_DB_KEYSPACE}' AND table_name='{ASTRA_DB_TABLE}';
116
+ # """
117
+
118
+
119
+ # try:
120
+
121
+ # result = astrasession.execute(check_table_query)
122
+
123
+ # if result.one():
124
+ # return_query=f""" select * from '{ASTRA_DB_KEYSPACE}'.'{ASTRA_DB_TABLE}'; """
125
+ # astra_vector_store=astrasession.execute(return_query)
126
+ # return astra_vector_store
127
+
128
+
129
+ # else:
130
+
131
+ # print(f"Table {ASTRA_DB_KEYSPACE}.{ASTRA_DB_TABLE} does not exist. Try to create table.")
132
+
133
+
134
+ # astra_vector_store=Cassandra(
135
+ # embedding=huggigface_embeddings,
136
+ # table_name='medical_bot_demo',
137
+ # session=astrasession,
138
+ # keyspace=ASTRA_DB_KEYSPACE
139
+ # )
140
+
141
+
142
+ # astra_vector_store.add_documents(final_documents)
143
+ # if astra_vector_store:
144
+ # print("Vector store created successfully")
145
+
146
+ # return astra_vector_store
147
+ # except Exception as e:
148
+ # print(f"Error checking/creating keyspace: {e}")
149
+
src/prompt.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ prompt_template="""
2
+ Use the following pieces of information to answer the user's question.
3
+ If you don't know the answer, just say that you don't know, don't try to make up an answer.
4
+
5
+ Context: {context}
6
+ Question: {input}
7
+
8
+ Only return the helpful answer below and nothing else.
9
+ Helpful answer:
10
+ """
src/secure-connect-medical-bot.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9976f3d6ec4a0d9459267c3bea8c2990695fff6b83b62cba92e5e5991c4c9dc
3
+ size 12244
static/.gitkeep ADDED
File without changes
static/bg1.jpeg ADDED
static/bg2.jpeg ADDED
static/style.css ADDED
@@ -0,0 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body,html{
2
+ height: 100%;
3
+ margin: 0;
4
+ background: rgb(44, 47, 59);
5
+ background: -webkit-linear-gradient(to right, rgb(40, 59, 34), rgb(54, 60, 70), rgb(32, 32, 43));
6
+ background: linear-gradient(to right, rgb(38, 51, 61), rgb(50, 55, 65), rgb(33, 33, 78));
7
+ }
8
+
9
+ .chat{
10
+ margin-top: auto;
11
+ margin-bottom: auto;
12
+ }
13
+ .card{
14
+ height: 500px;
15
+ border-radius: 15px !important;
16
+ background-color: rgba(0,0,0,0.4) !important;
17
+ }
18
+ .contacts_body{
19
+ padding: 0.75rem 0 !important;
20
+ overflow-y: auto;
21
+ white-space: nowrap;
22
+ }
23
+ .msg_card_body{
24
+ overflow-y: auto;
25
+ }
26
+ .card-header{
27
+ border-radius: 15px 15px 0 0 !important;
28
+ border-bottom: 0 !important;
29
+ }
30
+ .card-footer{
31
+ border-radius: 0 0 15px 15px !important;
32
+ border-top: 0 !important;
33
+ }
34
+ .container{
35
+ align-content: center;
36
+ }
37
+ .search{
38
+ border-radius: 15px 0 0 15px !important;
39
+ background-color: rgba(0,0,0,0.3) !important;
40
+ border:0 !important;
41
+ color:white !important;
42
+ }
43
+ .search:focus{
44
+ box-shadow:none !important;
45
+ outline:0px !important;
46
+ }
47
+ .type_msg{
48
+ background-color: rgba(0,0,0,0.3) !important;
49
+ border:0 !important;
50
+ color:white !important;
51
+ height: 60px !important;
52
+ overflow-y: auto;
53
+ }
54
+ .type_msg:focus{
55
+ box-shadow:none !important;
56
+ outline:0px !important;
57
+ }
58
+ .attach_btn{
59
+ border-radius: 15px 0 0 15px !important;
60
+ background-color: rgba(0,0,0,0.3) !important;
61
+ border:0 !important;
62
+ color: white !important;
63
+ cursor: pointer;
64
+ }
65
+ .send_btn{
66
+ border-radius: 0 15px 15px 0 !important;
67
+ background-color: rgba(0,0,0,0.3) !important;
68
+ border:0 !important;
69
+ color: white !important;
70
+ cursor: pointer;
71
+ }
72
+ .search_btn{
73
+ border-radius: 0 15px 15px 0 !important;
74
+ background-color: rgba(0,0,0,0.3) !important;
75
+ border:0 !important;
76
+ color: white !important;
77
+ cursor: pointer;
78
+ }
79
+ .contacts{
80
+ list-style: none;
81
+ padding: 0;
82
+ }
83
+ .contacts li{
84
+ width: 100% !important;
85
+ padding: 5px 10px;
86
+ margin-bottom: 15px !important;
87
+ }
88
+ .active{
89
+ background-color: rgba(0,0,0,0.3);
90
+ }
91
+ .user_img{
92
+ height: 70px;
93
+ width: 70px;
94
+ border:1.5px solid #f5f6fa;
95
+
96
+ }
97
+ .user_img_msg{
98
+ height: 40px;
99
+ width: 40px;
100
+ border:1.5px solid #f5f6fa;
101
+
102
+ }
103
+ .img_cont{
104
+ position: relative;
105
+ height: 70px;
106
+ width: 70px;
107
+ }
108
+ .img_cont_msg{
109
+ height: 40px;
110
+ width: 40px;
111
+ }
112
+ .online_icon{
113
+ position: absolute;
114
+ height: 15px;
115
+ width:15px;
116
+ background-color: #4cd137;
117
+ border-radius: 50%;
118
+ bottom: 0.2em;
119
+ right: 0.4em;
120
+ border:1.5px solid white;
121
+ }
122
+ .offline{
123
+ background-color: #c23616 !important;
124
+ }
125
+ .user_info{
126
+ margin-top: auto;
127
+ margin-bottom: auto;
128
+ margin-left: 15px;
129
+ }
130
+ .user_info span{
131
+ font-size: 20px;
132
+ color: white;
133
+ }
134
+ .user_info p{
135
+ font-size: 10px;
136
+ color: rgba(255,255,255,0.6);
137
+ }
138
+ .video_cam{
139
+ margin-left: 50px;
140
+ margin-top: 5px;
141
+ }
142
+ .video_cam span{
143
+ color: white;
144
+ font-size: 20px;
145
+ cursor: pointer;
146
+ margin-right: 20px;
147
+ }
148
+ .msg_cotainer{
149
+ margin-top: auto;
150
+ margin-bottom: auto;
151
+ margin-left: 10px;
152
+ border-radius: 25px;
153
+ background-color: rgb(82, 172, 255);
154
+ padding: 10px;
155
+ position: relative;
156
+ }
157
+ .msg_cotainer_send{
158
+ margin-top: auto;
159
+ margin-bottom: auto;
160
+ margin-right: 10px;
161
+ border-radius: 25px;
162
+ background-color: #58cc71;
163
+ padding: 10px;
164
+ position: relative;
165
+ }
166
+ .msg_time{
167
+ position: absolute;
168
+ left: 0;
169
+ bottom: -15px;
170
+ color: rgba(255,255,255,0.5);
171
+ font-size: 10px;
172
+ }
173
+ .msg_time_send{
174
+ position: absolute;
175
+ right:0;
176
+ bottom: -15px;
177
+ color: rgba(255,255,255,0.5);
178
+ font-size: 10px;
179
+ }
180
+ .msg_head{
181
+ position: relative;
182
+ }
183
+ #action_menu_btn{
184
+ position: absolute;
185
+ right: 10px;
186
+ top: 10px;
187
+ color: white;
188
+ cursor: pointer;
189
+ font-size: 20px;
190
+ }
191
+ .action_menu{
192
+ z-index: 1;
193
+ position: absolute;
194
+ padding: 15px 0;
195
+ background-color: rgba(0,0,0,0.5);
196
+ color: white;
197
+ border-radius: 15px;
198
+ top: 30px;
199
+ right: 15px;
200
+ display: none;
201
+ }
202
+ .action_menu ul{
203
+ list-style: none;
204
+ padding: 0;
205
+ margin: 0;
206
+ }
207
+ .action_menu ul li{
208
+ width: 100%;
209
+ padding: 10px 15px;
210
+ margin-bottom: 5px;
211
+ }
212
+ .action_menu ul li i{
213
+ padding-right: 10px;
214
+ }
215
+ .action_menu ul li:hover{
216
+ cursor: pointer;
217
+ background-color: rgba(0,0,0,0.2);
218
+ }
219
+ @media(max-width: 576px){
220
+ .contacts_card{
221
+ margin-bottom: 15px !important;
222
+ }
223
+ }
templates/chat.html ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
2
+ <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
3
+ <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
4
+
5
+ <!DOCTYPE html>
6
+ <html>
7
+ <head>
8
+ <title>Chatbot</title>
9
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
10
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
11
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
12
+ <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css')}}"/>
13
+ </head>
14
+
15
+
16
+ <body>
17
+ <div class="container-fluid h-100">
18
+ <div class="row justify-content-center h-100">
19
+ <div class="col-md-8 col-xl-6 chat">
20
+ <div class="card">
21
+ <div class="card-header msg_head">
22
+ <div class="d-flex bd-highlight">
23
+ <div class="img_cont">
24
+ <!-- <img src="https://i.ibb.co/fSNP7Rz/icons8-chatgpt-512.png" class="rounded-circle user_img"> -->
25
+ <img src="https://www.prdistribution.com/spirit/uploads/pressreleases/2019/newsreleases/d83341deb75c4c4f6b113f27b1e42cd8-chatbot-florence-already-helps-thousands-of-patients-to-remember-their-medication.png" class="rounded-circle user_img">
26
+ <span class="online_icon"></span>
27
+ </div>
28
+ <div class="user_info">
29
+ <span>Medical Chatbot</span>
30
+ <p>Ask me anything!</p>
31
+ </div>
32
+ </div>
33
+ </div>
34
+ <div id="messageFormeight" class="card-body msg_card_body">
35
+
36
+
37
+ </div>
38
+ <div class="card-footer">
39
+ <form id="messageArea" class="input-group">
40
+ <input type="text" id="text" name="msg" placeholder="Type your message..." autocomplete="off" class="form-control type_msg" required/>
41
+ <div class="input-group-append">
42
+ <button type="submit" id="send" class="input-group-text send_btn"><i class="fas fa-location-arrow"></i></button>
43
+ </div>
44
+ </form>
45
+ </div>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ </div>
50
+
51
+ <script>
52
+ $(document).ready(function() {
53
+ $("#messageArea").on("submit", function(event) {
54
+ const date = new Date();
55
+ const hour = date.getHours();
56
+ const minute = date.getMinutes();
57
+ const str_time = hour+":"+minute;
58
+ var rawText = $("#text").val();
59
+
60
+ var userHtml = '<div class="d-flex justify-content-end mb-4"><div class="msg_cotainer_send">' + rawText + '<span class="msg_time_send">'+ str_time + '</span></div><div class="img_cont_msg"><img src="https://i.ibb.co/d5b84Xw/Untitled-design.png" class="rounded-circle user_img_msg"></div></div>';
61
+
62
+ $("#text").val("");
63
+ $("#messageFormeight").append(userHtml);
64
+
65
+ $.ajax({
66
+ data: {
67
+ msg: rawText,
68
+ },
69
+ type: "POST",
70
+ url: "/get",
71
+ }).done(function(data) {
72
+ var botHtml = '<div class="d-flex justify-content-start mb-4"><div class="img_cont_msg"><img src="https://www.prdistribution.com/spirit/uploads/pressreleases/2019/newsreleases/d83341deb75c4c4f6b113f27b1e42cd8-chatbot-florence-already-helps-thousands-of-patients-to-remember-their-medication.png" class="rounded-circle user_img_msg"></div><div class="msg_cotainer">' + data + '<span class="msg_time">' + str_time + '</span></div></div>';
73
+ $("#messageFormeight").append($.parseHTML(botHtml));
74
+ });
75
+ event.preventDefault();
76
+ });
77
+ });
78
+ </script>
79
+
80
+ </body>
81
+ </html>