Process a query using Qwen3-VL and available tools from all servers Args: query: Text query/instruction image_paths: Optional list of image file paths to include in the query Returns: tuple: (final_response, intermediate_responses
(self, query: str, image_paths: Optional[List[str]] = None)
| 962 | return tool_calls |
| 963 | |
| 964 | async def process_query(self, query: str, image_paths: Optional[List[str]] = None) -> Tuple[str, bool]: |
| 965 | """Process a query using Qwen3-VL and available tools from all servers |
| 966 | |
| 967 | Args: |
| 968 | query: Text query/instruction |
| 969 | image_paths: Optional list of image file paths to include in the query |
| 970 | |
| 971 | Returns: |
| 972 | tuple: (final_response, intermediate_responses_shown) |
| 973 | """ |
| 974 | |
| 975 | # Build user message content (with images if provided) |
| 976 | if image_paths: |
| 977 | # Multi-modal content: text + images |
| 978 | content_for_api = [{"type": "text", "text": query}] |
| 979 | content_for_log = [{"type": "text", "text": query}] |
| 980 | images_metadata = [] |
| 981 | |
| 982 | for image_path in image_paths: |
| 983 | try: |
| 984 | print(f"📸 Loading image: {image_path}") |
| 985 | |
| 986 | # Full-size image for API |
| 987 | base64_image_full = encode_image_to_base64(image_path) |
| 988 | mime_type = get_image_mime_type(image_path) |
| 989 | |
| 990 | content_for_api.append({ |
| 991 | "type": "image_url", |
| 992 | "image_url": { |
| 993 | "url": f"data:{mime_type};base64,{base64_image_full}" |
| 994 | } |
| 995 | }) |
| 996 | |
| 997 | # Resized image for log |
| 998 | base64_image_resized, original_size, resized_size, file_size = resize_and_encode_image(image_path) |
| 999 | |
| 1000 | content_for_log.append({ |
| 1001 | "type": "image_url", |
| 1002 | "image_url": { |
| 1003 | "url": f"data:image/jpeg;base64,{base64_image_resized}" |
| 1004 | }, |
| 1005 | "image_metadata": { |
| 1006 | "filename": os.path.basename(image_path), |
| 1007 | "path": image_path, |
| 1008 | "mime_type": mime_type, |
| 1009 | "original_size": {"width": original_size[0], "height": original_size[1]}, |
| 1010 | "resized_size": {"width": resized_size[0], "height": resized_size[1]}, |
| 1011 | "file_size_bytes": file_size, |
| 1012 | "file_size_kb": round(file_size / 1024, 2), |
| 1013 | "note": "Image resized to 512x512 max for log storage" |
| 1014 | } |
| 1015 | }) |
| 1016 | |
| 1017 | images_metadata.append({ |
| 1018 | "filename": os.path.basename(image_path), |
| 1019 | "path": image_path, |
| 1020 | "mime_type": mime_type, |
| 1021 | "original_size": {"width": original_size[0], "height": original_size[1]}, |
no test coverage detected