File size: 1,866 Bytes
e98a02a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import gradio as gr

from src.modules.gradio_app.components.config_panel import create_config_panel
from src.modules.gradio_app.components.prompt_panel import create_prompt_panel
from src.modules.gradio_app.components.image_panel import create_image_panel
from src.modules.gradio_app.utils.analysis import analyze_image

def create_gradio_app():
    """Create the main Gradio application with all components"""
    with gr.Blocks() as app:
        gr.Markdown("# Image Analysis with LLM")
          # Image Analysis Panel
        image_input, analyze_button, output = create_image_panel()

        # Configuration Panel
        with gr.Row():
            endpoint_url, api_key, model_dropdown = create_config_panel()

        # Prompt Panel
        with gr.Row():
            prompt_input, system_prompt, temperature = create_prompt_panel()

      
        # Connect the analyze button to the analysis function
        analyze_button.click(
            fn=analyze_image,
            inputs=[
                image_input,
                endpoint_url,
                api_key,
                model_dropdown,
                prompt_input,
                system_prompt,
                temperature
            ],
            outputs=output
        )
        
    return app

app = create_gradio_app()

# Configure server settings for Docker deployment
server_port = 7860  # Standard Gradio port
server_name = "0.0.0.0"  # Allow external connections

def main():
    """Launch the Gradio application"""
    app.launch(
        server_name=server_name,
        server_port=server_port,
        share=False,  # Disable sharing as we're running in Docker
        auth=None,    # Can be configured if authentication is needed
        ssl_verify=False,  # Disable SSL verification for internal Docker network
        show_error=True,
        favicon_path=None
    )

main()