brainstorming
brainstorming
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).
web-interfaceOperate and safely adapt the MedRAX Gradio chat interface around an initialized agent, including image and DICOM uploads, chat threads, tool-result images, and server configuration.
Independent GitHub snapshot · Automated classification · Original documentation governs
Use this skill when a researcher needs to run or modify the browser UI around an already initialized MedRAX agent. This is an interface adapter, not a tool implementation or an agent-graph tutorial.
agent exposing workflow.stream(...), plus a
tools_dict mapping the selected tool names to initialized tool instances.Blocks demo that accepts a user message and optional image,
streams assistant/tool events, and returns (chat_history, image_path, text)
for the bound outputs.For the detailed event and upload sequence, read workflows.md. For launch and resource settings, read configuration.md. For failure diagnosis, read troubleshooting.md.
tools_to_use, model_dir, temp_dir, device,
model name, temperature, top-p, and OpenAI-compatible keyword arguments.ImageVisualizerTool and DicomProcessorTool; its
model-backed choices include classification, segmentation, visual QA,
report generation, grounding, LLaVA-Med, and generation. A selected tool
must be present in both the agent tool list and tools_dict.create_demo(agent, tools_dict). It constructs ChatInterface, a
gr.Blocks layout, a messages-style Chatbot, text input, image display,
upload buttons, and Clear Chat/New Thread controls.add_message first appends the user
image and text and disables the textbox; process_message then streams
agent events and updates chatbot, display image, and textbox. Re-enable the
textbox after completion, including failure.share=False; do not inherit the example's broad bind and
public share settings without a deployment decision.ChatInterface currently stores current_thread_id, original_file_path, and
display_file_path on one Python object. That is adequate for a single-user
demo only. For concurrent users, put these values in per-session gr.State (or
a server-side session store), use a collision-resistant thread identifier, and
never let one browser's upload or thread be reused by another browser.
UploadButton is configured separately for ordinary images and DICOM. The
current DICOM button accepts a generic file, so validate the lower-cased
suffix before processing rather than trusting the widget..dcm, call the selected DicomProcessorTool and read the
returned display mapping's image_path for the UI.original_file_path as the path sent in the textual image_path:
message. Keep display_file_path as the PNG or other viewable conversion.
If a multimodal payload is also built, encode the display path with its real
MIME type; never label raw DICOM bytes as JPEG. This distinction is required
even though the current implementation uses one fallback path for both.tools_dict["DicomProcessorTool"] is missing. Do not catch that as an
unexplained chat failure.Build the current request in the shape expected by the agent:
{"role": "user", "content": "image_path: <path>"}.image_url data payload for the viewable image.{"type": "text", "text": <message>}.The current LangGraph call is conceptually:
agent.workflow.stream(
{"messages": messages},
{"configurable": {"thread_id": thread_id}},
)
The checkpointer and thread ID carry graph state; the visible Gradio history is not itself the complete graph conversation. New threads must receive a new ID. Clear Chat should also decide whether it is merely a visual reset or a new conversation; make that choice explicit instead of leaving stale graph state.
Handle the stream defensively:
process event, take the latest message content, format it as text,
and append an assistant ChatMessage.execute event, iterate tool messages, use the emitted tool name, and
display textual results plus any validated image result. The current image
branch recognizes the emitted name image_visualizer; do not assume it is
the same spelling/case as ImageVisualizerTool in tools_dict.eval on tool output. Prefer structured tool returns; for a legacy
serialized value, use a constrained parser and validate the result shape and
path before rendering it.(history, display_path, ""). Do not expose raw temporary paths in assistant
text, and do not put an unredacted provider exception or credential in chat.For a CPU-only utility demonstration, initialize only
ImageVisualizerTool and DicomProcessorTool with device="cpu" where the
initializer requires a device. This avoids local vision-model weight loading,
but the normal process_message still calls the configured chat model. A full
chat demo therefore still needs an accessible OpenAI-compatible model endpoint,
or a test/stub agent whose workflow.stream produces deterministic events.
Do not claim a no-weight, no-model setup can answer medical questions.
Use configuration.md for a minimal selection matrix and troubleshooting.md when an optional model-backed tool prevents startup.
Route tool signatures, image processing, DICOM conversion implementation, and
result schemas to chest-xray-analysis or image-data-utilities. Route
LangGraph agent construction, prompts, checkpointers, and tool binding to
agent-orchestration. Route benchmark execution and scoring to
benchmark-evaluation. This skill only adapts their initialized outputs to a
safe Gradio lifecycle.