Skip to content

Commit 52ba787

Browse files
Merge pull request #39 from DefangLabs/jordan/devex2
A few more developer experience creature comforts
2 parents 0b5bb74 + 8960538 commit 52ba787

File tree

5 files changed

+46
-5
lines changed

5 files changed

+46
-5
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
FROM mcr.microsoft.com/devcontainers/python:3.12-bookworm
1+
FROM mcr.microsoft.com/devcontainers/python:3.9-bookworm

.devcontainer/devcontainer.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,12 @@
66
"features": {
77
"ghcr.io/defanglabs/devcontainer-feature/defang-cli:1.0.4": {},
88
"ghcr.io/devcontainers/features/docker-in-docker:2": {}
9-
}
10-
}
9+
},
10+
"mounts": [
11+
"source=/Users/jordan/.aws,target=/home/vscode/.aws,type=bind,consistency=cached",
12+
],
13+
"forwardPorts": [
14+
5050,
15+
8080
16+
]
17+
}

.vscode/launch.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python Debugger: Flask",
9+
"type": "debugpy",
10+
"request": "launch",
11+
"module": "flask",
12+
"cwd": "${workspaceFolder}/app",
13+
"env": {
14+
"FLASK_APP": "app.py",
15+
"FLASK_DEBUG": "1",
16+
"SECRET_KEY": "supersecret",
17+
"SESSION_COOKIE_SECURE": "0",
18+
"OPENAI_BASE_URL": "http://localhost:8080/api/v1",
19+
"OPENAI_API_KEY": "secret"
20+
},
21+
"args": [
22+
"run",
23+
"--no-reload",
24+
"--host=0.0.0.0",
25+
"--port=5050"
26+
],
27+
"justMyCode": false,
28+
"jinja": true,
29+
"autoStartBrowser": false
30+
}
31+
]
32+
}

app/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import segment.analytics as analytics
88
import uuid
9+
import sys
910

1011
analytics.write_key = os.getenv('SEGMENT_WRITE_KEY')
1112

@@ -53,7 +54,7 @@ def generate():
5354
yield token
5455
full_response += token
5556
except Exception as e:
56-
print(f"Error in /ask endpoint: {e}")
57+
print(f"Error in /ask endpoint: {e}", file=sys.stderr)
5758
yield "Internal Server Error"
5859

5960
if not full_response:

app/rag_system.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import openai
22
import json
33
import os
4+
import sys
45
from datetime import date
56
from sentence_transformers import SentenceTransformer
67
import numpy as np
@@ -155,7 +156,7 @@ def answer_query_stream(self, query):
155156
self.conversation_history.append({"role": "assistant", "content": full_response})
156157

157158
except Exception as e:
158-
print(f"Error in answer_query_stream: {e}")
159+
print(f"Error in answer_query_stream: {e}", file=sys.stderr)
159160
yield "An error occurred while generating the response."
160161

161162
def clear_conversation_history(self):

0 commit comments

Comments
 (0)