MCPcopy Create free account
hub / github.com/MiroMindAI/MiroThinker / process_input

Function process_input

apps/miroflow-agent/src/io/input_handler.py:438–651  ·  view source on GitHub ↗

Process user input and associated files. Extracts content from the task file (if provided) and appends it to the task description in a format suitable for the LLM. Args: task_description: The original task description task_file_name: Path to an associated file, or

(task_description: str, task_file_name: str)

Source from the content-addressed store, hash-verified

436
437
438def process_input(task_description: str, task_file_name: str) -> Tuple[str, str]:
439 """
440 Process user input and associated files.
441
442 Extracts content from the task file (if provided) and appends it to the
443 task description in a format suitable for the LLM.
444
445 Args:
446 task_description: The original task description
447 task_file_name: Path to an associated file, or empty string if none
448
449 Returns:
450 Tuple of (updated_task_description, updated_task_description)
451 Both values are the same - the task description with file content appended
452 """
453 updated_task_description = task_description
454 file_content_section = "" # Collect file content to append at the end
455
456 if task_file_name:
457 try:
458 file_extension = task_file_name.rsplit(".", maxsplit=1)[-1].lower()
459 parsing_result = None
460
461 if file_extension in IMAGE_EXTENSIONS:
462 # Generate unconditional image caption
463 caption = _generate_image_caption(task_file_name)
464
465 # Extract task-relevant information directly from the image
466 relevant_info = _extract_task_relevant_info_from_image(
467 task_file_name, task_description
468 )
469
470 # Format as Markdown
471 file_content_section += f"\n\nNote: An image file '{task_file_name}' is associated with this task. The content has been extracted as a detailed caption below. You may use available tools to process its content if necessary. If you need to further process this file in the sandbox, please upload it to the sandbox first.\n\n"
472 file_content_section += f"## Image Content\nFile: {task_file_name}\n\n"
473 file_content_section += f"> {caption}\n\n"
474
475 if relevant_info:
476 file_content_section += "Task-Relevant Information:\n\n"
477 file_content_section += f"{relevant_info}\n\n"
478
479 elif file_extension == "py":
480 # Python files - read directly
481 with open(task_file_name, "r", encoding="utf-8") as f:
482 parsing_result = DocumentConverterResult(
483 title=None, text_content=f.read()
484 )
485 file_content_section += f"\n\nNote: A Python file '{task_file_name}' is associated with this task. The content has been extracted as text below. You may use available tools to process its content if necessary. If you need to further process this file in the sandbox, please upload it to the sandbox first.\n\n"
486 file_content_section += f"## Python File\nFile: {task_file_name}\n\n"
487
488 elif file_extension in ["txt", "md", "sh", "yaml", "yml", "toml", "csv"]:
489 # Text-based files - read directly
490 with open(task_file_name, "r", encoding="utf-8") as f:
491 parsing_result = DocumentConverterResult(
492 title=None, text_content=f.read()
493 )
494 file_type_name = {
495 "txt": "Text",

Callers 1

run_main_agentMethod · 0.85

Calls 14

_generate_image_captionFunction · 0.85
XlsxConverterFunction · 0.85
DocxConverterFunction · 0.85
HtmlConverterFunction · 0.85
PptxConverterFunction · 0.85
_generate_audio_captionFunction · 0.85
_generate_video_captionFunction · 0.85
ZipConverterFunction · 0.85

Tested by

no test coverage detected