File size: 2,614 Bytes
d7291ef
351d460
d7291ef
 
 
 
 
 
 
 
fe5d98f
65933cd
 
d7291ef
186c8e8
d7291ef
 
186c8e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
351d460
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d7291ef
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from .vlm_service import VLMService, ModelType
from typing import Dict, Any, List
import asyncio

class StubVLMService(VLMService):
    """Stub VLM service for testing and development"""
    
    def __init__(self):
        super().__init__("STUB_MODEL", ModelType.CUSTOM)
    
    async def generate_caption(self, image_bytes: bytes, prompt: str, metadata_instructions: str = "") -> dict:
        """Generate a stub caption for testing purposes."""
        caption = f"This is a stub caption for testing. Image size: {len(image_bytes)} bytes. Prompt: {prompt[:50]}..."
        
        # Return data in the format expected by schema validator
        return {
            "caption": caption,
            "raw_response": {
                "stub": True,
                "analysis": caption,
                "metadata": {
                    "title": "Stub Generated Title",
                    "source": "OTHER",
                    "type": "OTHER", 
                    "countries": [],
                    "epsg": "OTHER"
                }
            },
            "metadata": {
                "title": "Stub Generated Title",
                "source": "OTHER",
                "type": "OTHER",
                "countries": [],
                "epsg": "OTHER"
            }
        }
    
    async def generate_multi_image_caption(self, image_bytes_list: List[bytes], prompt: str, metadata_instructions: str = "") -> dict:
        """Generate a stub caption for multiple images for testing purposes."""
        caption = f"This is a stub multi-image caption for testing. Number of images: {len(image_bytes_list)}. Total size: {sum(len(img) for img in image_bytes_list)} bytes. Prompt: {prompt[:50]}..."
        
        # Create individual metadata for each image
        metadata_images = {}
        for i, img_bytes in enumerate(image_bytes_list):
            metadata_images[f"image{i+1}"] = {
                "source": "OTHER",
                "type": "OTHER",
                "countries": [],
                "epsg": "OTHER"
            }
        
        # Return data in the format expected by schema validator
        return {
            "caption": caption,
            "raw_response": {
                "stub": True,
                "analysis": caption,
                "metadata": {
                    "title": "Stub Multi-Image Generated Title",
                    "metadata_images": metadata_images
                }
            },
            "metadata": {
                "title": "Stub Multi-Image Generated Title",
                "metadata_images": metadata_images
            }
        }