Skip to content

Commit 26f1a7b

Browse files
adhami3310masenf
andauthored
fix ai template (#5202)
* fix ai template * prebuilt -> premade Co-authored-by: Masen Furer <m_github@0x26.net> --------- Co-authored-by: Masen Furer <m_github@0x26.net>
1 parent ec6443f commit 26f1a7b

File tree

3 files changed

+21
-24
lines changed

3 files changed

+21
-24
lines changed

reflex/constants/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class Templates(SimpleNamespace):
134134
DEFAULT_TEMPLATE_URL = "https://blank-template.reflex.run"
135135

136136
# The reflex.build frontend host
137-
REFLEX_BUILD_FRONTEND = "https://flexgen.reflex.run"
137+
REFLEX_BUILD_FRONTEND = "https://reflex.build"
138138

139139
# The reflex.build backend host
140140
REFLEX_BUILD_BACKEND = "https://flexgen-prod-flexgen.fly.dev"

reflex/utils/prerequisites.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from reflex import constants, model
3939
from reflex.compiler import templates
4040
from reflex.config import Config, environment, get_config
41-
from reflex.utils import console, net, path_ops, processes
41+
from reflex.utils import console, net, path_ops, processes, redir
4242
from reflex.utils.decorator import once
4343
from reflex.utils.exceptions import (
4444
GeneratedCodeHasNoFunctionDefsError,
@@ -65,7 +65,6 @@ class Template:
6565
name: str
6666
description: str
6767
code_url: str
68-
demo_url: str | None = None
6968

7069

7170
@dataclasses.dataclass(frozen=True)
@@ -1606,22 +1605,13 @@ def prompt_for_template_options(templates: list[Template]) -> str:
16061605
# Show the user the URLs of each template to preview.
16071606
console.print("\nGet started with a template:")
16081607

1609-
def format_demo_url_str(url: str | None) -> str:
1610-
return f" ({url})" if url else ""
1611-
16121608
# Prompt the user to select a template.
1613-
id_to_name = {
1614-
str(
1615-
idx
1616-
): f"{template.name.replace('_', ' ').replace('-', ' ')}{format_demo_url_str(template.demo_url)} - {template.description}"
1617-
for idx, template in enumerate(templates)
1618-
}
1619-
for id in range(len(id_to_name)):
1620-
console.print(f"({id}) {id_to_name[str(id)]}")
1609+
for index, template in enumerate(templates):
1610+
console.print(f"({index}) {template.description}")
16211611

16221612
template = console.ask(
16231613
"Which template would you like to use?",
1624-
choices=[str(i) for i in range(len(id_to_name))],
1614+
choices=[str(i) for i in range(len(templates))],
16251615
show_choices=False,
16261616
default="0",
16271617
)
@@ -1890,14 +1880,17 @@ def initialize_app(app_name: str, template: str | None = None) -> str | None:
18901880

18911881
if template is None:
18921882
template = prompt_for_template_options(get_init_cli_prompt_options())
1883+
18931884
if template == constants.Templates.CHOOSE_TEMPLATES:
1894-
console.print(
1895-
f"Go to the templates page ({constants.Templates.REFLEX_TEMPLATES_URL}) and copy the command to init with a template."
1896-
)
1885+
redir.reflex_templates()
18971886
raise click.exceptions.Exit(0)
18981887

1888+
if template == constants.Templates.AI:
1889+
redir.reflex_build_redirect()
1890+
raise click.exceptions.Exit(0)
1891+
18991892
# If the blank template is selected, create a blank app.
1900-
if template in (constants.Templates.DEFAULT,):
1893+
if template == constants.Templates.DEFAULT:
19011894
# Default app creation behavior: a blank app.
19021895
initialize_default_app(app_name)
19031896
else:
@@ -1920,19 +1913,16 @@ def get_init_cli_prompt_options() -> list[Template]:
19201913
Template(
19211914
name=constants.Templates.DEFAULT,
19221915
description="A blank Reflex app.",
1923-
demo_url=constants.Templates.DEFAULT_TEMPLATE_URL,
19241916
code_url="",
19251917
),
19261918
Template(
19271919
name=constants.Templates.AI,
1928-
description="Generate a template using AI [Experimental]",
1929-
demo_url="",
1920+
description="[bold]Try our free AI builder.",
19301921
code_url="",
19311922
),
19321923
Template(
19331924
name=constants.Templates.CHOOSE_TEMPLATES,
1934-
description="Choose an existing template.",
1935-
demo_url="",
1925+
description="Premade templates built by the Reflex team.",
19361926
code_url="",
19371927
),
19381928
]

reflex/utils/redir.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ def open_browser(target_url: str) -> None:
2121
console.warn(
2222
f"Unable to automatically open the browser. Please navigate to {target_url} in your browser."
2323
)
24+
else:
25+
console.info(f"Opening browser to {target_url}.")
2426

2527

2628
def open_browser_and_wait(
@@ -52,3 +54,8 @@ def open_browser_and_wait(
5254
def reflex_build_redirect() -> None:
5355
"""Open the browser window to reflex.build."""
5456
open_browser(constants.Templates.REFLEX_BUILD_FRONTEND)
57+
58+
59+
def reflex_templates():
60+
"""Open the browser window to reflex.build/templates."""
61+
open_browser(constants.Templates.REFLEX_TEMPLATES_URL)

0 commit comments

Comments
 (0)