File size: 1,464 Bytes
301ef28
613de59
301ef28
613de59
 
301ef28
613de59
 
 
 
626a68f
b201c0c
 
 
 
 
 
 
 
 
 
613de59
 
 
b201c0c
613de59
 
 
 
 
0b432ca
613de59
b201c0c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import warnings
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()

# Import handlers and UI creator from modules
from prediction import single_prediction
from chatbot import process_chatbot_query_with_llm
from ui import create_ui

# Import API utilities for direct access if needed
from api_utils import (
    api_get_tide_level,
    api_get_tide_series,
    api_get_extremes_info,
    api_check_tide_alert,
    api_compare_stations,
    api_health_check
)

if __name__ == "__main__":
    # Suppress warnings for a cleaner output
    warnings.filterwarnings('ignore')
    
    # Create the Gradio UI by passing the handlers to the UI generator
    demo = create_ui(
        prediction_handler=single_prediction,
        chatbot_handler=process_chatbot_query_with_llm
    )
    
    # Launch the application
    # share=True creates a public link
    # server_name="0.0.0.0" allows external connections
    # server_port=7860 is the default Hugging Face Spaces port
    demo.launch(
        share=False,  # Set to True for public sharing
        server_name="0.0.0.0",  # For Hugging Face Spaces
        server_port=7860  # Default HF Spaces port
    )
    
    # Alternative launch configurations:
    # For local development:
    # demo.launch(share=False)
    
    # For Hugging Face Spaces:
    # demo.launch(server_name="0.0.0.0", server_port=7860)
    
    # For public sharing with ngrok:
    # demo.launch(share=True)