Skip to content

Feature cache cleaning#5

Merged
qchapp merged 18 commits into
mainfrom
feature-cache_cleaning
Oct 22, 2025
Merged

Feature cache cleaning#5
qchapp merged 18 commits into
mainfrom
feature-cache_cleaning

Conversation

@qchapp
Copy link
Copy Markdown
Member

@qchapp qchapp commented Oct 22, 2025

This pull request introduces several improvements for development workflow, deployment, and project documentation. It adds a full devcontainer setup for VS Code, a GitHub Actions workflow for building and publishing Docker images, and updates documentation to reflect these changes. It also includes a new changelog and minor configuration and dependency updates.

Development Environment & Tooling

  • Added a .devcontainer setup (.devcontainer/Dockerfile, .devcontainer/devcontainer.json) for reproducible VS Code development environments using a prebuilt Python 3.12 image, user setup, and convenient extensions. [1] [2]
  • Introduced a justfile with common development and serving commands for streamlined local workflows.

Deployment & CI/CD

  • Added a GitHub Actions workflow (.github/workflows/publish_image_in_GHCR.yaml) to automatically build, tag, and publish Docker images to GHCR on pushes and PRs, including release note extraction from the changelog and cleanup of PR images.
  • Updated the documentation and added instructions for building and running the Docker image, including environment variable usage.

Documentation & Project Organization

  • Added comprehensive project architecture and workflow documentation in .github/copilot-instructions.md, covering system design, data flow, error handling, and conventions.
  • Introduced a CHANGELOG.md following Keep a Changelog conventions, and updated the project version in pyproject.toml. [1] [2]
  • Updated .env.dist and README.md to clarify environment variable usage and reflect changes to model configuration. [1] [2]

Dependencies

  • Added pydantic-ai to the project dependencies in pyproject.toml.

These changes collectively improve the developer experience, streamline deployment, and clarify project usage and structure.

@qchapp qchapp requested a review from Copilot October 22, 2025 14:44
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces an experimental Pydantic AI agent architecture with tool-based retrieval, along with Docker deployment infrastructure, developer environment improvements, and enhanced temp file cleanup. The agent provides an alternative execution pathway (feature flag USE_AGENT=1) that uses structured tool calls instead of the original VLM pipeline for tool selection.

Key Changes:

  • Adds Pydantic AI agent with tool-based retrieval (search, rerank, repo_info, resolve_demo_link)
  • Introduces Docker/devcontainer infrastructure for reproducible development and deployment
  • Implements systematic temp file cleanup for preview and DICOM extraction directories
  • Simplifies environment variable naming (consolidates model configuration)

Reviewed Changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/ai_agent/agent/agent.py New agent orchestration with tool registration and execution flow
src/ai_agent/agent/tools/*.py Tool implementations for search, rerank, repo_info, and Gradio space interaction
src/ai_agent/agent/utils.py Agent state management and per-tool quota enforcement
src/ai_agent/api/pipeline.py Adds agent-facing APIs (retrieve_no_rerank, rerank_only, get_doc)
src/ai_agent/ui/app.py Integrates agent pathway with USE_AGENT flag and port fallback logic
src/ai_agent/utils/*.py Enhanced temp file cleanup, improved runnable link selection
tools/image/Dockerfile Production Docker image with uv package manager
.devcontainer/* VS Code devcontainer setup for consistent development
.github/workflows/publish_image_in_GHCR.yaml CI/CD workflow for automated Docker publishing
pyproject.toml Version bump and pydantic-ai dependency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread tools/image/Dockerfile
RUN source .venv/bin/activate && uv pip install -e .

EXPOSE 7860
ENTRYPOINT ["source .venv/bin/activate && python -m ai_agent.app"] No newline at end of file
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ENTRYPOINT exec form does not invoke a shell, so this will attempt to execute 'source' as a binary rather than sourcing the venv. Use CMD with shell form or switch to: ENTRYPOINT [\"/bin/bash\", \"-c\", \"source .venv/bin/activate && python -m ai_agent.app\"]

Suggested change
ENTRYPOINT ["source .venv/bin/activate && python -m ai_agent.app"]
ENTRYPOINT ["/bin/bash", "-c", "source .venv/bin/activate && python -m ai_agent.app"]

Copilot uses AI. Check for mistakes.
t = str(spec.get("type") or spec.get("component") or "").lower()
# Gradio client supports passing file paths for image inputs
if "image" in t and image_path:
payload.append(handle_file(image_path) if handle_file else image_path)
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conditional if handle_file will always be True since handle_file is imported at the module level. If the intention is to guard against import failures, wrap the import in a try/except and set a default. Otherwise, remove the conditional.

Suggested change
payload.append(handle_file(image_path) if handle_file else image_path)
payload.append(handle_file(image_path))

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to modify that because gradio space tool will be changed soon

"""Return the best runnable demo link for a tool (if any)."""
link = None
try:
pipe = RAGImagingPipeline(docs=[])
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new empty RAGImagingPipeline instance will not have access to the loaded catalog docs. Use get_pipeline() from .tools.utils instead to access the shared pipeline instance with the full catalog.

Copilot uses AI. Check for mistakes.
Comment thread src/ai_agent/agent/agent.py Outdated
Comment thread .devcontainer/Dockerfile Outdated
Comment thread tools/image/Dockerfile Outdated
Comment thread src/ai_agent/ui/app.py
return
except OSError as e: # port busy
last_err = e
busy = "Cannot find empty port" in str(e)
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message check 'Cannot find empty port' may not match the actual OSError message for port-in-use conditions. Verify the actual error message or use errno.EADDRINUSE for more reliable detection.

Copilot uses AI. Check for mistakes.
- name: Extract version from pyproject.toml
id: project_version
run: |
VERSION=$(grep 'version =' pyproject.toml | sed -E 's/version = "([^"]+)"/\1/')
Copy link

Copilot AI Oct 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The grep pattern 'version =' (with space before equals) won't match the actual format in pyproject.toml which uses 'version=' (no space). Change to grep 'version=' pyproject.toml or use a more flexible pattern.

Suggested change
VERSION=$(grep 'version =' pyproject.toml | sed -E 's/version = "([^"]+)"/\1/')
VERSION=$(grep -E '^\s*version\s*=' pyproject.toml | sed -E 's/^\s*version\s*=\s*["'\'']([^"'\''"]+)["'\'']/\1/')

Copilot uses AI. Check for mistakes.
Comment thread README.md Outdated
qchapp and others added 4 commits October 22, 2025 16:51
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
For more readability

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@qchapp qchapp merged commit c5e7a0f into main Oct 22, 2025
2 checks passed
@qchapp qchapp deleted the feature-cache_cleaning branch October 22, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants