Skip to content

Commit e29f16d

Browse files
committed
add flexgen post end point to landing page prompt
1 parent 45c88a6 commit e29f16d

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

pcweb/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
# Reflex Cloud Backend
6767
RX_CLOUD_BACKEND = os.getenv("RX_CLOUD_BACKEND", "https://cloud-backend.reflex.dev/")
68-
68+
RX_BUILD_BACKEND = os.getenv("RX_BUILD_BACKEND", "https://build-backend.reflex.dev/")
6969

7070
# Stats
7171
GITHUB_STARS = 23000

pcweb/pages/landing/views/hero.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import uuid
2+
import httpx
13
import reflex as rx
24
from pcweb.components.icons.icons import get_icon_var
3-
from pcweb.constants import REFLEX_BUILD_URL
5+
from pcweb.constants import REFLEX_BUILD_URL, RX_BUILD_BACKEND
46
from reflex.experimental import ClientStateVar
57

68
textarea_x_pos = ClientStateVar.create(var_name="textarea_x_pos", default=0)
@@ -9,11 +11,23 @@
911

1012

1113
class SubmitPromptState(rx.State):
12-
13-
@rx.event
14-
def redirect_to_ai_builder(self, form_data: dict):
14+
@rx.event(background=True)
15+
async def redirect_to_ai_builder(self, form_data: dict):
1516
if prompt := form_data.get("prompt"):
16-
return rx.redirect(f"{REFLEX_BUILD_URL.strip('/')}/?prompt={prompt}")
17+
random_uuid = uuid.uuid4()
18+
19+
with httpx.AsyncClient() as client:
20+
await client.post(
21+
RX_BUILD_BACKEND.rstrip("/") + "/prompt",
22+
json={
23+
"prompt": prompt,
24+
"token": str(random_uuid),
25+
},
26+
)
27+
28+
return rx.redirect(
29+
REFLEX_BUILD_URL.strip("/") + "/prompt?token={random_uuid!s}"
30+
)
1731

1832

1933
@rx.memo

0 commit comments

Comments
 (0)