Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -26,6 +26,7 @@ pc, pine_index, APIFY_TOKEN, OPENAI_API_KEY, TAVILY_API_KEY, client = initialize
|
|
26 |
embedding_model = initialize_embedding_model()
|
27 |
summarizer = initialize_summarizer()
|
28 |
|
|
|
29 |
# ==== Gradio UI Components ====
|
30 |
class RoadmapUnlockManager:
|
31 |
def __init__(self):
|
@@ -71,34 +72,135 @@ def render_text_roadmap(goal, steps):
|
|
71 |
|
72 |
|
73 |
|
74 |
-
def recall_from_memory(user_id, goal):
|
75 |
-
try:
|
76 |
-
query = user_id + ":" + goal.replace(" ", "_")
|
77 |
-
result = pine_index.fetch([query]) # β
returns a FetchResponse object
|
78 |
-
|
79 |
-
if query not in result.vectors:
|
80 |
-
return "β No saved plan found for this goal."
|
81 |
|
82 |
-
|
83 |
-
|
84 |
-
steps = [smart_label_converter(s) for s in steps if isinstance(s, str) and len(s.strip()) > 1]
|
85 |
-
summary = metadata.get("summary", "")
|
86 |
-
courses = metadata.get("courses", [])
|
87 |
-
course_section = ""
|
88 |
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
93 |
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
user_id_state = gr.State()
|
99 |
roadmap_unlock = RoadmapUnlockManager()
|
100 |
start_date = gr.Textbox(label="π
Start Date", value=str(datetime.date.today()))
|
101 |
-
|
102 |
with gr.Tabs():
|
103 |
with gr.Tab("β¨ Welcome"):
|
104 |
with gr.Row(equal_height=True):
|
@@ -312,4 +414,3 @@ def recall_from_memory(user_id, goal):
|
|
312 |
|
313 |
app.launch(debug=True, enable_queue=True)
|
314 |
|
315 |
-
|
|
|
26 |
embedding_model = initialize_embedding_model()
|
27 |
summarizer = initialize_summarizer()
|
28 |
|
29 |
+
|
30 |
# ==== Gradio UI Components ====
|
31 |
class RoadmapUnlockManager:
|
32 |
def __init__(self):
|
|
|
72 |
|
73 |
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
+
with gr.Blocks(css="""
|
77 |
+
@import url(\'https://fonts.googleapis.com/css2?family=Source+Sans+Pro&display=swap\');
|
|
|
|
|
|
|
|
|
78 |
|
79 |
+
body {
|
80 |
+
font-family: \'Source Sans Pro\', sans-serif;
|
81 |
+
background-color: #121212;
|
82 |
+
color: #f0f0f0;
|
83 |
+
}
|
84 |
|
85 |
+
#nickname-box {
|
86 |
+
max-width: 300px;
|
87 |
+
margin: 0 auto;
|
88 |
+
padding: 20px;
|
89 |
+
background-color: #1e1e1e;
|
90 |
+
border-radius: 12px;
|
91 |
+
box-shadow: 0px 0px 10px rgba(0,0,0,0.2);
|
92 |
+
}
|
93 |
+
|
94 |
+
#planner-card {
|
95 |
+
max-width: 720px;
|
96 |
+
margin: 0 auto;
|
97 |
+
padding: 28px;
|
98 |
+
background-color: #1e1e1e;
|
99 |
+
border-radius: 16px;
|
100 |
+
box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
|
101 |
+
}
|
102 |
+
|
103 |
+
#planner-card input,
|
104 |
+
#planner-card textarea,
|
105 |
+
#planner-card .gr-button {
|
106 |
+
font-size: 14px;
|
107 |
+
padding: 8px 12px;
|
108 |
+
border-radius: 8px;
|
109 |
+
}
|
110 |
+
|
111 |
+
#planner-card .gr-button {
|
112 |
+
background-color: #3a3aff;
|
113 |
+
color: white;
|
114 |
+
font-weight: bold;
|
115 |
+
}
|
116 |
+
|
117 |
+
#planner-card label {
|
118 |
+
font-weight: 600;
|
119 |
+
color: #f0f0f0;
|
120 |
+
}
|
121 |
+
|
122 |
+
#planner-card .gr-tab {
|
123 |
+
margin-top: 12px;
|
124 |
+
}
|
125 |
|
126 |
|
127 |
+
/* π Linky Tab Styling - Match Welcome Dark Mode */
|
128 |
+
|
129 |
+
#linky-tab {
|
130 |
+
background-color: #1e1e1e !important;
|
131 |
+
color: #f0f0f0 !important;
|
132 |
+
padding: 24px;
|
133 |
+
border-radius: 16px;
|
134 |
+
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
|
135 |
+
}
|
136 |
+
|
137 |
+
/* Fix outer wrappers Gradio uses */
|
138 |
+
#linky-tab .gr-block,
|
139 |
+
#linky-tab .gr-column,
|
140 |
+
#linky-tab .gr-panel {
|
141 |
+
background-color: transparent !important;
|
142 |
+
color: inherit;
|
143 |
+
box-shadow: none;}
|
144 |
+
|
145 |
+
/* Override inputs + textareas inside dark tab */
|
146 |
+
#linky-tab input,
|
147 |
+
#linky-tab textarea {
|
148 |
+
background-color: #2c2c2c !important;
|
149 |
+
color: #ffffff !important;
|
150 |
+
border: 1px solid #444 !important;
|
151 |
+
border-radius: 6px;}
|
152 |
+
|
153 |
+
/* Fix submit button look */
|
154 |
+
#linky-tab .gr-button {
|
155 |
+
background-color: #4444aa !important;
|
156 |
+
color: #fff !important;
|
157 |
+
border-radius: 6px;}
|
158 |
+
|
159 |
+
#dds-logo img {
|
160 |
+
max-width: 200px;
|
161 |
+
display: block;
|
162 |
+
margin: 0 auto 15px;
|
163 |
+
}
|
164 |
+
|
165 |
+
/* Shared Card Styling (like Welcome tab) */
|
166 |
+
#user-card {
|
167 |
+
background-color: #ffffff;
|
168 |
+
border: 1px solid #dddddd;
|
169 |
+
border-radius: 12px;
|
170 |
+
padding: 24px;
|
171 |
+
margin-top: 20px;
|
172 |
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
173 |
+
color: #1a1a1a;
|
174 |
+
}
|
175 |
+
|
176 |
+
#user-card input,
|
177 |
+
#user-card textarea {
|
178 |
+
background-color: #f5f5f5 !important;
|
179 |
+
color: #111111 !important;
|
180 |
+
border: 1px solid #ccc;
|
181 |
+
border-radius: 6px;
|
182 |
+
padding: 10px;
|
183 |
+
}
|
184 |
+
|
185 |
+
#user-card label {
|
186 |
+
color: #333333;
|
187 |
+
}
|
188 |
+
|
189 |
+
/* Responsive Tweaks */
|
190 |
+
@media (max-width: 768px) {
|
191 |
+
.gr-row {
|
192 |
+
flex-direction: column !important;
|
193 |
+
}
|
194 |
+
|
195 |
+
#user-card {
|
196 |
+
margin-top: 20px;
|
197 |
+
}
|
198 |
+
}
|
199 |
+
""") as app:
|
200 |
user_id_state = gr.State()
|
201 |
roadmap_unlock = RoadmapUnlockManager()
|
202 |
start_date = gr.Textbox(label="π
Start Date", value=str(datetime.date.today()))
|
203 |
+
|
204 |
with gr.Tabs():
|
205 |
with gr.Tab("β¨ Welcome"):
|
206 |
with gr.Row(equal_height=True):
|
|
|
414 |
|
415 |
app.launch(debug=True, enable_queue=True)
|
416 |
|
|