File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed
Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 6565
6666# Reflex Cloud Backend
6767RX_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
7171GITHUB_STARS = 23000
Original file line number Diff line number Diff line change 1+ import uuid
2+ import httpx
13import reflex as rx
24from 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
46from reflex .experimental import ClientStateVar
57
68textarea_x_pos = ClientStateVar .create (var_name = "textarea_x_pos" , default = 0 )
911
1012
1113class 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
You can’t perform that action at this time.
0 commit comments