Spaces:
Sleeping
Sleeping
Restructure the UI with Form and Chat tabs while keeping the globe always visible.
Browse filesMove guided intake into the right-side Form tab, keep chat in the Chat tab, and remove the old form/globe visibility toggles.
- assets/app.css +36 -10
- ui/chat.py +99 -163
- ui/globe.py +0 -3
assets/app.css
CHANGED
|
@@ -8,20 +8,45 @@
|
|
| 8 |
min-height: 70vh;
|
| 9 |
}
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
.borderless-chat-panel {
|
| 12 |
border-left: 1px solid rgba(148, 163, 184, 0.18);
|
| 13 |
padding-left: 10px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
|
| 16 |
-
.borderless-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
.borderless-
|
| 24 |
-
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
.borderless-hero h2 {
|
|
@@ -30,12 +55,11 @@
|
|
| 30 |
|
| 31 |
.borderless-hero p {
|
| 32 |
max-width: 820px;
|
| 33 |
-
color: #
|
| 34 |
}
|
| 35 |
|
| 36 |
.borderless-examples-title {
|
| 37 |
margin-top: 0.35rem;
|
| 38 |
-
color: #fbbf24;
|
| 39 |
font-weight: 600;
|
| 40 |
}
|
| 41 |
|
|
@@ -46,6 +70,8 @@
|
|
| 46 |
@media (max-width: 900px) {
|
| 47 |
.borderless-chat-panel {
|
| 48 |
border-left: 0;
|
|
|
|
|
|
|
| 49 |
padding-left: 0;
|
| 50 |
}
|
| 51 |
}
|
|
|
|
| 8 |
min-height: 70vh;
|
| 9 |
}
|
| 10 |
|
| 11 |
+
.borderless-center-panel {
|
| 12 |
+
gap: 8px;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
.borderless-chat-panel {
|
| 16 |
border-left: 1px solid rgba(148, 163, 184, 0.18);
|
| 17 |
padding-left: 10px;
|
| 18 |
+
display: flex;
|
| 19 |
+
flex-direction: column;
|
| 20 |
+
height: 70vh;
|
| 21 |
+
min-height: 0;
|
| 22 |
}
|
| 23 |
|
| 24 |
+
.borderless-tabs,
|
| 25 |
+
.borderless-chat-panel > :where(.gap, .block, .form, div) {
|
| 26 |
+
display: flex;
|
| 27 |
+
flex-direction: column;
|
| 28 |
+
flex: 1 1 auto;
|
| 29 |
+
min-height: 0;
|
| 30 |
+
gap: 8px;
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
.borderless-form-panel {
|
| 34 |
+
gap: 8px;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
.borderless-form-hint {
|
| 38 |
+
color: #9ca3af;
|
| 39 |
+
font-size: 0.9rem;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
.borderless-chat-panel .chatbot {
|
| 43 |
+
flex: 1 1 auto;
|
| 44 |
+
min-height: 0;
|
| 45 |
+
}
|
| 46 |
|
| 47 |
+
.borderless-chat-panel .chatbot-wrap,
|
| 48 |
+
.borderless-chat-panel .bubble-wrap {
|
| 49 |
+
min-height: 0;
|
| 50 |
}
|
| 51 |
|
| 52 |
.borderless-hero h2 {
|
|
|
|
| 55 |
|
| 56 |
.borderless-hero p {
|
| 57 |
max-width: 820px;
|
| 58 |
+
color: #9ca3af;
|
| 59 |
}
|
| 60 |
|
| 61 |
.borderless-examples-title {
|
| 62 |
margin-top: 0.35rem;
|
|
|
|
| 63 |
font-weight: 600;
|
| 64 |
}
|
| 65 |
|
|
|
|
| 70 |
@media (max-width: 900px) {
|
| 71 |
.borderless-chat-panel {
|
| 72 |
border-left: 0;
|
| 73 |
+
height: auto;
|
| 74 |
+
min-height: 70vh;
|
| 75 |
padding-left: 0;
|
| 76 |
}
|
| 77 |
}
|
ui/chat.py
CHANGED
|
@@ -84,25 +84,6 @@ def _profile_prompt_text(
|
|
| 84 |
)
|
| 85 |
|
| 86 |
|
| 87 |
-
def enter_research_workspace(prompt_text: str) -> tuple:
|
| 88 |
-
"""Switch the center panel from intake to globe and fill the chat input."""
|
| 89 |
-
return (
|
| 90 |
-
_chatbox_value(prompt_text),
|
| 91 |
-
gr.update(visible=False),
|
| 92 |
-
gr.update(visible=True),
|
| 93 |
-
gr.update(visible=True),
|
| 94 |
-
)
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
def return_to_intake() -> tuple:
|
| 98 |
-
"""Return to the profile intake without clearing chat history."""
|
| 99 |
-
return (
|
| 100 |
-
gr.update(visible=True),
|
| 101 |
-
gr.update(visible=False),
|
| 102 |
-
gr.update(visible=False),
|
| 103 |
-
)
|
| 104 |
-
|
| 105 |
-
|
| 106 |
def build_profile_prompt(
|
| 107 |
citizenship: str,
|
| 108 |
current_location: str,
|
|
@@ -113,8 +94,8 @@ def build_profile_prompt(
|
|
| 113 |
family: str,
|
| 114 |
timeline: str,
|
| 115 |
goals: str,
|
| 116 |
-
) ->
|
| 117 |
-
return
|
| 118 |
_profile_prompt_text(
|
| 119 |
citizenship,
|
| 120 |
current_location,
|
|
@@ -129,100 +110,85 @@ def build_profile_prompt(
|
|
| 129 |
)
|
| 130 |
|
| 131 |
|
| 132 |
-
def example_prompt(prompt: str) ->
|
| 133 |
-
return
|
| 134 |
|
| 135 |
|
| 136 |
-
def render_intake_panel(
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
) -> None:
|
| 143 |
-
toggle_outputs = [
|
| 144 |
-
chat_input,
|
| 145 |
-
intake_stage,
|
| 146 |
-
globe_column,
|
| 147 |
-
research_toolbar,
|
| 148 |
-
]
|
| 149 |
-
|
| 150 |
-
with intake_stage:
|
| 151 |
-
with gr.Accordion("Start with a guided profile", open=True):
|
| 152 |
-
gr.Markdown(
|
| 153 |
-
"Describe your background once. The agent researches official sources, "
|
| 154 |
-
"compares realistic visa pathways, and marks suitable countries on the globe.",
|
| 155 |
-
)
|
| 156 |
-
with gr.Row():
|
| 157 |
-
citizenship = gr.Textbox(
|
| 158 |
-
label="Citizenship / passports",
|
| 159 |
-
placeholder="e.g. India; no second passport",
|
| 160 |
-
)
|
| 161 |
-
current_location = gr.Textbox(
|
| 162 |
-
label="Current location",
|
| 163 |
-
placeholder="e.g. Singapore on an employment pass",
|
| 164 |
-
)
|
| 165 |
-
with gr.Row():
|
| 166 |
-
education = gr.Textbox(
|
| 167 |
-
label="Education",
|
| 168 |
-
placeholder="e.g. Master's in computer science",
|
| 169 |
-
)
|
| 170 |
-
work_history = gr.Textbox(
|
| 171 |
-
label="Work history",
|
| 172 |
-
placeholder="e.g. 5 years as backend software engineer",
|
| 173 |
-
)
|
| 174 |
-
with gr.Row():
|
| 175 |
-
languages = gr.Textbox(
|
| 176 |
-
label="Languages",
|
| 177 |
-
placeholder="e.g. English C1, German A2",
|
| 178 |
-
)
|
| 179 |
-
budget = gr.Textbox(
|
| 180 |
-
label="Budget",
|
| 181 |
-
placeholder="e.g. USD 18,000 available for relocation",
|
| 182 |
-
)
|
| 183 |
-
with gr.Row():
|
| 184 |
-
family = gr.Textbox(
|
| 185 |
-
label="Family / dependents",
|
| 186 |
-
placeholder="e.g. spouse, one child, or solo applicant",
|
| 187 |
-
)
|
| 188 |
-
timeline = gr.Textbox(
|
| 189 |
-
label="Target timeline",
|
| 190 |
-
placeholder="e.g. 12-18 months",
|
| 191 |
-
)
|
| 192 |
-
goals = gr.Textbox(
|
| 193 |
-
label="Goals in everyday language",
|
| 194 |
-
lines=3,
|
| 195 |
-
placeholder=(
|
| 196 |
-
"e.g. I want a realistic skilled-worker route, lower risk, "
|
| 197 |
-
"and a path to permanent residence."
|
| 198 |
-
),
|
| 199 |
)
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 215 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
gr.Markdown("Try a demo persona:", elem_classes=["borderless-examples-title"])
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
)
|
| 226 |
|
| 227 |
|
| 228 |
class SidebarChatInterface(gr.ChatInterface):
|
|
@@ -231,20 +197,16 @@ class SidebarChatInterface(gr.ChatInterface):
|
|
| 231 |
fn,
|
| 232 |
*,
|
| 233 |
history_container: gr.Column | None = None,
|
| 234 |
-
globe_column: gr.Column | None = None,
|
| 235 |
**kwargs,
|
| 236 |
):
|
| 237 |
self._history_container = history_container
|
| 238 |
-
self._globe_column = globe_column
|
| 239 |
kwargs.setdefault("save_history", True)
|
| 240 |
super().__init__(fn, **kwargs)
|
| 241 |
|
| 242 |
def _render_history_area(self):
|
| 243 |
-
if self._history_container is not None
|
| 244 |
with self._history_container:
|
| 245 |
super()._render_history_area()
|
| 246 |
-
with self._globe_column:
|
| 247 |
-
render_globe_panel(height="70vh")
|
| 248 |
return
|
| 249 |
|
| 250 |
super()._render_history_area()
|
|
@@ -271,64 +233,38 @@ def create_chat_interface(
|
|
| 271 |
min_width=520,
|
| 272 |
elem_classes=["borderless-center-panel"],
|
| 273 |
):
|
| 274 |
-
|
| 275 |
-
|
| 276 |
-
|
| 277 |
-
|
| 278 |
-
research_toolbar = gr.Row(
|
| 279 |
-
visible=False,
|
| 280 |
-
elem_classes=["borderless-research-toolbar"],
|
| 281 |
-
)
|
| 282 |
-
globe_column = gr.Column(
|
| 283 |
-
visible=False,
|
| 284 |
-
elem_classes=["globe-column"],
|
| 285 |
)
|
|
|
|
| 286 |
with globe_column:
|
| 287 |
render_globe_panel(height="70vh")
|
| 288 |
|
| 289 |
-
with research_toolbar:
|
| 290 |
-
edit_profile_btn = gr.Button(
|
| 291 |
-
"← Edit profile",
|
| 292 |
-
size="sm",
|
| 293 |
-
variant="secondary",
|
| 294 |
-
)
|
| 295 |
-
|
| 296 |
-
render_intake_panel(
|
| 297 |
-
chat_input,
|
| 298 |
-
intake_stage=intake_stage,
|
| 299 |
-
globe_column=globe_column,
|
| 300 |
-
research_toolbar=research_toolbar,
|
| 301 |
-
)
|
| 302 |
-
|
| 303 |
with gr.Column(
|
| 304 |
scale=4,
|
| 305 |
min_width=360,
|
| 306 |
elem_classes=["borderless-chat-panel"],
|
| 307 |
):
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
intake_stage,
|
| 327 |
-
globe_column,
|
| 328 |
-
research_toolbar,
|
| 329 |
-
],
|
| 330 |
-
queue=False,
|
| 331 |
-
)
|
| 332 |
|
| 333 |
globe_state.change(
|
| 334 |
fn=None,
|
|
|
|
| 84 |
)
|
| 85 |
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
def build_profile_prompt(
|
| 88 |
citizenship: str,
|
| 89 |
current_location: str,
|
|
|
|
| 94 |
family: str,
|
| 95 |
timeline: str,
|
| 96 |
goals: str,
|
| 97 |
+
) -> dict[str, object]:
|
| 98 |
+
return _chatbox_value(
|
| 99 |
_profile_prompt_text(
|
| 100 |
citizenship,
|
| 101 |
current_location,
|
|
|
|
| 110 |
)
|
| 111 |
|
| 112 |
|
| 113 |
+
def example_prompt(prompt: str) -> dict[str, object]:
|
| 114 |
+
return _chatbox_value(prompt)
|
| 115 |
|
| 116 |
|
| 117 |
+
def render_intake_panel(chat_input: gr.MultimodalTextbox) -> None:
|
| 118 |
+
with gr.Column(elem_classes=["borderless-form-panel"]):
|
| 119 |
+
with gr.Row():
|
| 120 |
+
citizenship = gr.Textbox(
|
| 121 |
+
label="Citizenship / passports",
|
| 122 |
+
placeholder="e.g. India; no second passport",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 123 |
)
|
| 124 |
+
current_location = gr.Textbox(
|
| 125 |
+
label="Current location",
|
| 126 |
+
placeholder="e.g. Singapore on an employment pass",
|
| 127 |
+
)
|
| 128 |
+
with gr.Row():
|
| 129 |
+
education = gr.Textbox(
|
| 130 |
+
label="Education",
|
| 131 |
+
placeholder="e.g. Master's in computer science",
|
| 132 |
+
)
|
| 133 |
+
work_history = gr.Textbox(
|
| 134 |
+
label="Work history",
|
| 135 |
+
placeholder="e.g. 5 years as backend software engineer",
|
| 136 |
+
)
|
| 137 |
+
with gr.Row():
|
| 138 |
+
languages = gr.Textbox(
|
| 139 |
+
label="Languages",
|
| 140 |
+
placeholder="e.g. English C1, German A2",
|
| 141 |
+
)
|
| 142 |
+
budget = gr.Textbox(
|
| 143 |
+
label="Budget",
|
| 144 |
+
placeholder="e.g. USD 18,000 available for relocation",
|
| 145 |
)
|
| 146 |
+
with gr.Row():
|
| 147 |
+
family = gr.Textbox(
|
| 148 |
+
label="Family / dependents",
|
| 149 |
+
placeholder="e.g. spouse, one child, or solo applicant",
|
| 150 |
+
)
|
| 151 |
+
timeline = gr.Textbox(
|
| 152 |
+
label="Target timeline",
|
| 153 |
+
placeholder="e.g. 12-18 months",
|
| 154 |
+
)
|
| 155 |
+
goals = gr.Textbox(
|
| 156 |
+
label="Goals in everyday language",
|
| 157 |
+
lines=3,
|
| 158 |
+
placeholder=(
|
| 159 |
+
"e.g. I want a realistic skilled-worker route, lower risk, "
|
| 160 |
+
"and a path to permanent residence."
|
| 161 |
+
),
|
| 162 |
+
)
|
| 163 |
+
gr.Button("Create research prompt", variant="primary").click(
|
| 164 |
+
fn=build_profile_prompt,
|
| 165 |
+
inputs=[
|
| 166 |
+
citizenship,
|
| 167 |
+
current_location,
|
| 168 |
+
education,
|
| 169 |
+
work_history,
|
| 170 |
+
languages,
|
| 171 |
+
budget,
|
| 172 |
+
family,
|
| 173 |
+
timeline,
|
| 174 |
+
goals,
|
| 175 |
+
],
|
| 176 |
+
outputs=chat_input,
|
| 177 |
+
queue=False,
|
| 178 |
+
)
|
| 179 |
|
| 180 |
+
gr.Markdown(
|
| 181 |
+
"After creating a prompt, open the Chat tab and send it.",
|
| 182 |
+
elem_classes=["borderless-form-hint"],
|
| 183 |
+
)
|
| 184 |
gr.Markdown("Try a demo persona:", elem_classes=["borderless-examples-title"])
|
| 185 |
+
for label, prompt in EXAMPLE_PROMPTS:
|
| 186 |
+
gr.Button(label, size="sm").click(
|
| 187 |
+
fn=example_prompt,
|
| 188 |
+
inputs=[gr.State(prompt)],
|
| 189 |
+
outputs=chat_input,
|
| 190 |
+
queue=False,
|
| 191 |
+
)
|
|
|
|
| 192 |
|
| 193 |
|
| 194 |
class SidebarChatInterface(gr.ChatInterface):
|
|
|
|
| 197 |
fn,
|
| 198 |
*,
|
| 199 |
history_container: gr.Column | None = None,
|
|
|
|
| 200 |
**kwargs,
|
| 201 |
):
|
| 202 |
self._history_container = history_container
|
|
|
|
| 203 |
kwargs.setdefault("save_history", True)
|
| 204 |
super().__init__(fn, **kwargs)
|
| 205 |
|
| 206 |
def _render_history_area(self):
|
| 207 |
+
if self._history_container is not None:
|
| 208 |
with self._history_container:
|
| 209 |
super()._render_history_area()
|
|
|
|
|
|
|
| 210 |
return
|
| 211 |
|
| 212 |
super()._render_history_area()
|
|
|
|
| 233 |
min_width=520,
|
| 234 |
elem_classes=["borderless-center-panel"],
|
| 235 |
):
|
| 236 |
+
gr.Markdown(
|
| 237 |
+
"## Borderless\n"
|
| 238 |
+
"Describe your background once. The agent researches official sources, compares realistic pathways, and suggests countries to migrate to.",
|
| 239 |
+
elem_classes=["borderless-hero"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
)
|
| 241 |
+
globe_column = gr.Column(elem_classes=["globe-column"])
|
| 242 |
with globe_column:
|
| 243 |
render_globe_panel(height="70vh")
|
| 244 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
with gr.Column(
|
| 246 |
scale=4,
|
| 247 |
min_width=360,
|
| 248 |
elem_classes=["borderless-chat-panel"],
|
| 249 |
):
|
| 250 |
+
with gr.Tabs(elem_classes=["borderless-tabs"]):
|
| 251 |
+
with gr.Tab("Form"):
|
| 252 |
+
render_intake_panel(chat_input)
|
| 253 |
+
with gr.Tab("Chat"):
|
| 254 |
+
chat = SidebarChatInterface(
|
| 255 |
+
respond,
|
| 256 |
+
multimodal=True,
|
| 257 |
+
textbox=chat_input,
|
| 258 |
+
history_container=history_container,
|
| 259 |
+
additional_inputs=[
|
| 260 |
+
gr.State(BORDERLESS_SYSTEM_PROMPT),
|
| 261 |
+
gr.State(DEFAULT_MAX_TOKENS),
|
| 262 |
+
gr.State(DEFAULT_TEMPERATURE),
|
| 263 |
+
gr.State(DEFAULT_TOP_P),
|
| 264 |
+
globe_state,
|
| 265 |
+
],
|
| 266 |
+
additional_outputs=[globe_state],
|
| 267 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
|
| 269 |
globe_state.change(
|
| 270 |
fn=None,
|
ui/globe.py
CHANGED
|
@@ -131,9 +131,6 @@ def render_globe_panel(
|
|
| 131 |
'<div class="globe-shell is-loading">'
|
| 132 |
f'<div class="globe-map" {data_attrs}></div>'
|
| 133 |
'<div class="globe-status globe-loading">Loading the globe...</div>'
|
| 134 |
-
'<div class="globe-status globe-empty">'
|
| 135 |
-
"Recommended countries will appear here as the agent researches."
|
| 136 |
-
"</div>"
|
| 137 |
"</div>"
|
| 138 |
),
|
| 139 |
css_template=_read_asset("globe.css"),
|
|
|
|
| 131 |
'<div class="globe-shell is-loading">'
|
| 132 |
f'<div class="globe-map" {data_attrs}></div>'
|
| 133 |
'<div class="globe-status globe-loading">Loading the globe...</div>'
|
|
|
|
|
|
|
|
|
|
| 134 |
"</div>"
|
| 135 |
),
|
| 136 |
css_template=_read_asset("globe.css"),
|