Skip to content

Commit eb94295

Browse files
remove DEBUG mode
1 parent 060432c commit eb94295

File tree

3 files changed

+3
-51
lines changed

3 files changed

+3
-51
lines changed

app/app.py

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def handle_ask_request(request, session):
6868

6969
@app.route('/', methods=['GET', 'POST'])
7070
def index():
71-
return render_template('index.html', debug=os.getenv('DEBUG'))
71+
return render_template('index.html')
7272

7373
@app.route('/ask', methods=['POST'])
7474
def ask():
@@ -135,17 +135,6 @@ def download_file(name):
135135
"data", name, as_attachment=True
136136
)
137137

138-
if os.getenv('DEBUG') == '1':
139-
@app.route('/ask/debug', methods=['POST'])
140-
def debug_context():
141-
data = request.get_json()
142-
query = data.get('query', '')
143-
if not query:
144-
return jsonify({"error": "Query is required"}), 400
145-
context = app.rag_system.get_context(query)
146-
return jsonify({"context": context})
147-
148-
149138
# Handle incoming webhooks from Intercom
150139
@app.route('/intercom-webhook', methods=['POST'])
151140
@csrf.exempt
@@ -186,7 +175,7 @@ def handle_webhook():
186175
if conversation_type == 'email':
187176
logger.info(f"Conversation {conversation_id} is of type email; no action taken.")
188177
return 'OK'
189-
178+
190179
# Check if it is a user reply and do the admin-replied checks if so
191180
# For new user conversations, we will skip admin-replied check to avoid false positives from Intercom auto-replies
192181
if topic == 'conversation.user.replied':

app/templates/index.html

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<meta name="debug" content="{{ debug }}">
76
<title>Ask Defang</title>
87
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/4.0.2/marked.min.js"></script>
98
<link rel="icon" href="{{ url_for('static', filename='images/favicon.ico') }}" type="image/x-icon">
@@ -273,12 +272,7 @@ <h2>Ask Defang</h2>
273272
loadingSpinner.style.display = 'inline-block';
274273
sendButton.disabled = true;
275274

276-
const debug = document.querySelector('meta[name=debug]').content;
277-
if (debug == '1') {
278-
askDebug(query)
279-
} else {
280-
ask(query, responseContainer)
281-
}
275+
ask(query, responseContainer)
282276
}
283277

284278
function ask(query, responseContainer) {
@@ -324,36 +318,6 @@ <h2>Ask Defang</h2>
324318
chatBox.scrollTop = chatBox.scrollHeight;
325319
});
326320
}
327-
328-
function askDebug(query) {
329-
// fetch context for debugging
330-
rateLimitingFetch('/ask/debug', {
331-
method: 'POST',
332-
headers: {
333-
'Content-Type': 'application/json',
334-
'X-CSRFToken': '{{ csrf_token() }}'
335-
},
336-
body: JSON.stringify({ query: query}),
337-
})
338-
.then(response => response.json())
339-
.then(data => {
340-
if (data.error) {
341-
chatBox.innerHTML += `<p><strong>Debug Context:</strong> Error: ${data.error}</p>`;
342-
} else {
343-
chatBox.innerHTML += `<p><strong>Debug Context:</strong> ${data.context}</p>`;
344-
}
345-
chatBox.scrollTop = chatBox.scrollHeight;
346-
loadingSpinner.style.display = 'none';
347-
sendButton.disabled = false;
348-
})
349-
.catch(error => {
350-
console.error('Error:', error);
351-
loadingSpinner.style.display = 'none';
352-
sendButton.disabled = false;
353-
chatBox.innerHTML += '<p><strong>Debug Context:</strong> Error: Failed to get context</p>';
354-
chatBox.scrollTop = chatBox.scrollHeight;
355-
});
356-
}
357321
</script>
358322
</body>
359323
</html>

compose.dev.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ services:
1010
FLASK_APP: app.py
1111
FLASK_ENV: development # Set Flask environment to development
1212
FLASK_DEBUG: 1 # Enable debug mode
13-
DEBUG: 1 # Ensure DEBUG is set to 1
1413
REBUILD_TOKEN: rebuildtoken
1514
SECRET_KEY: supersecret
1615
SEGMENT_WRITE_KEY: ${SEGMENT_WRITE_KEY} # Set your Segment write key here or in the .env file

0 commit comments

Comments
 (0)