Spaces:
Sleeping
Sleeping
Fixed the layout so it’s center/right instead of top/bottom.
Browse files- assets/app.css +31 -9
- assets/globe.css +2 -1
- ui/chat.py +140 -30
- ui/sidebar.py +1 -1
assets/app.css
CHANGED
|
@@ -1,11 +1,27 @@
|
|
| 1 |
-
.borderless-
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
border-radius: 16px;
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(124, 58, 237, 0.08)),
|
| 8 |
-
rgba(17, 24, 39, 0.34);
|
| 9 |
}
|
| 10 |
|
| 11 |
.borderless-hero h2 {
|
|
@@ -24,8 +40,14 @@
|
|
| 24 |
}
|
| 25 |
|
| 26 |
.globe-column {
|
| 27 |
-
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
}
|
| 30 |
|
| 31 |
footer {
|
|
|
|
| 1 |
+
.borderless-main-workspace {
|
| 2 |
+
align-items: stretch;
|
| 3 |
+
gap: 12px;
|
| 4 |
+
}
|
| 5 |
+
|
| 6 |
+
.borderless-center-panel,
|
| 7 |
+
.borderless-chat-panel {
|
| 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-intake-stage {
|
| 17 |
+
width: 100%;
|
| 18 |
+
max-width: none;
|
| 19 |
+
margin: 0;
|
| 20 |
+
padding: 8px 4px 24px;
|
| 21 |
border-radius: 16px;
|
| 22 |
+
|
| 23 |
+
.borderless-research-toolbar {
|
| 24 |
+
margin: 0 0 8px;
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
|
| 27 |
.borderless-hero h2 {
|
|
|
|
| 40 |
}
|
| 41 |
|
| 42 |
.globe-column {
|
| 43 |
+
min-height: 70vh;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
@media (max-width: 900px) {
|
| 47 |
+
.borderless-chat-panel {
|
| 48 |
+
border-left: 0;
|
| 49 |
+
padding-left: 0;
|
| 50 |
+
}
|
| 51 |
}
|
| 52 |
|
| 53 |
footer {
|
assets/globe.css
CHANGED
|
@@ -13,7 +13,8 @@
|
|
| 13 |
position: relative;
|
| 14 |
width: 100%;
|
| 15 |
height: 100%;
|
| 16 |
-
min-height:
|
|
|
|
| 17 |
border-radius: 12px;
|
| 18 |
overflow: hidden;
|
| 19 |
background:
|
|
|
|
| 13 |
position: relative;
|
| 14 |
width: 100%;
|
| 15 |
height: 100%;
|
| 16 |
+
min-height: 70vh;
|
| 17 |
+
max-height: 80vh;
|
| 18 |
border-radius: 12px;
|
| 19 |
overflow: hidden;
|
| 20 |
background:
|
ui/chat.py
CHANGED
|
@@ -42,11 +42,7 @@ def _chatbox_value(text: str) -> dict[str, object]:
|
|
| 42 |
return {"text": text.strip(), "files": []}
|
| 43 |
|
| 44 |
|
| 45 |
-
def
|
| 46 |
-
return _chatbox_value(prompt)
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
def build_profile_prompt(
|
| 50 |
citizenship: str,
|
| 51 |
current_location: str,
|
| 52 |
education: str,
|
|
@@ -56,7 +52,7 @@ def build_profile_prompt(
|
|
| 56 |
family: str,
|
| 57 |
timeline: str,
|
| 58 |
goals: str,
|
| 59 |
-
) ->
|
| 60 |
sections = [
|
| 61 |
("Citizenship/passports", citizenship),
|
| 62 |
("Current location", current_location),
|
|
@@ -74,9 +70,12 @@ def build_profile_prompt(
|
|
| 74 |
if value and value.strip()
|
| 75 |
)
|
| 76 |
if not details:
|
| 77 |
-
details =
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
-
return
|
| 80 |
"Research realistic migration options for my profile.\n\n"
|
| 81 |
f"{details}\n\n"
|
| 82 |
"Please recommend 3-5 suitable countries, mark them on the globe, "
|
|
@@ -85,10 +84,71 @@ def build_profile_prompt(
|
|
| 85 |
)
|
| 86 |
|
| 87 |
|
| 88 |
-
def
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
gr.Markdown(
|
| 91 |
-
"## Borderless\n"
|
| 92 |
"Describe your background once. The agent researches official sources, "
|
| 93 |
"compares realistic visa pathways, and marks suitable countries on the globe.",
|
| 94 |
elem_classes=["borderless-hero"],
|
|
@@ -151,7 +211,7 @@ def render_intake_panel(chat_input: gr.MultimodalTextbox) -> None:
|
|
| 151 |
timeline,
|
| 152 |
goals,
|
| 153 |
],
|
| 154 |
-
outputs=
|
| 155 |
queue=False,
|
| 156 |
)
|
| 157 |
|
|
@@ -161,7 +221,7 @@ def render_intake_panel(chat_input: gr.MultimodalTextbox) -> None:
|
|
| 161 |
gr.Button(label, size="sm").click(
|
| 162 |
fn=example_prompt,
|
| 163 |
inputs=[gr.State(prompt)],
|
| 164 |
-
outputs=
|
| 165 |
queue=False,
|
| 166 |
)
|
| 167 |
|
|
@@ -172,17 +232,19 @@ class SidebarChatInterface(gr.ChatInterface):
|
|
| 172 |
fn,
|
| 173 |
*,
|
| 174 |
history_container: gr.Column | None = None,
|
|
|
|
| 175 |
**kwargs,
|
| 176 |
):
|
| 177 |
self._history_container = history_container
|
|
|
|
| 178 |
kwargs.setdefault("save_history", True)
|
| 179 |
super().__init__(fn, **kwargs)
|
| 180 |
|
| 181 |
def _render_history_area(self):
|
| 182 |
-
if self._history_container is not None:
|
| 183 |
with self._history_container:
|
| 184 |
super()._render_history_area()
|
| 185 |
-
with
|
| 186 |
render_globe_panel(height="70vh")
|
| 187 |
return
|
| 188 |
|
|
@@ -198,27 +260,75 @@ def create_chat_interface(
|
|
| 198 |
globe_state = gr.JSON(value=empty_globe_state(), visible=False, elem_id="globe-state")
|
| 199 |
chat_input = gr.MultimodalTextbox(
|
| 200 |
show_label=False,
|
| 201 |
-
placeholder="
|
| 202 |
file_count="multiple",
|
| 203 |
sources=["upload"],
|
| 204 |
render=False,
|
| 205 |
)
|
| 206 |
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
gr.
|
| 218 |
-
|
| 219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 220 |
],
|
| 221 |
-
|
| 222 |
)
|
| 223 |
|
| 224 |
globe_state.change(
|
|
|
|
| 42 |
return {"text": text.strip(), "files": []}
|
| 43 |
|
| 44 |
|
| 45 |
+
def _profile_prompt_text(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
citizenship: str,
|
| 47 |
current_location: str,
|
| 48 |
education: str,
|
|
|
|
| 52 |
family: str,
|
| 53 |
timeline: str,
|
| 54 |
goals: str,
|
| 55 |
+
) -> str:
|
| 56 |
sections = [
|
| 57 |
("Citizenship/passports", citizenship),
|
| 58 |
("Current location", current_location),
|
|
|
|
| 70 |
if value and value.strip()
|
| 71 |
)
|
| 72 |
if not details:
|
| 73 |
+
details = (
|
| 74 |
+
"- I have not filled in the profile yet. Ask me only for the "
|
| 75 |
+
"missing details that matter most."
|
| 76 |
+
)
|
| 77 |
|
| 78 |
+
return (
|
| 79 |
"Research realistic migration options for my profile.\n\n"
|
| 80 |
f"{details}\n\n"
|
| 81 |
"Please recommend 3-5 suitable countries, mark them on the globe, "
|
|
|
|
| 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,
|
| 109 |
+
education: str,
|
| 110 |
+
work_history: str,
|
| 111 |
+
languages: str,
|
| 112 |
+
budget: str,
|
| 113 |
+
family: str,
|
| 114 |
+
timeline: str,
|
| 115 |
+
goals: str,
|
| 116 |
+
) -> tuple:
|
| 117 |
+
return enter_research_workspace(
|
| 118 |
+
_profile_prompt_text(
|
| 119 |
+
citizenship,
|
| 120 |
+
current_location,
|
| 121 |
+
education,
|
| 122 |
+
work_history,
|
| 123 |
+
languages,
|
| 124 |
+
budget,
|
| 125 |
+
family,
|
| 126 |
+
timeline,
|
| 127 |
+
goals,
|
| 128 |
+
)
|
| 129 |
+
)
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
def example_prompt(prompt: str) -> tuple:
|
| 133 |
+
return enter_research_workspace(prompt)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def render_intake_panel(
|
| 137 |
+
chat_input: gr.MultimodalTextbox,
|
| 138 |
+
*,
|
| 139 |
+
intake_stage: gr.Column,
|
| 140 |
+
globe_column: gr.Column,
|
| 141 |
+
research_toolbar: gr.Row,
|
| 142 |
+
) -> None:
|
| 143 |
+
toggle_outputs = [
|
| 144 |
+
chat_input,
|
| 145 |
+
intake_stage,
|
| 146 |
+
globe_column,
|
| 147 |
+
research_toolbar,
|
| 148 |
+
]
|
| 149 |
+
|
| 150 |
+
with intake_stage:
|
| 151 |
gr.Markdown(
|
|
|
|
| 152 |
"Describe your background once. The agent researches official sources, "
|
| 153 |
"compares realistic visa pathways, and marks suitable countries on the globe.",
|
| 154 |
elem_classes=["borderless-hero"],
|
|
|
|
| 211 |
timeline,
|
| 212 |
goals,
|
| 213 |
],
|
| 214 |
+
outputs=toggle_outputs,
|
| 215 |
queue=False,
|
| 216 |
)
|
| 217 |
|
|
|
|
| 221 |
gr.Button(label, size="sm").click(
|
| 222 |
fn=example_prompt,
|
| 223 |
inputs=[gr.State(prompt)],
|
| 224 |
+
outputs=toggle_outputs,
|
| 225 |
queue=False,
|
| 226 |
)
|
| 227 |
|
|
|
|
| 232 |
fn,
|
| 233 |
*,
|
| 234 |
history_container: gr.Column | None = None,
|
| 235 |
+
globe_column: gr.Column | None = None,
|
| 236 |
**kwargs,
|
| 237 |
):
|
| 238 |
self._history_container = history_container
|
| 239 |
+
self._globe_column = globe_column
|
| 240 |
kwargs.setdefault("save_history", True)
|
| 241 |
super().__init__(fn, **kwargs)
|
| 242 |
|
| 243 |
def _render_history_area(self):
|
| 244 |
+
if self._history_container is not None and self._globe_column is not None:
|
| 245 |
with self._history_container:
|
| 246 |
super()._render_history_area()
|
| 247 |
+
with self._globe_column:
|
| 248 |
render_globe_panel(height="70vh")
|
| 249 |
return
|
| 250 |
|
|
|
|
| 260 |
globe_state = gr.JSON(value=empty_globe_state(), visible=False, elem_id="globe-state")
|
| 261 |
chat_input = gr.MultimodalTextbox(
|
| 262 |
show_label=False,
|
| 263 |
+
placeholder="Create a prompt from the form, choose a demo, or type directly...",
|
| 264 |
file_count="multiple",
|
| 265 |
sources=["upload"],
|
| 266 |
render=False,
|
| 267 |
)
|
| 268 |
|
| 269 |
+
with gr.Row(elem_classes=["borderless-main-workspace"], equal_height=False):
|
| 270 |
+
with gr.Column(
|
| 271 |
+
scale=7,
|
| 272 |
+
min_width=520,
|
| 273 |
+
elem_classes=["borderless-center-panel"],
|
| 274 |
+
):
|
| 275 |
+
intake_stage = gr.Column(
|
| 276 |
+
visible=True,
|
| 277 |
+
elem_classes=["borderless-intake-stage"],
|
| 278 |
+
)
|
| 279 |
+
research_toolbar = gr.Row(
|
| 280 |
+
visible=False,
|
| 281 |
+
elem_classes=["borderless-research-toolbar"],
|
| 282 |
+
)
|
| 283 |
+
globe_column = gr.Column(
|
| 284 |
+
visible=False,
|
| 285 |
+
elem_classes=["globe-column"],
|
| 286 |
+
)
|
| 287 |
+
with globe_column:
|
| 288 |
+
render_globe_panel(height="70vh")
|
| 289 |
+
|
| 290 |
+
with research_toolbar:
|
| 291 |
+
edit_profile_btn = gr.Button(
|
| 292 |
+
"← Edit profile",
|
| 293 |
+
size="sm",
|
| 294 |
+
variant="secondary",
|
| 295 |
+
)
|
| 296 |
+
|
| 297 |
+
render_intake_panel(
|
| 298 |
+
chat_input,
|
| 299 |
+
intake_stage=intake_stage,
|
| 300 |
+
globe_column=globe_column,
|
| 301 |
+
research_toolbar=research_toolbar,
|
| 302 |
+
)
|
| 303 |
+
|
| 304 |
+
with gr.Column(
|
| 305 |
+
scale=4,
|
| 306 |
+
min_width=360,
|
| 307 |
+
elem_classes=["borderless-chat-panel"],
|
| 308 |
+
):
|
| 309 |
+
chat = SidebarChatInterface(
|
| 310 |
+
respond,
|
| 311 |
+
multimodal=True,
|
| 312 |
+
textbox=chat_input,
|
| 313 |
+
history_container=history_container,
|
| 314 |
+
additional_inputs=[
|
| 315 |
+
gr.State(BORDERLESS_SYSTEM_PROMPT),
|
| 316 |
+
gr.State(DEFAULT_MAX_TOKENS),
|
| 317 |
+
gr.State(DEFAULT_TEMPERATURE),
|
| 318 |
+
gr.State(DEFAULT_TOP_P),
|
| 319 |
+
globe_state,
|
| 320 |
+
],
|
| 321 |
+
additional_outputs=[globe_state],
|
| 322 |
+
)
|
| 323 |
+
|
| 324 |
+
edit_profile_btn.click(
|
| 325 |
+
fn=return_to_intake,
|
| 326 |
+
outputs=[
|
| 327 |
+
intake_stage,
|
| 328 |
+
globe_column,
|
| 329 |
+
research_toolbar,
|
| 330 |
],
|
| 331 |
+
queue=False,
|
| 332 |
)
|
| 333 |
|
| 334 |
globe_state.change(
|
ui/sidebar.py
CHANGED
|
@@ -16,5 +16,5 @@ def render_sidebar() -> gr.Column:
|
|
| 16 |
gr.Markdown(
|
| 17 |
"_Research support only. Always verify details on official government sites._"
|
| 18 |
)
|
| 19 |
-
history_host = gr.Column()
|
| 20 |
return history_host
|
|
|
|
| 16 |
gr.Markdown(
|
| 17 |
"_Research support only. Always verify details on official government sites._"
|
| 18 |
)
|
| 19 |
+
history_host = gr.Column(elem_classes=["borderless-chat-history"])
|
| 20 |
return history_host
|