Commit
·
b791c4a
1
Parent(s):
d076bff
MikeD Fixes
Browse files- Dockerfile +26 -6
- app.py +7 -2
Dockerfile
CHANGED
@@ -1,11 +1,31 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
2 |
RUN useradd -m -u 1000 user
|
3 |
USER user
|
|
|
|
|
4 |
ENV HOME=/home/user \
|
5 |
-
PATH=/home/user/.local/bin:$PATH
|
|
|
|
|
|
|
|
|
|
|
6 |
WORKDIR $HOME/app
|
|
|
|
|
7 |
COPY --chown=user . $HOME/app
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# Get a distribution that has uv already installed
|
3 |
+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
|
4 |
+
|
5 |
+
# Add user - this is the user that will run the app
|
6 |
+
# If you do not set user, the app will run as root (undesirable)
|
7 |
RUN useradd -m -u 1000 user
|
8 |
USER user
|
9 |
+
|
10 |
+
# Set the home directory and path
|
11 |
ENV HOME=/home/user \
|
12 |
+
PATH=/home/user/.local/bin:$PATH
|
13 |
+
|
14 |
+
ENV UVICORN_WS_PROTOCOL=websockets
|
15 |
+
|
16 |
+
|
17 |
+
# Set the working directory
|
18 |
WORKDIR $HOME/app
|
19 |
+
|
20 |
+
# Copy the app to the container
|
21 |
COPY --chown=user . $HOME/app
|
22 |
+
|
23 |
+
# Install the dependencies
|
24 |
+
# RUN uv sync --frozen
|
25 |
+
RUN uv sync
|
26 |
+
|
27 |
+
# Expose the port
|
28 |
+
EXPOSE 7860
|
29 |
+
|
30 |
+
# Run the app
|
31 |
+
CMD ["uv", "run", "chainlit", "run", "app.py", "--host", "0.0.0.0", "--port", "7860"]
|
app.py
CHANGED
@@ -56,8 +56,13 @@ def process_text_file(file: AskFileResponse):
|
|
56 |
with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".txt") as temp_file:
|
57 |
temp_file_path = temp_file.name
|
58 |
|
|
|
|
|
|
|
59 |
with open(temp_file_path, "wb") as f:
|
60 |
-
f.write(
|
|
|
|
|
61 |
|
62 |
text_loader = TextFileLoader(temp_file_path)
|
63 |
documents = text_loader.load_documents()
|
@@ -81,7 +86,7 @@ async def on_chat_start():
|
|
81 |
file = files[0]
|
82 |
|
83 |
msg = cl.Message(
|
84 |
-
content=f"Processing `{file.name}`..."
|
85 |
)
|
86 |
await msg.send()
|
87 |
|
|
|
56 |
with tempfile.NamedTemporaryFile(mode="w", delete=False, suffix=".txt") as temp_file:
|
57 |
temp_file_path = temp_file.name
|
58 |
|
59 |
+
with open(file.path, "rb") as f:
|
60 |
+
content = f.read()
|
61 |
+
|
62 |
with open(temp_file_path, "wb") as f:
|
63 |
+
f.write(content)
|
64 |
+
|
65 |
+
#file response no longer has a content field
|
66 |
|
67 |
text_loader = TextFileLoader(temp_file_path)
|
68 |
documents = text_loader.load_documents()
|
|
|
86 |
file = files[0]
|
87 |
|
88 |
msg = cl.Message(
|
89 |
+
content=f"Processing `{file.name}`..."
|
90 |
)
|
91 |
await msg.send()
|
92 |
|