Spaces:
Sleeping
Sleeping
ππ
commited on
Commit
Β·
d7fcbbf
1
Parent(s):
beb52ea
Fix: Update permissions and disable Gradio caching to resolve permission issues
Browse files- Dockerfile +11 -2
- app.py +19 -4
Dockerfile
CHANGED
@@ -27,6 +27,10 @@ RUN apt-get update && apt-get install -y \
|
|
27 |
libasound2 \
|
28 |
&& rm -rf /var/lib/apt/lists/*
|
29 |
|
|
|
|
|
|
|
|
|
30 |
# Copy requirements first for better caching
|
31 |
COPY requirements.txt .
|
32 |
|
@@ -41,14 +45,19 @@ RUN playwright install-deps chromium
|
|
41 |
COPY . .
|
42 |
|
43 |
# Create necessary directories with proper permissions
|
44 |
-
RUN mkdir -p db logs projects screenshots pdfs && \
|
45 |
-
|
|
|
46 |
|
47 |
# Set environment variables
|
48 |
ENV PYTHONUNBUFFERED=1
|
49 |
ENV PYTHONDONTWRITEBYTECODE=1
|
50 |
ENV GRADIO_SERVER_PORT=7860
|
51 |
ENV GRADIO_SERVER_NAME=0.0.0.0
|
|
|
|
|
|
|
|
|
52 |
|
53 |
# Expose port for Gradio
|
54 |
EXPOSE 7860
|
|
|
27 |
libasound2 \
|
28 |
&& rm -rf /var/lib/apt/lists/*
|
29 |
|
30 |
+
# Create a non-root user
|
31 |
+
RUN useradd -m -u 1000 user && \
|
32 |
+
chown -R user:user /code
|
33 |
+
|
34 |
# Copy requirements first for better caching
|
35 |
COPY requirements.txt .
|
36 |
|
|
|
45 |
COPY . .
|
46 |
|
47 |
# Create necessary directories with proper permissions
|
48 |
+
RUN mkdir -p db logs projects screenshots pdfs .gradio && \
|
49 |
+
chown -R user:user /code && \
|
50 |
+
chmod -R 755 /code
|
51 |
|
52 |
# Set environment variables
|
53 |
ENV PYTHONUNBUFFERED=1
|
54 |
ENV PYTHONDONTWRITEBYTECODE=1
|
55 |
ENV GRADIO_SERVER_PORT=7860
|
56 |
ENV GRADIO_SERVER_NAME=0.0.0.0
|
57 |
+
ENV HOME=/code
|
58 |
+
|
59 |
+
# Switch to non-root user
|
60 |
+
USER user
|
61 |
|
62 |
# Expose port for Gradio
|
63 |
EXPOSE 7860
|
app.py
CHANGED
@@ -6,6 +6,7 @@ import gradio as gr
|
|
6 |
from threading import Thread
|
7 |
import tiktoken
|
8 |
import logging
|
|
|
9 |
|
10 |
from src.config import Config
|
11 |
from src.logger import Logger
|
@@ -13,6 +14,13 @@ from src.project import ProjectManager
|
|
13 |
from src.state import AgentState
|
14 |
from src.agents import Agent
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
# Initialize core components
|
17 |
manager = ProjectManager()
|
18 |
AgentState = AgentState()
|
@@ -45,7 +53,12 @@ def process_message(message, base_model="gpt-3.5-turbo", project_name="default",
|
|
45 |
return f"An error occurred: {str(e)}"
|
46 |
|
47 |
def create_gradio_interface():
|
48 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
49 |
gr.Markdown("""
|
50 |
# π€ Devika AI Assistant
|
51 |
|
@@ -83,7 +96,7 @@ def create_gradio_interface():
|
|
83 |
with gr.Column(scale=3):
|
84 |
output_box = gr.Markdown(label="Devika's Response")
|
85 |
|
86 |
-
# Add examples
|
87 |
gr.Examples(
|
88 |
examples=[
|
89 |
["Create a React component for a todo list", "gpt-3.5-turbo", "DuckDuckGo"],
|
@@ -93,7 +106,7 @@ def create_gradio_interface():
|
|
93 |
inputs=[message_input, model_dropdown, search_engine_dropdown],
|
94 |
outputs=output_box,
|
95 |
fn=lambda x, y, z: process_message(x, y, "default", z),
|
96 |
-
cache_examples=
|
97 |
)
|
98 |
|
99 |
submit_btn.click(
|
@@ -112,5 +125,7 @@ if __name__ == "__main__":
|
|
112 |
server_name="0.0.0.0",
|
113 |
server_port=7860,
|
114 |
share=False,
|
115 |
-
debug=False
|
|
|
|
|
116 |
)
|
|
|
6 |
from threading import Thread
|
7 |
import tiktoken
|
8 |
import logging
|
9 |
+
from pathlib import Path
|
10 |
|
11 |
from src.config import Config
|
12 |
from src.logger import Logger
|
|
|
14 |
from src.state import AgentState
|
15 |
from src.agents import Agent
|
16 |
|
17 |
+
# Create necessary directories
|
18 |
+
base_dir = Path("/code")
|
19 |
+
for dir_name in ["db", "logs", "projects", "screenshots", "pdfs", ".gradio"]:
|
20 |
+
dir_path = base_dir / dir_name
|
21 |
+
dir_path.mkdir(exist_ok=True)
|
22 |
+
os.chmod(dir_path, 0o755)
|
23 |
+
|
24 |
# Initialize core components
|
25 |
manager = ProjectManager()
|
26 |
AgentState = AgentState()
|
|
|
53 |
return f"An error occurred: {str(e)}"
|
54 |
|
55 |
def create_gradio_interface():
|
56 |
+
with gr.Blocks(
|
57 |
+
title="Devika AI Assistant",
|
58 |
+
theme=gr.themes.Soft(),
|
59 |
+
analytics_enabled=False,
|
60 |
+
cache_examples=False # Disable example caching to avoid permission issues
|
61 |
+
) as interface:
|
62 |
gr.Markdown("""
|
63 |
# π€ Devika AI Assistant
|
64 |
|
|
|
96 |
with gr.Column(scale=3):
|
97 |
output_box = gr.Markdown(label="Devika's Response")
|
98 |
|
99 |
+
# Add examples without caching
|
100 |
gr.Examples(
|
101 |
examples=[
|
102 |
["Create a React component for a todo list", "gpt-3.5-turbo", "DuckDuckGo"],
|
|
|
106 |
inputs=[message_input, model_dropdown, search_engine_dropdown],
|
107 |
outputs=output_box,
|
108 |
fn=lambda x, y, z: process_message(x, y, "default", z),
|
109 |
+
cache_examples=False # Disable example caching
|
110 |
)
|
111 |
|
112 |
submit_btn.click(
|
|
|
125 |
server_name="0.0.0.0",
|
126 |
server_port=7860,
|
127 |
share=False,
|
128 |
+
debug=False,
|
129 |
+
show_error=True,
|
130 |
+
cache_examples=False # Disable example caching
|
131 |
)
|