File size: 2,468 Bytes
918bdb4
3b9a6b5
 
918bdb4
197eaf5
3b9a6b5
918bdb4
 
 
3b9a6b5
2004c79
e2685f7
3b9a6b5
 
 
 
 
 
 
 
 
 
 
 
 
918bdb4
 
 
 
 
 
 
 
 
 
 
 
3b9a6b5
 
 
0965204
 
 
 
3b9a6b5
 
 
e2685f7
3b9a6b5
197eaf5
 
 
 
 
 
 
 
 
 
918bdb4
 
3b9a6b5
918bdb4
3b9a6b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import os, argparse
import gradio as gr

from utils.logging_config import setup_logging, get_logger
from utils.version import __version__

# Initialize logging early - will be reconfigured based on debug mode
setup_logging()
logger = get_logger(__name__)

from handlers.mcp_backend import process_message_and_attached_file
from ui.pages.chat import draw_chat_page


# Store last chat message and file in global variables (for demo purposes)
last_message_body = None
last_attached_file = None


# =========================
#           APP
# =========================


def app(debug: bool = False):
    """Main application function with optional debug mode"""

    # Configure logging based on debug mode
    if debug:
        os.environ["YUGA_DEBUG"] = "true"
        setup_logging("DEBUG")
        logger.info("Application started in DEBUG mode")
    else:
        os.environ["YUGA_DEBUG"] = "false"
        setup_logging("INFO")
        logger.info("Application started in normal mode")

    with gr.Blocks() as demo:
        gr.Markdown(
            """
            # 🐍 Yuga Planner

            **Yuga Planner** is a neuro-symbolic system that combines AI agents with constraint optimization
            for intelligent scheduling.
            """
        )

        draw_chat_page(debug)

        # Version footer
        gr.Markdown(
            f"""
            <div style="text-align: center; margin-top: 2rem; padding: 1rem; color: #666; font-size: 0.8rem;">
                Yuga Planner v{__version__}
            </div>
            """,
            elem_classes=["version-footer"],
        )

        # Register the MCP tool as an API endpoint
        gr.api(process_message_and_attached_file)

    return demo


if __name__ == "__main__":
    parser = argparse.ArgumentParser(
        description="Yuga Planner - Team Scheduling Application"
    )
    parser.add_argument(
        "--debug",
        action="store_true",
        help="Enable debug mode with additional UI controls and logging",
    )
    parser.add_argument(
        "--server-name",
        default="0.0.0.0",
        help="Server name/IP to bind to (default: 0.0.0.0)",
    )
    parser.add_argument(
        "--server-port",
        type=int,
        default=7860,
        help="Server port to bind to (default: 7860)",
    )

    args = parser.parse_args()

    app(debug=args.debug).launch(
        server_name=args.server_name, server_port=args.server_port, mcp_server=True
    )