Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files
static/output_images/New Text Document.txt
ADDED
File without changes
|
templates/index.html
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
6 |
+
<title>PDF Q&A Chatbot</title>
|
7 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
|
8 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
9 |
+
<style>
|
10 |
+
/* Full-Screen Styling */
|
11 |
+
html, body {
|
12 |
+
height: 100%;
|
13 |
+
margin: 0;
|
14 |
+
padding: 0;
|
15 |
+
font-family: 'Arial', sans-serif;
|
16 |
+
background-image: url('https://source.unsplash.com/1920x1080/?technology,abstract'); /* Change Background */
|
17 |
+
background-size: cover;
|
18 |
+
background-position: center;
|
19 |
+
}
|
20 |
+
|
21 |
+
.chat-container {
|
22 |
+
display: flex;
|
23 |
+
flex-direction: column;
|
24 |
+
height: 100vh;
|
25 |
+
justify-content: center;
|
26 |
+
align-items: center;
|
27 |
+
}
|
28 |
+
|
29 |
+
.chat-box {
|
30 |
+
width: 80%;
|
31 |
+
max-width: 800px;
|
32 |
+
height: 70vh;
|
33 |
+
overflow-y: auto;
|
34 |
+
background: rgba(255, 255, 255, 0.9);
|
35 |
+
border-radius: 10px;
|
36 |
+
padding: 20px;
|
37 |
+
box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
|
38 |
+
}
|
39 |
+
|
40 |
+
.chat-header {
|
41 |
+
text-align: center;
|
42 |
+
font-size: 22px;
|
43 |
+
font-weight: bold;
|
44 |
+
color: #007bff;
|
45 |
+
padding-bottom: 10px;
|
46 |
+
border-bottom: 2px solid #007bff;
|
47 |
+
margin-bottom: 10px;
|
48 |
+
}
|
49 |
+
|
50 |
+
.message-container {
|
51 |
+
display: flex;
|
52 |
+
flex-direction: column;
|
53 |
+
}
|
54 |
+
|
55 |
+
.user-message, .bot-message {
|
56 |
+
margin: 10px 0;
|
57 |
+
padding: 12px;
|
58 |
+
border-radius: 10px;
|
59 |
+
max-width: 80%;
|
60 |
+
}
|
61 |
+
|
62 |
+
.user-message {
|
63 |
+
background-color: #007bff;
|
64 |
+
color: white;
|
65 |
+
align-self: flex-end;
|
66 |
+
text-align: right;
|
67 |
+
}
|
68 |
+
|
69 |
+
.bot-message {
|
70 |
+
background-color: #f1f1f1;
|
71 |
+
align-self: flex-start;
|
72 |
+
text-align: left;
|
73 |
+
}
|
74 |
+
|
75 |
+
.image-container img {
|
76 |
+
max-width: 100%;
|
77 |
+
border-radius: 5px;
|
78 |
+
margin-top: 5px;
|
79 |
+
}
|
80 |
+
|
81 |
+
.input-group {
|
82 |
+
position: fixed;
|
83 |
+
bottom: 20px;
|
84 |
+
width: 80%;
|
85 |
+
max-width: 800px;
|
86 |
+
}
|
87 |
+
|
88 |
+
.form-control {
|
89 |
+
height: 50px;
|
90 |
+
font-size: 16px;
|
91 |
+
}
|
92 |
+
|
93 |
+
.btn {
|
94 |
+
height: 50px;
|
95 |
+
font-size: 16px;
|
96 |
+
}
|
97 |
+
</style>
|
98 |
+
</head>
|
99 |
+
<body>
|
100 |
+
|
101 |
+
<div class="chat-container">
|
102 |
+
<div class="chat-box" id="chat-box">
|
103 |
+
<div class="chat-header">📜 PDF Q&A Chatbot</div>
|
104 |
+
<div class="message-container"></div>
|
105 |
+
</div>
|
106 |
+
|
107 |
+
<div class="input-group">
|
108 |
+
<input type="text" id="query" class="form-control" placeholder="Ask a question...">
|
109 |
+
<button class="btn btn-primary" onclick="fetchAnswer()">Ask</button>
|
110 |
+
</div>
|
111 |
+
</div>
|
112 |
+
|
113 |
+
<script>
|
114 |
+
function fetchAnswer() {
|
115 |
+
let query = $("#query").val();
|
116 |
+
if (!query) return;
|
117 |
+
|
118 |
+
let userMessage = `<div class="user-message">👤 ${query}</div>`;
|
119 |
+
$("#chat-box .message-container").append(userMessage);
|
120 |
+
$("#query").val("");
|
121 |
+
|
122 |
+
$.ajax({
|
123 |
+
url: "/query",
|
124 |
+
type: "POST",
|
125 |
+
contentType: "application/json",
|
126 |
+
data: JSON.stringify({ query: query }),
|
127 |
+
success: function(response) {
|
128 |
+
let botMessage = `<div class="bot-message">🤖 ${response.text || "No answer found."}</div>`;
|
129 |
+
$("#chat-box .message-container").append(botMessage);
|
130 |
+
|
131 |
+
if (response.images) {
|
132 |
+
let imageContainer = `<div class="image-container">`;
|
133 |
+
response.images.forEach(img => {
|
134 |
+
imageContainer += `<img src="${img}" class="img-fluid">`;
|
135 |
+
});
|
136 |
+
imageContainer += `</div>`;
|
137 |
+
$("#chat-box .message-container").append(imageContainer);
|
138 |
+
}
|
139 |
+
|
140 |
+
$("#chat-box").scrollTop($("#chat-box")[0].scrollHeight);
|
141 |
+
}
|
142 |
+
});
|
143 |
+
}
|
144 |
+
</script>
|
145 |
+
|
146 |
+
</body>
|
147 |
+
</html>
|