File size: 3,463 Bytes
37c75d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import os
import gradio as gr
from groq import Groq
import re
from duckduckgo_search import DDGS
from main import TimeAdvisor

# Custom CSS for styling
custom_css = """
#tt-header {
    text-align: center;
    background: linear-gradient(45deg, #2c3e50, #b59b6d); /* Deep navy to gold */
    padding: 20px;
    border-radius: 15px;
    color: white;
    border: 3px solid #8a6c4d;
}
#tt-header h1 {
    font-family: 'Garamond', serif;
    font-size: 2.5em !important;
    margin: 0;
}
#tt-header p {
    font-family: 'Georgia', serif;
}
.input-section {
    background: #e9dcc5 !important; /* Muted parchment */
    padding: 20px !important;
    border-radius: 15px !important;
    border: 2px solid #b59b6d !important;
}
.output-box {
    background: #fcf5e5 !important; /* Warm cream */
    padding: 25px !important;
    border-radius: 15px !important;
    border: 3px solid #8a6c4d !important;
    font-family: 'Georgia', serif !important;
    min-height: 200px !important;
}
.gradio-container {
    background: url('https://img.freepik.com/free-photo/wooden-floor-background_53876-88628.jpg?t=st=1741254869~exp=1741258469~hmac=ab6efd526ec76fa0d1fae8ad5c5907e80b93cafbea5da290f64ddf6648b80a46&w=1380') !important;
    background-size: cover !important;
}
button {
    background: #2c3e50 !important; /* Deep navy */
    color: #f5e6d3 !important;
    border: 2px solid #b59b6d !important;
    font-family: 'Garamond', serif !important;
}
"""


def time_travel_assistant(api_key, query):
    os.environ["GROQ_API_KEY"] = api_key
    try:
        advisor = TimeAdvisor()
        output = advisor.agent_loop(query)
        return output
    except Exception as e:
        return f"πŸ•°οΈπŸ’₯ Time Machine Malfunction! πŸ’₯πŸ•°οΈ\n{str(e)}"

with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as app:
    with gr.Column(elem_id="tt-header"):
        gr.Markdown("""
        # πŸ•°οΈβœ¨ Time Traveler's Style Guide ✨🌍
        *"Fashionably Anachronistic Since 3000 BCE"*
        """)
        gr.HTML("""<p>Where should your temporal adventures take you?<br>
        Examples: 'Victorian London', '1960s New York', or 'Ming Dynasty Market'</p>""")
    
    with gr.Row(variant="panel", elem_classes="input-section"):
        api_key = gr.Textbox(
            label="πŸ”‘ Groq API Key. (Get your key at https://console.groq.com/keys)",
            placeholder="Enter your API key...",
            type="password",
            lines=1
        )
        user_query = gr.Textbox(
            label="🌍⏳ Your Time Destination",
            placeholder="Where/when are we blending in?",
            lines=2
        )
    
    submit_btn = gr.Button("πŸš€ Launch Temporal Consultant", variant="primary")
    
    with gr.Column(elem_classes="output-box"):
        output = gr.Markdown(
            label="πŸŽ©πŸ“œ Time Travel Briefing",
            elem_id="output-box",
            value="**Awaiting your temporal coordinates...**"
        )
    
    examples = gr.Examples(
        examples=[
            ["Ancient Mesopotamia"],
            ["Renaissance Venice"],
            ["Wild West Saloon 1870"],
            ["1980s Tokyo Street Fashion"]
        ],
        inputs=[user_query],
        outputs=[output],
        fn=time_travel_assistant,
        cache_examples=False
    )
    
    submit_btn.click(
        fn=time_travel_assistant,
        inputs=[api_key, user_query],
        outputs=output
    )

if __name__ == "__main__":
    app.launch()