|
|
| import gradio as gr
|
|
|
| from ui.intake.choices import (
|
| BUDGET_CHOICES,
|
| EDUCATION_CHOICES,
|
| EXPERIENCE_CHOICES,
|
| FAMILY_CHOICES,
|
| OCCUPATION_CHOICES,
|
| RESIDENCE_STATUS_CHOICES,
|
| TIMELINE_CHOICES,
|
| country_choices,
|
| )
|
| from ui.intake.examples import demo_personas, persona_prompt
|
| from ui.intake.prompts import build_profile_prompt
|
|
|
|
|
| def _searchable_dropdown(
|
| *,
|
| label: str,
|
| choices: list[str],
|
| multiselect: bool = False,
|
| info: str | None = None,
|
| ) -> gr.Dropdown:
|
| return gr.Dropdown(
|
| label=label,
|
| choices=choices,
|
| multiselect=multiselect,
|
| filterable=True,
|
| allow_custom_value=True,
|
| value=None,
|
| info=info,
|
| )
|
|
|
|
|
| def _create_research_prompt(
|
| current_country,
|
| residence_status,
|
| education,
|
| occupation,
|
| experience,
|
| budget,
|
| family,
|
| timeline,
|
| goals,
|
| ):
|
| return build_profile_prompt(
|
| None,
|
| current_country,
|
| residence_status,
|
| education,
|
| occupation,
|
| experience,
|
| None,
|
| budget,
|
| family,
|
| timeline,
|
| goals,
|
| )
|
|
|
|
|
| def render_intake_panel(chat_input: gr.MultimodalTextbox) -> None:
|
| countries = country_choices()
|
|
|
| with gr.Column(elem_classes=["borderless-form-panel"]):
|
| with gr.Row():
|
| current_country = _searchable_dropdown(
|
| label="Current country",
|
| choices=countries,
|
| )
|
| residence_status = _searchable_dropdown(
|
| label="Current residence status",
|
| choices=RESIDENCE_STATUS_CHOICES,
|
| )
|
| with gr.Row():
|
| education = _searchable_dropdown(
|
| label="Education",
|
| choices=EDUCATION_CHOICES,
|
| )
|
| occupation = _searchable_dropdown(
|
| label="Occupation",
|
| choices=OCCUPATION_CHOICES,
|
| )
|
| with gr.Row():
|
| experience = _searchable_dropdown(
|
| label="Experience",
|
| choices=EXPERIENCE_CHOICES,
|
| )
|
| timeline = _searchable_dropdown(
|
| label="Target timeline",
|
| choices=TIMELINE_CHOICES,
|
| )
|
| with gr.Row():
|
| budget = _searchable_dropdown(
|
| label="Budget",
|
| choices=BUDGET_CHOICES,
|
| )
|
| family = _searchable_dropdown(
|
| label="Family / dependents",
|
| choices=FAMILY_CHOICES,
|
| )
|
| goals = gr.Textbox(
|
| label="Goals in everyday language",
|
| lines=3,
|
| placeholder=(
|
| "e.g. I want a realistic skilled-worker route, lower risk, "
|
| "and a path to permanent residence."
|
| ),
|
| )
|
| gr.Button("Submit", variant="primary").click(
|
| fn=_create_research_prompt,
|
| inputs=[
|
| current_country,
|
| residence_status,
|
| education,
|
| occupation,
|
| experience,
|
| budget,
|
| family,
|
| timeline,
|
| goals,
|
| ],
|
| outputs=[chat_input],
|
| queue=False,
|
| )
|
|
|