Skip to content

Commit febcc81

Browse files
Merge branch 'main' into eric/add-linter
2 parents 4efa19d + acc4c71 commit febcc81

File tree

5 files changed

+38
-20
lines changed

5 files changed

+38
-20
lines changed

app/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,4 @@ EXPOSE 5050
4949
ENV FLASK_APP=app.py
5050

5151
# Run the application using uWSGI
52-
# CMD ["uwsgi", "--lazy-apps", "--http", "0.0.0.0:5050", "--wsgi-file", "app.py", "--callable", "app", "--processes", "4"]
53-
# longer timeout settings to allow for slower rag and llm responses
54-
CMD ["uwsgi", "--lazy-apps", "--http", "0.0.0.0:5050", "--wsgi-file", "app.py", "--callable", "app", "--processes", "4", "--harakiri", "300", "--socket-timeout", "300", "--http-timeout", "300", "--http-keepalive", "--http-auto-chunked"]
52+
CMD ["uwsgi", "--lazy-apps", "--http", "0.0.0.0:5050", "--wsgi-file", "app.py", "--callable", "app", "--processes", "2"]

app/get_knowledge_base.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import re
44
import json
55
from git import Repo
6+
import logging
67

78
kb_file_path = "./data/knowledge_base.json"
89

@@ -33,23 +34,26 @@ def setup_repositories():
3334
for repo_name, repo_url in repos.items():
3435
clone_repository(repo_url, os.path.join(tmp_dir, repo_name))
3536

36-
37-
def run_prebuild_script():
38-
"""Run the defang-docs repo prebuild script"""
39-
40-
subprocess.run(
41-
["npm", "-C", ".tmp/defang-docs", "install"],
42-
check=True,
37+
def run_command(cmd):
38+
process = subprocess.Popen(
39+
cmd,
4340
stdout=subprocess.PIPE,
4441
stderr=subprocess.PIPE,
42+
text=True,
4543
)
44+
for line in process.stdout:
45+
logging.info(line.rstrip())
46+
for line in process.stderr:
47+
logging.error(line.rstrip())
48+
process.wait()
49+
if process.returncode != 0:
50+
raise RuntimeError(f"Command {cmd} failed with return code {process.returncode}")
4651

47-
subprocess.run(
48-
["npm", "-C", ".tmp/defang-docs", "run", "prebuild"],
49-
check=True,
50-
stdout=subprocess.PIPE,
51-
stderr=subprocess.PIPE,
52-
)
52+
def run_prebuild_script():
53+
""" Run the defang-docs repo prebuild script"""
54+
55+
run_command(["npm", "-C", ".tmp/defang-docs", "--loglevel=error", "install"])
56+
run_command(["npm", "-C", ".tmp/defang-docs", "run", "prebuild"])
5357

5458

5559
def parse_markdown():

app/templates/index.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
</a>
202202
</div>
203203
<h2>Ask Defang</h2>
204-
<div id="chat-box" class="chat-box"></div>
204+
<div id="chat-box" class="chat-box">Welcome to Ask Defang. Let's start chatting!</div>
205205
<input type="text" autofocus="autofocus" id="query-input" class="input-box" placeholder="Ask a question...">
206206
<button id="send-button" class="submit-btn">
207207
Send
@@ -260,9 +260,25 @@ <h2>Ask Defang</h2>
260260
// Display user query
261261
chatBox.innerHTML += `<p><strong>You:</strong> ${query}</p>`;
262262

263+
let processingMsg = `Processing<span class="loading-dots"><span>.</span><span>.</span><span>.</span></span>`;
264+
// Animate the loading dots
265+
setTimeout(() => {
266+
const dots = responseContainer?.querySelectorAll('.loading-dots span');
267+
if (!dots) return;
268+
let visible = 1;
269+
const interval = setInterval(() => {
270+
dots.forEach((dot, idx) => {
271+
dot.style.visibility = idx < visible ? 'visible' : 'hidden';
272+
});
273+
visible = visible < 3 ? visible + 1 : 1;
274+
// Stop animation when spinner is hidden (response received)
275+
if (loadingSpinner.style.display === 'none') clearInterval(interval);
276+
}, 400);
277+
}, 0);
278+
263279
// Create a new response container for this query
264280
const responseContainer = document.createElement('p');
265-
responseContainer.innerHTML = `<strong>Assistant:</strong> <span class="assistant-response"></span>`;
281+
responseContainer.innerHTML = `<strong>Assistant:</strong> <span class="assistant-response">${processingMsg}</span>`;
266282
chatBox.appendChild(responseContainer);
267283

268284
chatBox.scrollTop = chatBox.scrollHeight;

compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
resources:
3131
reservations:
3232
memory: 4G
33-
cpus: 2.0
33+
cpus: 1.0
3434
healthcheck:
3535
test: ["CMD", "curl", "-f", "http://localhost:5050/"]
3636
interval: 30s

discord-bot/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ app.post('/interactions', verifyKeyMiddleware(process.env.DISCORD_PUBLIC_KEY), a
222222
type: InteractionResponseType.CHANNEL_MESSAGE_WITH_SOURCE,
223223
data: {
224224
// Fetches a random emoji to send from a helper function
225-
content: `Develop Anything, Deploy Anywhere ${getRandomEmoji()}`,
225+
content: `Develop Once, Deploy Anywhere ${getRandomEmoji()}`,
226226
},
227227
});
228228
}

0 commit comments

Comments
 (0)