Skip to content

Commit bad59d8

Browse files
committed
fixed empty image paths error handling
1 parent 11a7b44 commit bad59d8

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/ai_agent/ui/handlers.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,21 @@ def respond(
208208
model_name = model_config.get("name")
209209
base_url_override = model_config.get("base_url") # Can be None for OpenAI
210210
log.info(f"Model config: {model} -> name={model_name}, base_url={base_url_override}")
211+
212+
effective_paths = file_paths or (state.last_files or [])
213+
214+
if not effective_paths:
215+
reply.text += (
216+
"⚠️ Please upload an image first (or re-upload). "
217+
"I need at least one image to recommend tools for your data."
218+
)
219+
state.conversation_history.append(f"Assistant: {reply.text}")
220+
return reply, state
211221

212222
try:
213223
agent_result = run_agent(
214224
clean_message,
215-
image_paths=file_paths,
225+
image_paths=effective_paths,
216226
image_bytes=image_bytes, # Pass image bytes to VLM
217227
excluded=list(state.banlist),
218228
conversation_history=state.conversation_history,

0 commit comments

Comments
 (0)