Skip to content

Commit 63e607c

Browse files
authored
Merge branch 'main' into linda-test-chatbot
2 parents 5224e86 + 6cde831 commit 63e607c

16 files changed

+72
-32
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
.env
2+
__pycache__
3+
sentence-transformers
24
.tmp/*
35
!.tmp/prebuild.sh

app/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ COPY . /app
3939
# Make the prebuild.sh script executable
4040
RUN chmod +x .tmp/prebuild.sh
4141

42-
# Expose port 5000 for the Flask application
43-
EXPOSE 5000
42+
# Expose port 5050 for the Flask application
43+
EXPOSE 5050
4444

4545
# Define environment variable for Flask
4646
ENV FLASK_APP=app.py
4747

4848
# Run the application using uWSGI
49-
CMD ["uwsgi", "--http", "0.0.0.0:5000", "--wsgi-file", "app.py", "--callable", "app", "--processes", "4", "--threads", "2"]
49+
CMD ["uwsgi", "--http", "0.0.0.0:5050", "--wsgi-file", "app.py", "--callable", "app", "--processes", "4", "--threads", "2"]

app/app.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
analytics.write_key = os.getenv('SEGMENT_WRITE_KEY')
1111

12-
app = Flask(__name__, static_folder='templates/images')
12+
app = Flask(__name__, static_folder='templates/static')
1313
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY')
1414
app.config['SESSION_COOKIE_HTTPONLY'] = True
1515
app.config['SESSION_COOKIE_SECURE'] = bool(os.getenv('SESSION_COOKIE_SECURE'))
@@ -40,7 +40,7 @@ def ask():
4040

4141
if not query:
4242
return jsonify({"error": "No query provided"}), 400
43-
43+
4444
# For analytics tracking, generates an anonymous id and uses it for the session
4545
if 'anonymous_id' not in session:
4646
session['anonymous_id'] = str(uuid.uuid4())
@@ -59,12 +59,13 @@ def generate():
5959
if not full_response:
6060
full_response = "No response generated"
6161

62-
# Track the query and response
63-
analytics.track(
64-
anonymous_id=anonymous_id,
65-
event='Chatbot Question submitted',
66-
properties={'query': query, 'response': full_response, 'source': 'Ask Defang'}
67-
)
62+
if analytics.write_key:
63+
# Track the query and response
64+
analytics.track(
65+
anonymous_id=anonymous_id,
66+
event='Chatbot Question submitted',
67+
properties={'query': query, 'response': full_response, 'source': 'Ask Defang'}
68+
)
6869

6970
return Response(stream_with_context(generate()), content_type='text/markdown')
7071

@@ -107,5 +108,4 @@ def debug_context():
107108
context = rag_system.get_context(query)
108109
return jsonify({"context": context})
109110

110-
if __name__ == '__main__':
111-
app.run(host='0.0.0.0', port=5000, static_url_path='/static')
111+
app.run(host='0.0.0.0', port=5050)

app/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Werkzeug==2.0.3
44
scikit-learn==0.24.2
55
segment-analytics-python==2.3.3
66
numpy==1.22.0
7-
sentence-transformers==2.1.0
7+
sentence-transformers==2.2.1
88
torch==1.10.0
99
huggingface_hub==0.8.1
1010
openai==0.28.0

app/templates/images/defang_icon.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)