update
Browse files- Dockerfile +7 -0
- static/index.html +8 -0
- static/script.js +24 -1
- static/style.css +26 -2
Dockerfile
CHANGED
@@ -9,6 +9,13 @@ COPY ./requirements.txt /code/requirements.txt
|
|
9 |
|
10 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
# download model from transformer
|
13 |
|
14 |
COPY . .
|
|
|
9 |
|
10 |
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
|
11 |
|
12 |
+
# # Install Node.js and npm
|
13 |
+
# RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - \
|
14 |
+
# && apt-get install -y nodejs
|
15 |
+
|
16 |
+
# # Now you can use npm to install packages
|
17 |
+
# RUN npm install -g marked
|
18 |
+
|
19 |
# download model from transformer
|
20 |
|
21 |
COPY . .
|
static/index.html
CHANGED
@@ -4,6 +4,7 @@
|
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<link rel="stylesheet" href="/static/style.css">
|
|
|
7 |
<script src="/static/script.js" defer></script>
|
8 |
<title>ASK-ANRG</title>
|
9 |
</head>
|
@@ -19,7 +20,14 @@
|
|
19 |
<button id="send-btn">Send</button>
|
20 |
</div>
|
21 |
<div class="demo">
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
<h3>Demo Questions</h3>
|
|
|
23 |
<button class="question_btn">Give me a pub of J coleman</button>
|
24 |
<button class="question_btn">What is the position of J coleman (deprecated)</button>
|
25 |
<button class="question_btn">Give me a pub on neural network</button>
|
|
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
<link rel="stylesheet" href="/static/style.css">
|
7 |
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
8 |
<script src="/static/script.js" defer></script>
|
9 |
<title>ASK-ANRG</title>
|
10 |
</head>
|
|
|
20 |
<button id="send-btn">Send</button>
|
21 |
</div>
|
22 |
<div class="demo">
|
23 |
+
<div>
|
24 |
+
<h3>Project Description</h3>
|
25 |
+
<p>Objective: Create an AI Chatbot for research labs equipped to answer inquiries about lab history, members, research papers, projects, and more.</p>
|
26 |
+
<p>Motivation: Research lab websites (like anrg.usc.edu) are frequented by academics, recruiters, collaborators, students, and others seeking information about a lab, its members, and its research. We demonstrate some demo questions below.</p>
|
27 |
+
<p>With the recent advancements in Large Language Models (LLMs), such as ChatGPT, we can develop a bot that provides immediate, direct answers to these and other questions. This initiative will enhance user experience and efficiency, allowing easier access to the lab's information.</p>
|
28 |
+
</div>
|
29 |
<h3>Demo Questions</h3>
|
30 |
+
<p>First enter your own api-key and then ask question through user input or click on one of the demo questions</p>
|
31 |
<button class="question_btn">Give me a pub of J coleman</button>
|
32 |
<button class="question_btn">What is the position of J coleman (deprecated)</button>
|
33 |
<button class="question_btn">Give me a pub on neural network</button>
|
static/script.js
CHANGED
@@ -3,6 +3,22 @@ const userInput = document.getElementById('user-input');
|
|
3 |
const apiKeyInput = document.getElementById('api-key-input');
|
4 |
const chatBox = document.getElementById('chat-box');
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
const questionButtons = document.querySelectorAll('.question_btn');
|
7 |
questionButtons.forEach(btn => {
|
8 |
console.log(btn)
|
@@ -29,6 +45,8 @@ sendBtn.addEventListener('click', () => {
|
|
29 |
chatBox.appendChild(userMessageDiv);
|
30 |
scrollToBottom();
|
31 |
|
|
|
|
|
32 |
// Call FastAPI backend to get response
|
33 |
console.log("type: ", typeof message, typeof apiKey)
|
34 |
fetch('/chat/', {
|
@@ -49,14 +67,19 @@ sendBtn.addEventListener('click', () => {
|
|
49 |
.then(data => {
|
50 |
console.log("data: ", data)
|
51 |
console.log("reply: ", data.response)
|
|
|
|
|
|
|
52 |
// Display chatbot's response
|
53 |
const botMessageDiv = document.createElement('div');
|
54 |
botMessageDiv.className = 'bot-message';
|
55 |
-
botMessageDiv.
|
56 |
chatBox.appendChild(botMessageDiv);
|
|
|
57 |
scrollToBottom();
|
58 |
})
|
59 |
.catch(error => {
|
|
|
60 |
console.log('There was a problem with the fetch operation:', error.message);
|
61 |
});
|
62 |
|
|
|
3 |
const apiKeyInput = document.getElementById('api-key-input');
|
4 |
const chatBox = document.getElementById('chat-box');
|
5 |
|
6 |
+
|
7 |
+
function showTypingIndicator() {
|
8 |
+
const typingIndicatorDiv = document.createElement('div');
|
9 |
+
typingIndicatorDiv.className = 'bot-message typing-indicator';
|
10 |
+
typingIndicatorDiv.innerHTML = '<span>Typing...</span>';
|
11 |
+
chatBox.appendChild(typingIndicatorDiv);
|
12 |
+
scrollToBottom();
|
13 |
+
}
|
14 |
+
|
15 |
+
function removeTypingIndicator() {
|
16 |
+
const typingIndicatorDiv = chatBox.querySelector('.typing-indicator');
|
17 |
+
if (typingIndicatorDiv) {
|
18 |
+
chatBox.removeChild(typingIndicatorDiv);
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
const questionButtons = document.querySelectorAll('.question_btn');
|
23 |
questionButtons.forEach(btn => {
|
24 |
console.log(btn)
|
|
|
45 |
chatBox.appendChild(userMessageDiv);
|
46 |
scrollToBottom();
|
47 |
|
48 |
+
showTypingIndicator();
|
49 |
+
|
50 |
// Call FastAPI backend to get response
|
51 |
console.log("type: ", typeof message, typeof apiKey)
|
52 |
fetch('/chat/', {
|
|
|
67 |
.then(data => {
|
68 |
console.log("data: ", data)
|
69 |
console.log("reply: ", data.response)
|
70 |
+
// Convert Markdown response to HTML
|
71 |
+
removeTypingIndicator();
|
72 |
+
const botMessageHTML = marked.parse(data.response);
|
73 |
// Display chatbot's response
|
74 |
const botMessageDiv = document.createElement('div');
|
75 |
botMessageDiv.className = 'bot-message';
|
76 |
+
botMessageDiv.innerHTML = botMessageHTML;
|
77 |
chatBox.appendChild(botMessageDiv);
|
78 |
+
console.log("botMessageDiv", botMessageDiv)
|
79 |
scrollToBottom();
|
80 |
})
|
81 |
.catch(error => {
|
82 |
+
removeTypingIndicator();
|
83 |
console.log('There was a problem with the fetch operation:', error.message);
|
84 |
});
|
85 |
|
static/style.css
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
body {
|
2 |
font-family: Arial, sans-serif;
|
3 |
background-color: #f4f4f4;
|
4 |
-
margin:
|
5 |
padding: 0;
|
6 |
display: flex;
|
7 |
justify-content: center;
|
@@ -26,6 +26,7 @@ body {
|
|
26 |
}
|
27 |
|
28 |
.demo {
|
|
|
29 |
/* display: flex;
|
30 |
justify-content: flex-end;
|
31 |
align-items: center; */
|
@@ -91,4 +92,27 @@ label {
|
|
91 |
display: block;
|
92 |
margin-bottom: 8px;
|
93 |
font-weight: bold;
|
94 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
body {
|
2 |
font-family: Arial, sans-serif;
|
3 |
background-color: #f4f4f4;
|
4 |
+
margin: 0px;
|
5 |
padding: 0;
|
6 |
display: flex;
|
7 |
justify-content: center;
|
|
|
26 |
}
|
27 |
|
28 |
.demo {
|
29 |
+
margin: 50px auto;
|
30 |
/* display: flex;
|
31 |
justify-content: flex-end;
|
32 |
align-items: center; */
|
|
|
92 |
display: block;
|
93 |
margin-bottom: 8px;
|
94 |
font-weight: bold;
|
95 |
+
}
|
96 |
+
|
97 |
+
/* Add these styles to your style.css */
|
98 |
+
.chat-box {
|
99 |
+
position: relative; /* Needed for absolute positioning context */
|
100 |
+
/* ... other styles ... */
|
101 |
+
}
|
102 |
+
|
103 |
+
.typing-indicator {
|
104 |
+
width: 50px;
|
105 |
+
position: absolute; /* Position the indicator absolutely */
|
106 |
+
bottom: 0; /* Align to the bottom */
|
107 |
+
left: 0; /* Align to the left */
|
108 |
+
padding: 5px 10px; /* Some padding around the text */
|
109 |
+
background-color: #f0f0f0; /* Light gray background */
|
110 |
+
border-radius: 10px;
|
111 |
+
margin: 10px; /* Add some space from the bottom left corner */
|
112 |
+
color: #757575; /* Gray color for the text */
|
113 |
+
font-size: 0.8em; /* Smaller font size */
|
114 |
+
}
|
115 |
+
|
116 |
+
.typing-indicator span {
|
117 |
+
/* You can add styles for the span if needed */
|
118 |
+
}
|