Ashed00 commited on
Commit
37c75d2
Β·
verified Β·
1 Parent(s): a775140

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +113 -0
app.py ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from groq import Groq
4
+ import re
5
+ from duckduckgo_search import DDGS
6
+ from main import TimeAdvisor
7
+
8
+ # Custom CSS for styling
9
+ custom_css = """
10
+ #tt-header {
11
+ text-align: center;
12
+ background: linear-gradient(45deg, #2c3e50, #b59b6d); /* Deep navy to gold */
13
+ padding: 20px;
14
+ border-radius: 15px;
15
+ color: white;
16
+ border: 3px solid #8a6c4d;
17
+ }
18
+ #tt-header h1 {
19
+ font-family: 'Garamond', serif;
20
+ font-size: 2.5em !important;
21
+ margin: 0;
22
+ }
23
+ #tt-header p {
24
+ font-family: 'Georgia', serif;
25
+ }
26
+ .input-section {
27
+ background: #e9dcc5 !important; /* Muted parchment */
28
+ padding: 20px !important;
29
+ border-radius: 15px !important;
30
+ border: 2px solid #b59b6d !important;
31
+ }
32
+ .output-box {
33
+ background: #fcf5e5 !important; /* Warm cream */
34
+ padding: 25px !important;
35
+ border-radius: 15px !important;
36
+ border: 3px solid #8a6c4d !important;
37
+ font-family: 'Georgia', serif !important;
38
+ min-height: 200px !important;
39
+ }
40
+ .gradio-container {
41
+ background: url('https://img.freepik.com/free-photo/wooden-floor-background_53876-88628.jpg?t=st=1741254869~exp=1741258469~hmac=ab6efd526ec76fa0d1fae8ad5c5907e80b93cafbea5da290f64ddf6648b80a46&w=1380') !important;
42
+ background-size: cover !important;
43
+ }
44
+ button {
45
+ background: #2c3e50 !important; /* Deep navy */
46
+ color: #f5e6d3 !important;
47
+ border: 2px solid #b59b6d !important;
48
+ font-family: 'Garamond', serif !important;
49
+ }
50
+ """
51
+
52
+
53
+ def time_travel_assistant(api_key, query):
54
+ os.environ["GROQ_API_KEY"] = api_key
55
+ try:
56
+ advisor = TimeAdvisor()
57
+ output = advisor.agent_loop(query)
58
+ return output
59
+ except Exception as e:
60
+ return f"πŸ•°οΈπŸ’₯ Time Machine Malfunction! πŸ’₯πŸ•°οΈ\n{str(e)}"
61
+
62
+ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as app:
63
+ with gr.Column(elem_id="tt-header"):
64
+ gr.Markdown("""
65
+ # πŸ•°οΈβœ¨ Time Traveler's Style Guide ✨🌍
66
+ *"Fashionably Anachronistic Since 3000 BCE"*
67
+ """)
68
+ gr.HTML("""<p>Where should your temporal adventures take you?<br>
69
+ Examples: 'Victorian London', '1960s New York', or 'Ming Dynasty Market'</p>""")
70
+
71
+ with gr.Row(variant="panel", elem_classes="input-section"):
72
+ api_key = gr.Textbox(
73
+ label="πŸ”‘ Groq API Key. (Get your key at https://console.groq.com/keys)",
74
+ placeholder="Enter your API key...",
75
+ type="password",
76
+ lines=1
77
+ )
78
+ user_query = gr.Textbox(
79
+ label="🌍⏳ Your Time Destination",
80
+ placeholder="Where/when are we blending in?",
81
+ lines=2
82
+ )
83
+
84
+ submit_btn = gr.Button("πŸš€ Launch Temporal Consultant", variant="primary")
85
+
86
+ with gr.Column(elem_classes="output-box"):
87
+ output = gr.Markdown(
88
+ label="πŸŽ©πŸ“œ Time Travel Briefing",
89
+ elem_id="output-box",
90
+ value="**Awaiting your temporal coordinates...**"
91
+ )
92
+
93
+ examples = gr.Examples(
94
+ examples=[
95
+ ["Ancient Mesopotamia"],
96
+ ["Renaissance Venice"],
97
+ ["Wild West Saloon 1870"],
98
+ ["1980s Tokyo Street Fashion"]
99
+ ],
100
+ inputs=[user_query],
101
+ outputs=[output],
102
+ fn=time_travel_assistant,
103
+ cache_examples=False
104
+ )
105
+
106
+ submit_btn.click(
107
+ fn=time_travel_assistant,
108
+ inputs=[api_key, user_query],
109
+ outputs=output
110
+ )
111
+
112
+ if __name__ == "__main__":
113
+ app.launch()