VibecoderMcSwaggins commited on
Commit
36983ae
·
1 Parent(s): 25c3a8b

refactor(phase4): address CodeRabbit review

Browse files

- Pin uv version in Dockerfile and add non-root user
- Use OrchestratorConfig for timeout in app.py
- Use timezone.utc for timestamps in models.py

Files changed (3) hide show
  1. Dockerfile +9 -1
  2. src/app.py +7 -7
  3. src/utils/models.py +2 -2
Dockerfile CHANGED
@@ -10,7 +10,7 @@ RUN apt-get update && apt-get install -y \
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
  # Install uv
13
- RUN pip install uv
14
 
15
  # Copy project files
16
  COPY pyproject.toml .
@@ -21,9 +21,17 @@ COPY README.md .
21
  # Install dependencies
22
  RUN uv sync --frozen --no-dev
23
 
 
 
 
 
24
  # Expose port
25
  EXPOSE 7860
26
 
 
 
 
 
27
  # Set environment variables
28
  ENV GRADIO_SERVER_NAME=0.0.0.0
29
  ENV GRADIO_SERVER_PORT=7860
 
10
  && rm -rf /var/lib/apt/lists/*
11
 
12
  # Install uv
13
+ RUN pip install uv==0.5.4
14
 
15
  # Copy project files
16
  COPY pyproject.toml .
 
21
  # Install dependencies
22
  RUN uv sync --frozen --no-dev
23
 
24
+ # Create non-root user
25
+ RUN useradd --create-home --shell /bin/bash appuser
26
+ USER appuser
27
+
28
  # Expose port
29
  EXPOSE 7860
30
 
31
+ # Health check
32
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
33
+ CMD curl -f http://localhost:7860/ || exit 1
34
+
35
  # Set environment variables
36
  ENV GRADIO_SERVER_NAME=0.0.0.0
37
  ENV GRADIO_SERVER_PORT=7860
src/app.py CHANGED
@@ -24,10 +24,16 @@ def create_orchestrator(use_mock: bool = False) -> Orchestrator:
24
  Returns:
25
  Configured Orchestrator instance
26
  """
 
 
 
 
 
 
27
  # Create search tools
28
  search_handler = SearchHandler(
29
  tools=[PubMedTool(), WebTool()],
30
- timeout=30.0,
31
  )
32
 
33
  # Create judge (mock or real)
@@ -37,12 +43,6 @@ def create_orchestrator(use_mock: bool = False) -> Orchestrator:
37
  else:
38
  judge_handler = JudgeHandler()
39
 
40
- # Create orchestrator
41
- config = OrchestratorConfig(
42
- max_iterations=5,
43
- max_results_per_tool=10,
44
- )
45
-
46
  return Orchestrator(
47
  search_handler=search_handler,
48
  judge_handler=judge_handler,
 
24
  Returns:
25
  Configured Orchestrator instance
26
  """
27
+ # Create orchestrator config
28
+ config = OrchestratorConfig(
29
+ max_iterations=5,
30
+ max_results_per_tool=10,
31
+ )
32
+
33
  # Create search tools
34
  search_handler = SearchHandler(
35
  tools=[PubMedTool(), WebTool()],
36
+ timeout=config.search_timeout,
37
  )
38
 
39
  # Create judge (mock or real)
 
43
  else:
44
  judge_handler = JudgeHandler()
45
 
 
 
 
 
 
 
46
  return Orchestrator(
47
  search_handler=search_handler,
48
  judge_handler=judge_handler,
src/utils/models.py CHANGED
@@ -1,6 +1,6 @@
1
  """Data models for the Search feature."""
2
 
3
- from datetime import datetime
4
  from typing import Any, ClassVar, Literal
5
 
6
  from pydantic import BaseModel, Field
@@ -109,7 +109,7 @@ class AgentEvent(BaseModel):
109
  ]
110
  message: str
111
  data: Any = None
112
- timestamp: datetime = Field(default_factory=datetime.now)
113
  iteration: int = 0
114
 
115
  def to_markdown(self) -> str:
 
1
  """Data models for the Search feature."""
2
 
3
+ from datetime import UTC, datetime
4
  from typing import Any, ClassVar, Literal
5
 
6
  from pydantic import BaseModel, Field
 
109
  ]
110
  message: str
111
  data: Any = None
112
+ timestamp: datetime = Field(default_factory=lambda: datetime.now(UTC))
113
  iteration: int = 0
114
 
115
  def to_markdown(self) -> str: