$ show royerlab/napari-chatgpt
napari-chatgpt (Omega) is an LLM-powered autonomous agent designed as a napari plugin for interactive image analysis. It enables users to interact with the napari viewer via natural language through a chat interface, either embedded in napari or via a web-based UI. The system processes user commands by leveraging LLMs (via LiteMind) to select and execute appropriate tools for tasks such as image loading, segmentation, denoising, widget creation, viewer control, web search, and code execution. The architecture centers around a plugin-contributed dock widget that launches a chat interface, which communicates with a FastAPI/WebSocket backend. The backend hosts the Omega agent, which uses a modular tool system where each tool (e.g., for file operations, segmentation, or web requests) inherits from a base class and is responsible for executing specific actions. The agent can iteratively refine its actions through dialogue, enabling complex workflows like 'segment nuclei and show measurement statistics'. Key external dependencies include napari (>=0.5), LiteMind, LLM provider libraries (OpenAI, Anthropic, Google), FastAPI, Qt bindings, and scientific libraries like scikit-image, Cellpose, and StarDist.
The LLM identified 4 files worth highlighting for reuse:
Extracts and consolidates import statements from a string of Python code. This self-contained utility has minimal dependencies (primarily the standard library's ast module) and can be reused in any code generation, refactoring, or analysis tool that processes Python code. It demonstrates practical skill in handling Python's import mechanics and code transformation.
Extracts code blocks from markdown text using regular expressions. This isolated function has no internal dependencies beyond the standard library's re module and can be applied in any project that processes markdown documentation or notebooks. It showcases a focused, reliable pattern for parsing fenced code blocks, a common need in developer tools and documentation systems.
A Qt-based code editor widget featuring syntax highlighting (via Pygments), line numbers, and basic editing capabilities. While it depends on Qt and external libraries (Jedi for completion, Pygments for highlighting), the widget is encapsulated and can be integrated into any Qt application with minimal adaptation. It represents a polished, reusable UI component that avoids tight coupling to the rest of the codebase, making it suitable for extraction into a standalone code editing library.
A simple function that checks whether a TCP port is available on the local host by attempting to bind a socket. With no dependencies beyond the standard library's socket module, this utility is highly portable and can be used in any Python application needing to allocate or verify network ports. It exemplifies a small, focused solution to a recurring network programming problem.