Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 18 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ ENV PYTHONDONTWRITEBYTECODE=1 \
MEDEX_ENV=production \
MEDEX_LOG_LEVEL=INFO \
MEDEX_API_PORT=8000 \
MEDEX_UI_PORT=8501
MEDEX_UI_PORT=3000

# Install runtime dependencies only
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 \
libgl1-mesa-glx \
libglib2.0-0 \
libsm6 \
libxext6 \
Expand Down Expand Up @@ -89,7 +89,7 @@ RUN mkdir -p /app/data /app/logs /app/cache /app/rag_cache && \
USER medex

# Expose ports
EXPOSE 8000 8501
EXPOSE 8000 3000

# Health check for API
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
Expand Down Expand Up @@ -135,25 +135,22 @@ HEALTHCHECK --interval=15s --timeout=5s --start-period=20s --retries=2 \
CMD ["python", "-m", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]

# -----------------------------------------------------------------------------
# Stage 4: UI - Streamlit web interface
# Stage 4: UI - Reflex web interface
# -----------------------------------------------------------------------------
FROM production AS ui

# Override healthcheck for Streamlit
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:8501/healthz || exit 1
# Healthcheck for Reflex frontend
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
CMD curl -f http://localhost:3000 || exit 1

# Expose only Streamlit port
EXPOSE 8501
# Expose Reflex default port
EXPOSE 3000

# Environment for Streamlit
ENV STREAMLIT_SERVER_PORT=8501 \
STREAMLIT_SERVER_ADDRESS=0.0.0.0 \
STREAMLIT_SERVER_HEADLESS=true \
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
# Environment for Reflex
ENV REFLEX_ENV_MODE=prod

# Start Streamlit
CMD ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
# Start Reflex (production mode)
CMD ["reflex", "run", "--env", "prod", "--backend-only", "false"]

# -----------------------------------------------------------------------------
# Stage 5: HuggingFace - For Hugging Face Spaces deployment
Expand Down Expand Up @@ -193,11 +190,9 @@ EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD curl -f http://localhost:7860/_stcore/health || exit 1

# Set environment variables for Streamlit
ENV STREAMLIT_SERVER_PORT=7860 \
STREAMLIT_SERVER_ADDRESS=0.0.0.0 \
STREAMLIT_SERVER_HEADLESS=true \
STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
# Environment for Reflex on HuggingFace Spaces
ENV REFLEX_ENV_MODE=prod \
PORT=7860

# Run the Streamlit app
CMD ["streamlit", "run", "streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]
# Run the Reflex app on HF Spaces port
CMD ["reflex", "run", "--env", "prod", "--backend-port", "7860"]
12 changes: 6 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ services:
memory: 1G

# ---------------------------------------------------------------------------
# UI Service - Streamlit Frontend
# UI Service - Reflex Frontend
# ---------------------------------------------------------------------------
ui:
build:
Expand All @@ -177,7 +177,7 @@ services:
container_name: medex-ui
restart: unless-stopped
ports:
- "${MEDEX_UI_PORT:-8501}:8501"
- "${MEDEX_UI_PORT:-3000}:3000"
environment:
- MEDEX_ENV=production
- MEDEX_API_URL=http://api:8000
Expand All @@ -200,11 +200,11 @@ services:
redis:
condition: service_healthy
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8501/healthz"]
test: ["CMD", "curl", "-f", "http://localhost:3000"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
start_period: 60s
networks:
- medex-network
deploy:
Expand Down Expand Up @@ -250,8 +250,8 @@ services:
ports:
- "7860:7860"
environment:
- STREAMLIT_SERVER_PORT=7860
- STREAMLIT_SERVER_ADDRESS=0.0.0.0
- REFLEX_ENV_MODE=prod
- PORT=7860
volumes:
- medex-cache:/home/user/app/cache
networks:
Expand Down
68 changes: 16 additions & 52 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,23 @@ build-backend = "setuptools.build_meta"
[project]
name = "medex"
version = "1.0.0"
description = "Medical AI Intelligence System — dual-mode clinical consultation, emergency detection, RAG knowledge base, and multi-model LLM routing"
description = "Medical AI Intelligence System powered by Kimi K2"
readme = "README.md"
license = {text = "MIT"}
authors = [
{name = "Gonzalo Romero", email = "deeprat.tec@gmail.com"}
{name = "Gonzalo Romero", email = "gonzalorome6@gmail.com"}
]
maintainers = [
{name = "Gonzalo Romero", email = "deeprat.tec@gmail.com"}
{name = "Gonzalo Romero", email = "gonzalorome6@gmail.com"}
]
keywords = [
"medical-ai",
"healthcare",
"rag",
"llm",
"clinical-decision-support",
"emergency-detection",
"medical-imaging",
"fastapi",
"huggingface"
"kimi",
"moonshot",
"reflex",
"clinical-decision-support"
]
classifiers = [
"Development Status :: 4 - Beta",
Expand All @@ -42,22 +40,12 @@ classifiers = [
]
requires-python = ">=3.10"
dependencies = [
"fastapi>=0.104.0",
"uvicorn[standard]>=0.24.0",
"reflex>=0.5.0",
"huggingface-hub>=0.20.0",
"openai>=1.0.0",
"sentence-transformers>=2.2.0",
"qdrant-client>=1.7.0",
"sqlalchemy>=2.0.0",
"alembic>=1.13.0",
"redis>=5.0.0",
"asyncpg>=0.29.0",
"scikit-learn>=1.0.0",
"numpy>=1.21.0",
"Pillow>=8.3.0",
"aiohttp>=3.8.0",
"pydantic>=2.0.0",
"python-dotenv>=1.0.0",
]

[project.optional-dependencies]
Expand All @@ -77,11 +65,11 @@ full = [
]

[project.urls]
Homepage = "https://github.com/DeepRatAI/MedX"
Documentation = "https://github.com/DeepRatAI/MedX#-documentation"
Repository = "https://github.com/DeepRatAI/MedX"
Issues = "https://github.com/DeepRatAI/MedX/issues"
Changelog = "https://github.com/DeepRatAI/MedX/blob/main/CHANGELOG.md"
Homepage = "https://github.com/DeepRatAI/Med-X-KimiK2-RAG"
Documentation = "https://github.com/DeepRatAI/Med-X-KimiK2-RAG#documentation"
Repository = "https://github.com/DeepRatAI/Med-X-KimiK2-RAG"
Issues = "https://github.com/DeepRatAI/Med-X-KimiK2-RAG/issues"
Changelog = "https://github.com/DeepRatAI/Med-X-KimiK2-RAG/blob/main/CHANGELOG.md"

[tool.setuptools.packages.find]
where = ["src"]
Expand All @@ -106,8 +94,6 @@ exclude = '''
[tool.ruff]
line-length = 88
target-version = "py310"

[tool.ruff.lint]
select = [
"E", # pycodestyle errors
"W", # pycodestyle warnings
Expand All @@ -118,22 +104,11 @@ select = [
"UP", # pyupgrade
]
ignore = [
"E501", # line too long (handled by black)
"B008", # do not perform function calls in argument defaults
"I001", # import-sorting (handled by standalone isort in CI)
"I002", # missing-required-import (handled by standalone isort)
"F821", # undefined-name (legacy code, tracked in #2)
"F841", # unused-variable (legacy code, tracked in #2)
"B007", # unused-loop-control-variable
"B905", # zip-without-explicit-strict
"E741", # ambiguous-variable-name
"B904", # raise-without-from-inside-except
"E712", # true-false-comparison
"B027", # empty-method-without-abstract-decorator
"C401", # unnecessary-generator-set
"E501", # line too long (handled by black)
"B008", # do not perform function calls in argument defaults
]

[tool.ruff.lint.isort]
[tool.ruff.isort]
known-first-party = ["medex"]

[tool.mypy]
Expand All @@ -145,17 +120,6 @@ disallow_incomplete_defs = true
check_untyped_defs = true
ignore_missing_imports = true

[tool.isort]
profile = "black"
line_length = 88
known_first_party = ["medex"]
skip_gitignore = true

[tool.bandit]
exclude_dirs = ["tests", "scripts"]
# B101: assert used (test helper), B104: bind 0.0.0.0 (intentional for Docker containers)
skips = ["B101", "B104"]

[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
Expand Down
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ httpx>=0.25.0
# OpenAI SDK for Moonshot AI (Kimi API)
openai>=1.0.0

# Streamlit for Web Interface
streamlit>=1.28.0
streamlit-chat>=0.1.1
# UI Framework (Reflex)
# Note: Reflex is managed via its own CLI (reflex init / reflex run)
# and is not listed here as a pip dependency.

# Image Processing (for medical imaging)
Pillow>=8.3.0
Expand Down
Loading