instruction stringlengths 0 1k | input stringlengths 1 1k | output stringlengths 10 6.51k |
|---|---|---|
return
if is_add_operation:
new_customer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
... |
self._all_customers_data[i]["last_name"] = last_name
self._all_customers_data[i]["email"] = email_from_form
self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["role"] = role_from_form
self._all_c... | self._all_customers_data[i]["first_name"] = first_name |
mer = CustomerData(
customer_id=self._next_customer_id,
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
... |
self._all_customers_data[i]["email"] = email_from_form
self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["role"] = role_from_form
self._all_customers_data[i]["tags"] = self._parse_tags_string(
... | self._all_customers_data[i]["last_name"] = last_name |
first_name=first_name,
last_name=last_name,
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags... |
self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["role"] = role_from_form
self._all_customers_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
)
self._all_c... | self._all_customers_data[i]["email"] = email_from_form |
email=email_from_form,
phone=form_data.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoform... |
self._all_customers_data[i]["role"] = role_from_form
self._all_customers_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
)
self._all_customers_data[i]["updated_at"] = (
datetime... | self._all_customers_data[i]["status"] = status |
ata.get("phone"),
status=status,
avatar_url="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(... |
self._all_customers_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
)
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
cus... | self._all_customers_data[i]["role"] = role_from_form |
rl="/favicon.ico",
role=role_from_form,
tags=self._parse_tags_string(tags_str_from_form),
created_at=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all_cu... |
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
customer_found = True
break
if not customer_found:
self.error_message = f"Customer with ID {customer_id... | self._all_customers_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
) |
=datetime.datetime.now().isoformat(),
updated_at=datetime.datetime.now().isoformat(),
selected=False,
)
self._all_customers_data.append(new_customer)
self._next_customer_id += 1
toast_message = "User added successfully!"
else:
... |
customer_found = True
break
if not customer_found:
self.error_message = f"Customer with ID {customer_id} not found."
return
toast_message = "User updated successfully!"
self._target_customer_email_for_tags = email_... | self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
) |
self._all_customers_data.append(new_customer)
self._next_customer_id += 1
toast_message = "User added successfully!"
else:
customer_found = False
for i, cust in enumerate(self._all_customers_data):
if cust["customer_id"] == customer_id:... |
break
if not customer_found:
self.error_message = f"Customer with ID {customer_id} not found."
return
toast_message = "User updated successfully!"
self._target_customer_email_for_tags = email_from_form
self._target_customer_ta... | customer_found = True |
self._next_customer_id += 1
toast_message = "User added successfully!"
else:
customer_found = False
for i, cust in enumerate(self._all_customers_data):
if cust["customer_id"] == customer_id:
self._all_customers_data[i]["first_name... |
toast_message = "User updated successfully!"
self._target_customer_email_for_tags = email_from_form
self._target_customer_tag_str = tags_str_from_form
self._target_customer_role = role_from_form
self.show_edit_dialog = False
self._reset_form_fields()
self.t... | if not customer_found:
self.error_message = f"Customer with ID {customer_id} not found."
return |
toast_message = "User added successfully!"
else:
customer_found = False
for i, cust in enumerate(self._all_customers_data):
if cust["customer_id"] == customer_id:
self._all_customers_data[i]["first_name"] = first_name
sel... |
return
toast_message = "User updated successfully!"
self._target_customer_email_for_tags = email_from_form
self._target_customer_tag_str = tags_str_from_form
self._target_customer_role = role_from_form
self.show_edit_dialog = False
self._reset_form_... | self.error_message = f"Customer with ID {customer_id} not found." |
e
for i, cust in enumerate(self._all_customers_data):
if cust["customer_id"] == customer_id:
self._all_customers_data[i]["first_name"] = first_name
self._all_customers_data[i]["last_name"] = last_name
self._all_customers_data[i]["em... |
self._target_customer_email_for_tags = email_from_form
self._target_customer_tag_str = tags_str_from_form
self._target_customer_role = role_from_form
self.show_edit_dialog = False
self._reset_form_fields()
self.total_db_customers = len(self._all_customers_data)
... | toast_message = "User updated successfully!" |
mers_data):
if cust["customer_id"] == customer_id:
self._all_customers_data[i]["first_name"] = first_name
self._all_customers_data[i]["last_name"] = last_name
self._all_customers_data[i]["email"] = email_from_form
self._all_... |
self._target_customer_tag_str = tags_str_from_form
self._target_customer_role = role_from_form
self.show_edit_dialog = False
self._reset_form_fields()
self.total_db_customers = len(self._all_customers_data)
yield CustomerState.fetch_customers
yield rx.toast(toa... | self._target_customer_email_for_tags = email_from_form |
id:
self._all_customers_data[i]["first_name"] = first_name
self._all_customers_data[i]["last_name"] = last_name
self._all_customers_data[i]["email"] = email_from_form
self._all_customers_data[i]["status"] = status
self._... |
self._target_customer_role = role_from_form
self.show_edit_dialog = False
self._reset_form_fields()
self.total_db_customers = len(self._all_customers_data)
yield CustomerState.fetch_customers
yield rx.toast(toast_message, duration=3000)
@rx.event
def set_form_... | self._target_customer_tag_str = tags_str_from_form |
name"] = first_name
self._all_customers_data[i]["last_name"] = last_name
self._all_customers_data[i]["email"] = email_from_form
self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["role"] = role_from_form
... |
self.show_edit_dialog = False
self._reset_form_fields()
self.total_db_customers = len(self._all_customers_data)
yield CustomerState.fetch_customers
yield rx.toast(toast_message, duration=3000)
@rx.event
def set_form_status(self, status: str):
self.form_status ... | self._target_customer_role = role_from_form |
tomers_data[i]["last_name"] = last_name
self._all_customers_data[i]["email"] = email_from_form
self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["role"] = role_from_form
self._all_customers_data[i]["tags"] = self._p... |
self._reset_form_fields()
self.total_db_customers = len(self._all_customers_data)
yield CustomerState.fetch_customers
yield rx.toast(toast_message, duration=3000)
@rx.event
def set_form_status(self, status: str):
self.form_status = status
@rx.event
def set_for... | self.show_edit_dialog = False |
stomers_data[i]["email"] = email_from_form
self._all_customers_data[i]["status"] = status
self._all_customers_data[i]["role"] = role_from_form
self._all_customers_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
... |
yield CustomerState.fetch_customers
yield rx.toast(toast_message, duration=3000)
@rx.event
def set_form_status(self, status: str):
self.form_status = status
@rx.event
def set_form_tags(self, tags: str):
self.form_tags = tags
@rx.event
def set_form_role(self, ... | self.total_db_customers = len(self._all_customers_data) |
from_form
self._all_customers_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
)
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
... |
@rx.event
def set_form_tags(self, tags: str):
self.form_tags = tags
@rx.event
def set_form_role(self, role: str):
self.form_role = role
@rx.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(self._all_customers_data... | def set_form_status(self, status: str):
self.form_status = status |
s_data[i]["tags"] = self._parse_tags_string(
tags_str_from_form
)
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
customer_found = True
... |
@rx.event
def set_form_tags(self, tags: str):
self.form_tags = tags
@rx.event
def set_form_role(self, role: str):
self.form_role = role
@rx.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(self._all_customers_data... | self.form_status = status |
tags_str_from_form
)
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
customer_found = True
break
if not customer_found:
... |
@rx.event
def set_form_role(self, role: str):
self.form_role = role
@rx.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(self._all_customers_data)):
self._all_customers_data[i]["selected"] = self.all_selected
@rx.... | def set_form_tags(self, tags: str):
self.form_tags = tags |
)
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
customer_found = True
break
if not customer_found:
self.error_message = f"Customer ... |
@rx.event
def set_form_role(self, role: str):
self.form_role = role
@rx.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(self._all_customers_data)):
self._all_customers_data[i]["selected"] = self.all_selected
@rx.... | self.form_tags = tags |
self._all_customers_data[i]["updated_at"] = (
datetime.datetime.now().isoformat()
)
customer_found = True
break
if not customer_found:
self.error_message = f"Customer with ID {customer_id} not found."
... |
@rx.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(self._all_customers_data)):
self._all_customers_data[i]["selected"] = self.all_selected
@rx.event
def toggle_select_customer(self, customer_id: int):
all_are_selecte... | def set_form_role(self, role: str):
self.form_role = role |
(
datetime.datetime.now().isoformat()
)
customer_found = True
break
if not customer_found:
self.error_message = f"Customer with ID {customer_id} not found."
return
toast_message = ... |
@rx.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(self._all_customers_data)):
self._all_customers_data[i]["selected"] = self.all_selected
@rx.event
def toggle_select_customer(self, customer_id: int):
all_are_selecte... | self.form_role = role |
me.now().isoformat()
)
customer_found = True
break
if not customer_found:
self.error_message = f"Customer with ID {customer_id} not found."
return
toast_message = "User updated successfully!"
sel... |
@rx.event
def toggle_select_customer(self, customer_id: int):
all_are_selected_after_toggle = True
found = False
for i in range(len(self._all_customers_data)):
if self._all_customers_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selecte... | def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(self._all_customers_data)):
self._all_customers_data[i]["selected"] = self.all_selected |
)
customer_found = True
break
if not customer_found:
self.error_message = f"Customer with ID {customer_id} not found."
return
toast_message = "User updated successfully!"
self._target_customer_email_for_tags = e... |
for i in range(len(self._all_customers_data)):
self._all_customers_data[i]["selected"] = self.all_selected
@rx.event
def toggle_select_customer(self, customer_id: int):
all_are_selected_after_toggle = True
found = False
for i in range(len(self._all_customers_data)):... | self.all_selected = not self.all_selected |
break
if not customer_found:
self.error_message = f"Customer with ID {customer_id} not found."
return
toast_message = "User updated successfully!"
self._target_customer_email_for_tags = email_from_form
self._target_customer_tag_s... |
@rx.event
def toggle_select_customer(self, customer_id: int):
all_are_selected_after_toggle = True
found = False
for i in range(len(self._all_customers_data)):
if self._all_customers_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selecte... | for i in range(len(self._all_customers_data)):
self._all_customers_data[i]["selected"] = self.all_selected |
self.error_message = f"Customer with ID {customer_id} not found."
return
toast_message = "User updated successfully!"
self._target_customer_email_for_tags = email_from_form
self._target_customer_tag_str = tags_str_from_form
self._target_customer_role ... |
@rx.event
def toggle_select_customer(self, customer_id: int):
all_are_selected_after_toggle = True
found = False
for i in range(len(self._all_customers_data)):
if self._all_customers_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selecte... | self._all_customers_data[i]["selected"] = self.all_selected |
."
return
toast_message = "User updated successfully!"
self._target_customer_email_for_tags = email_from_form
self._target_customer_tag_str = tags_str_from_form
self._target_customer_role = role_from_form
self.show_edit_dialog = False
self._reset_for... |
@rx.event(background=True)
async def download_csv(self):
async with self:
if not self._all_customers_data:
self.error_message = "No customer data available to download. Please fetch customers first."
yield rx.toast(
"No customer data to d... | def toggle_select_customer(self, customer_id: int):
all_are_selected_after_toggle = True
found = False
for i in range(len(self._all_customers_data)):
if self._all_customers_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selected"] = not self._all_... |
updated successfully!"
self._target_customer_email_for_tags = email_from_form
self._target_customer_tag_str = tags_str_from_form
self._target_customer_role = role_from_form
self.show_edit_dialog = False
self._reset_form_fields()
self.total_db_customers = len(self._all_c... |
found = False
for i in range(len(self._all_customers_data)):
if self._all_customers_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selected"] = not self._all_customers_data[
i
]["selected"]
found = True... | all_are_selected_after_toggle = True |
customer_email_for_tags = email_from_form
self._target_customer_tag_str = tags_str_from_form
self._target_customer_role = role_from_form
self.show_edit_dialog = False
self._reset_form_fields()
self.total_db_customers = len(self._all_customers_data)
yield CustomerState.f... |
for i in range(len(self._all_customers_data)):
if self._all_customers_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selected"] = not self._all_customers_data[
i
]["selected"]
found = True
if not se... | found = False |
tags_str_from_form
self._target_customer_role = role_from_form
self.show_edit_dialog = False
self._reset_form_fields()
self.total_db_customers = len(self._all_customers_data)
yield CustomerState.fetch_customers
yield rx.toast(toast_message, duration=3000)
@rx.even... |
if not self._all_customers_data[i]["selected"]:
all_are_selected_after_toggle = False
if found:
self.all_selected = all_are_selected_after_toggle
@rx.event(background=True)
async def download_csv(self):
async with self:
if not self._all_custo... | if self._all_customers_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selected"] = not self._all_customers_data[
i
]["selected"]
found = True |
self.show_edit_dialog = False
self._reset_form_fields()
self.total_db_customers = len(self._all_customers_data)
yield CustomerState.fetch_customers
yield rx.toast(toast_message, duration=3000)
@rx.event
def set_form_status(self, status: str):
self.form_status = statu... |
found = True
if not self._all_customers_data[i]["selected"]:
all_are_selected_after_toggle = False
if found:
self.all_selected = all_are_selected_after_toggle
@rx.event(background=True)
async def download_csv(self):
async with self:
... | self._all_customers_data[i]["selected"] = not self._all_customers_data[
i
]["selected"] |
yield CustomerState.fetch_customers
yield rx.toast(toast_message, duration=3000)
@rx.event
def set_form_status(self, status: str):
self.form_status = status
@rx.event
def set_form_tags(self, tags: str):
self.form_tags = tags
@rx.event
def set_form_role(self, role: str)... |
if not self._all_customers_data[i]["selected"]:
all_are_selected_after_toggle = False
if found:
self.all_selected = all_are_selected_after_toggle
@rx.event(background=True)
async def download_csv(self):
async with self:
if not self._all_custo... | found = True |
_customers
yield rx.toast(toast_message, duration=3000)
@rx.event
def set_form_status(self, status: str):
self.form_status = status
@rx.event
def set_form_tags(self, tags: str):
self.form_tags = tags
@rx.event
def set_form_role(self, role: str):
self.form_role ... |
if found:
self.all_selected = all_are_selected_after_toggle
@rx.event(background=True)
async def download_csv(self):
async with self:
if not self._all_customers_data:
self.error_message = "No customer data available to download. Please fetch customers fi... | if not self._all_customers_data[i]["selected"]:
all_are_selected_after_toggle = False |
@rx.event
def set_form_status(self, status: str):
self.form_status = status
@rx.event
def set_form_tags(self, tags: str):
self.form_tags = tags
@rx.event
def set_form_role(self, role: str):
self.form_role = role
@rx.event
def toggle_select_all(self):
s... |
if found:
self.all_selected = all_are_selected_after_toggle
@rx.event(background=True)
async def download_csv(self):
async with self:
if not self._all_customers_data:
self.error_message = "No customer data available to download. Please fetch customers fi... | all_are_selected_after_toggle = False |
tatus: str):
self.form_status = status
@rx.event
def set_form_tags(self, tags: str):
self.form_tags = tags
@rx.event
def set_form_role(self, role: str):
self.form_role = role
@rx.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
... |
@rx.event(background=True)
async def download_csv(self):
async with self:
if not self._all_customers_data:
self.error_message = "No customer data available to download. Please fetch customers first."
yield rx.toast(
"No customer data to d... | if found:
self.all_selected = all_are_selected_after_toggle |
elf.form_status = status
@rx.event
def set_form_tags(self, tags: str):
self.form_tags = tags
@rx.event
def set_form_role(self, role: str):
self.form_role = role
@rx.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(... |
@rx.event(background=True)
async def download_csv(self):
async with self:
if not self._all_customers_data:
self.error_message = "No customer data available to download. Please fetch customers first."
yield rx.toast(
"No customer data to d... | self.all_selected = all_are_selected_after_toggle |
role: str):
self.form_role = role
@rx.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(self._all_customers_data)):
self._all_customers_data[i]["selected"] = self.all_selected
@rx.event
def toggle_select_customer(self, c... |
self.loading = True
self.error_message = ""
try:
df_export_data = []
for cust_data_item in self._all_customers_data:
tags_str_repr = ", ".join(cust_data_item["tags"])
df_export_data.append(
{
... | if not self._all_customers_data:
self.error_message = "No customer data available to download. Please fetch customers first."
yield rx.toast(
"No customer data to download.",
duration=3000,
)
return |
x.event
def toggle_select_all(self):
self.all_selected = not self.all_selected
for i in range(len(self._all_customers_data)):
self._all_customers_data[i]["selected"] = self.all_selected
@rx.event
def toggle_select_customer(self, customer_id: int):
all_are_selected_after_... |
yield rx.toast(
"No customer data to download.",
duration=3000,
)
return
self.loading = True
self.error_message = ""
try:
df_export_data = []
for cust_data_item in self._all_c... | self.error_message = "No customer data available to download. Please fetch customers first." |
lf, customer_id: int):
all_are_selected_after_toggle = True
found = False
for i in range(len(self._all_customers_data)):
if self._all_customers_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selected"] = not self._all_customers_data[
... |
self.error_message = ""
try:
df_export_data = []
for cust_data_item in self._all_customers_data:
tags_str_repr = ", ".join(cust_data_item["tags"])
df_export_data.append(
{
"ID": cust_data_item["custo... | self.loading = True |
ll_are_selected_after_toggle = True
found = False
for i in range(len(self._all_customers_data)):
if self._all_customers_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selected"] = not self._all_customers_data[
i
]["sele... |
try:
df_export_data = []
for cust_data_item in self._all_customers_data:
tags_str_repr = ", ".join(cust_data_item["tags"])
df_export_data.append(
{
"ID": cust_data_item["customer_id"],
"F... | self.error_message = "" |
= False
for i in range(len(self._all_customers_data)):
if self._all_customers_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selected"] = not self._all_customers_data[
i
]["selected"]
found = True
i... |
for cust_data_item in self._all_customers_data:
tags_str_repr = ", ".join(cust_data_item["tags"])
df_export_data.append(
{
"ID": cust_data_item["customer_id"],
"First Name": cust_data_item["first_name"],
... | df_export_data = [] |
len(self._all_customers_data)):
if self._all_customers_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selected"] = not self._all_customers_data[
i
]["selected"]
found = True
if not self._all_customers_data[i... |
if not df_export_data:
async with self:
self.error_message = "No customers to download."
yield rx.toast(
"No customer data available to download.",
duration=3000,
)
return
... | for cust_data_item in self._all_customers_data:
tags_str_repr = ", ".join(cust_data_item["tags"])
df_export_data.append(
{
"ID": cust_data_item["customer_id"],
"First Name": cust_data_item["first_name"],
... |
rs_data[i]["customer_id"] == customer_id:
self._all_customers_data[i]["selected"] = not self._all_customers_data[
i
]["selected"]
found = True
if not self._all_customers_data[i]["selected"]:
all_are_selected_after_toggle = F... |
df_export_data.append(
{
"ID": cust_data_item["customer_id"],
"First Name": cust_data_item["first_name"],
"Last Name": cust_data_item["last_name"],
"Email": cust_data_item["email"],
... | tags_str_repr = ", ".join(cust_data_item["tags"]) |
)
return
self.loading = True
self.error_message = ""
try:
df_export_data = []
for cust_data_item in self._all_customers_data:
tags_str_repr = ", ".join(cust_data_item["tags"])
df_export_data.append(
... |
df = pd.DataFrame(df_export_data)
csv_data = df.to_csv(index=False)
filename = (
f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv"
)
yield rx.download(data=csv_data, filename=filename)
yield rx.toast("CSV downloa... | if not df_export_data:
async with self:
self.error_message = "No customers to download."
yield rx.toast(
"No customer data available to download.",
duration=3000,
)
return |
lf.error_message = ""
try:
df_export_data = []
for cust_data_item in self._all_customers_data:
tags_str_repr = ", ".join(cust_data_item["tags"])
df_export_data.append(
{
"ID": cust_data_item["customer_id"],
... |
yield rx.toast(
"No customer data available to download.",
duration=3000,
)
return
df = pd.DataFrame(df_export_data)
csv_data = df.to_csv(index=False)
filename = (
f"customers_{da... | self.error_message = "No customers to download." |
{
"ID": cust_data_item["customer_id"],
"First Name": cust_data_item["first_name"],
"Last Name": cust_data_item["last_name"],
"Email": cust_data_item["email"],
"Phone": cust_data_it... |
csv_data = df.to_csv(index=False)
filename = (
f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv"
)
yield rx.download(data=csv_data, filename=filename)
yield rx.toast("CSV download started.", duration=3000)
except Exc... | df = pd.DataFrame(df_export_data) |
"ID": cust_data_item["customer_id"],
"First Name": cust_data_item["first_name"],
"Last Name": cust_data_item["last_name"],
"Email": cust_data_item["email"],
"Phone": cust_data_item.get("phone", ""),
"... |
filename = (
f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv"
)
yield rx.download(data=csv_data, filename=filename)
yield rx.toast("CSV download started.", duration=3000)
except Exception as e:
async with self:
... | csv_data = df.to_csv(index=False) |
"First Name": cust_data_item["first_name"],
"Last Name": cust_data_item["last_name"],
"Email": cust_data_item["email"],
"Phone": cust_data_item.get("phone", ""),
"Status": cust_data_item["status"],
... |
yield rx.download(data=csv_data, filename=filename)
yield rx.toast("CSV download started.", duration=3000)
except Exception as e:
async with self:
self.error_message = f"Failed to download CSV: {e!s}"
yield rx.toast(
f"Error downlo... | filename = (
f"customers_{datetime.datetime.now().strftime('%Y%m%d_%H%M%S')}.csv"
) |
"Role": cust_data_item["role"],
"Tags": tags_str_repr,
"Created At": cust_data_item["created_at"],
"Updated At": cust_data_item["updated_at"],
}
)
if not df_export_data:
... |
yield rx.toast(
f"Error downloading CSV: {e!s}",
duration=5000,
)
finally:
async with self:
self.loading = False
@rx.event
def set_search_query(self, query: str):
self.search_query = query
self.current_... | self.error_message = f"Failed to download CSV: {e!s}" |
}
)
if not df_export_data:
async with self:
self.error_message = "No customers to download."
yield rx.toast(
"No customer data available to download.",
duration=3000,
)
... |
@rx.event
def set_search_query(self, query: str):
self.search_query = query
self.current_page = 1
| self.loading = False |
if not df_export_data:
async with self:
self.error_message = "No customers to download."
yield rx.toast(
"No customer data available to download.",
duration=3000,
)
return
df = pd.D... | def set_search_query(self, query: str):
self.search_query = query
self.current_page = 1 | |
with self:
self.error_message = "No customers to download."
yield rx.toast(
"No customer data available to download.",
duration=3000,
)
return
df = pd.DataFrame(df_export_data)
csv_data = ... |
self.current_page = 1
| self.search_query = query |
f.error_message = "No customers to download."
yield rx.toast(
"No customer data available to download.",
duration=3000,
)
return
df = pd.DataFrame(df_export_data)
csv_data = df.to_csv(index=False)
... | self.current_page = 1 | |
from . import styles
# Import all the pages.
from .pages import *
app = rx.App(
style=styles.base_style,
stylesheets=styles.base_stylesheets,
html_lang="en",
html_custom_attrs={"className": "!scroll-smooth"},
theme=rx.theme(
appearance="inherit",
has_background=True,
scal... | import reflex as rx | |
import reflex as rx
|
# Import all the pages.
from .pages import *
app = rx.App(
style=styles.base_style,
stylesheets=styles.base_stylesheets,
html_lang="en",
html_custom_attrs={"className": "!scroll-smooth"},
theme=rx.theme(
appearance="inherit",
has_background=True,
scaling="100%",
ra... | from . import styles |
import reflex as rx
from . import styles
# Import all the pages.
|
app = rx.App(
style=styles.base_style,
stylesheets=styles.base_stylesheets,
html_lang="en",
html_custom_attrs={"className": "!scroll-smooth"},
theme=rx.theme(
appearance="inherit",
has_background=True,
scaling="100%",
radius="none",
accent_color="violet",
... | from .pages import * |
sidebar_width = ["100%", "100%", "100%", "375px", "450px"]
border = f"1.5px solid {rx.color('gray', 5, True)}"
content_max_width = "1280px"
sidebar_bg = rx.color("gray", 2)
content_bg_color = rx.color("gray", 1)
image_style = {
"decoding": "auto",
"loading": "eager",
"vertical_align": "middle",
"obje... | import reflex as rx | |
import reflex as rx
sidebar_width = ["100%", "100%", "100%", "375px", "450px"]
border = f"1.5px solid {rx.color('gray', 5, True)}"
|
sidebar_bg = rx.color("gray", 2)
content_bg_color = rx.color("gray", 1)
image_style = {
"decoding": "auto",
"loading": "eager",
"vertical_align": "middle",
"object_fit": "contain",
"width": "auto",
}
image_height = ["400px", "500px", "650px", "850px"]
image_props = {
"style": image_style,
... | content_max_width = "1280px" |
import reflex as rx
sidebar_width = ["100%", "100%", "100%", "375px", "450px"]
border = f"1.5px solid {rx.color('gray', 5, True)}"
content_max_width = "1280px"
|
content_bg_color = rx.color("gray", 1)
image_style = {
"decoding": "auto",
"loading": "eager",
"vertical_align": "middle",
"object_fit": "contain",
"width": "auto",
}
image_height = ["400px", "500px", "650px", "850px"]
image_props = {
"style": image_style,
"width": "100%",
"height": ... | sidebar_bg = rx.color("gray", 2) |
import reflex as rx
sidebar_width = ["100%", "100%", "100%", "375px", "450px"]
border = f"1.5px solid {rx.color('gray', 5, True)}"
content_max_width = "1280px"
sidebar_bg = rx.color("gray", 2)
|
image_style = {
"decoding": "auto",
"loading": "eager",
"vertical_align": "middle",
"object_fit": "contain",
"width": "auto",
}
image_height = ["400px", "500px", "650px", "850px"]
image_props = {
"style": image_style,
"width": "100%",
"height": image_height,
}
button_props = {
"... | content_bg_color = rx.color("gray", 1) |
import reflex as rx
sidebar_width = ["100%", "100%", "100%", "375px", "450px"]
border = f"1.5px solid {rx.color('gray', 5, True)}"
content_max_width = "1280px"
sidebar_bg = rx.color("gray", 2)
content_bg_color = rx.color("gray", 1)
image_style = {
"decoding": "auto",
"loading": "eager",
"vertical_align": ... |
image_props = {
"style": image_style,
"width": "100%",
"height": image_height,
}
button_props = {
"size": "2",
"cursor": "pointer",
"variant": "outline",
}
box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)"
base_stylesheets = [
"https://fonts.googleapis.com/css... | image_height = ["400px", "500px", "650px", "850px"] |
import reflex as rx
sidebar_width = ["100%", "100%", "100%", "375px", "450px"]
border = f"1.5px solid {rx.color('gray', 5, True)}"
content_max_width = "1280px"
sidebar_bg = rx.color("gray", 2)
content_bg_color = rx.color("gray", 1)
image_style = {
"decoding": "auto",
"loading": "eager",
"vertical_align": ... |
button_props = {
"size": "2",
"cursor": "pointer",
"variant": "outline",
}
box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)"
base_stylesheets = [
"https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700;800&display=swap",
"react-zoom.css",
]
base_sty... | image_props = {
"style": image_style,
"width": "100%",
"height": image_height,
} |
import reflex as rx
sidebar_width = ["100%", "100%", "100%", "375px", "450px"]
border = f"1.5px solid {rx.color('gray', 5, True)}"
content_max_width = "1280px"
sidebar_bg = rx.color("gray", 2)
content_bg_color = rx.color("gray", 1)
image_style = {
"decoding": "auto",
"loading": "eager",
"vertical_align": ... |
box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)"
base_stylesheets = [
"https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700;800&display=swap",
"react-zoom.css",
]
base_style = {
"font_family": "Roboto Flex",
rx.icon: {
"stroke_width": "1.75px"... | button_props = {
"size": "2",
"cursor": "pointer",
"variant": "outline",
} |
import reflex as rx
sidebar_width = ["100%", "100%", "100%", "375px", "450px"]
border = f"1.5px solid {rx.color('gray', 5, True)}"
content_max_width = "1280px"
sidebar_bg = rx.color("gray", 2)
content_bg_color = rx.color("gray", 1)
image_style = {
"decoding": "auto",
"loading": "eager",
"vertical_align": ... |
base_stylesheets = [
"https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700;800&display=swap",
"react-zoom.css",
]
base_style = {
"font_family": "Roboto Flex",
rx.icon: {
"stroke_width": "1.75px",
},
}
| box_shadow = "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)" |
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatus(Enum):
S... | import asyncio | |
import asyncio
|
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatus(Enum):
STARTING = "start... | import datetime |
import asyncio
import datetime
import os
|
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatus(Enum):
STARTING = "starting"
PROCESSING = "processin... | from enum import Enum |
import asyncio
import datetime
import os
from enum import Enum
|
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatus(Enum):
STARTING = "starting"
PROCESSING = "processing"
SUCCEEDED = "s... | import reflex as rx |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
|
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatus(Enum):
STARTING = "starting"
PROCESSING = "processing"
SUCCEEDED = "succeeded"
FAI... | import replicate |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
|
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatus(Enum):
STARTING = "starting"
PROCESSING = "processing"
SUCCEEDED = "succeeded"
FAILED = "failed"
CANCELED = "canceled"
class Ge... | from .options import OptionsState |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
|
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatus(Enum):
STARTING = "starting"
PROCESSING = "processing"
SUCCEEDED = "succeeded"
FAILED = "failed"
CANCELED = "canceled"
class GeneratorState(rx.State):
is_ge... | DEFAULT_IMAGE = "/default.webp" |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
|
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatus(Enum):
STARTING = "starting"
PROCESSING = "processing"
SUCCEEDED = "succeeded"
FAILED = "failed"
CANCELED = "canceled"
class GeneratorState(rx.State):
is_generating: bool = False
is_upscaling: b... | API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN" |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
|
class ResponseStatus(Enum):
STARTING = "starting"
PROCESSING = "processing"
SUCCEEDED = "succeeded"
FAILED = "failed"
CANCELED = "canceled"
class GeneratorState(rx.State):
is_generating: bool = False
is_upscaling: bool = False
_request_id: str = None
output_image: str = DEFAULT_... | CopyLocalState = rx._x.client_state(default=False, var_name="copying") |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
|
class GeneratorState(rx.State):
is_generating: bool = False
is_upscaling: bool = False
_request_id: str = None
output_image: str = DEFAULT_IMAGE
output_list: list[str] = []
upscaled_image: str = ""
is_downloading: bool = False
@rx.event
def set_output_image(self, value: str):
... | class ResponseStatus(Enum):
STARTING = "starting"
PROCESSING = "processing"
SUCCEEDED = "succeeded"
FAILED = "failed"
CANCELED = "canceled" |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatu... |
PROCESSING = "processing"
SUCCEEDED = "succeeded"
FAILED = "failed"
CANCELED = "canceled"
class GeneratorState(rx.State):
is_generating: bool = False
is_upscaling: bool = False
_request_id: str = None
output_image: str = DEFAULT_IMAGE
output_list: list[str] = []
upscaled_image... | STARTING = "starting" |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatu... |
SUCCEEDED = "succeeded"
FAILED = "failed"
CANCELED = "canceled"
class GeneratorState(rx.State):
is_generating: bool = False
is_upscaling: bool = False
_request_id: str = None
output_image: str = DEFAULT_IMAGE
output_list: list[str] = []
upscaled_image: str = ""
is_downloading:... | PROCESSING = "processing" |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatu... |
FAILED = "failed"
CANCELED = "canceled"
class GeneratorState(rx.State):
is_generating: bool = False
is_upscaling: bool = False
_request_id: str = None
output_image: str = DEFAULT_IMAGE
output_list: list[str] = []
upscaled_image: str = ""
is_downloading: bool = False
@rx.event... | SUCCEEDED = "succeeded" |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatu... |
CANCELED = "canceled"
class GeneratorState(rx.State):
is_generating: bool = False
is_upscaling: bool = False
_request_id: str = None
output_image: str = DEFAULT_IMAGE
output_list: list[str] = []
upscaled_image: str = ""
is_downloading: bool = False
@rx.event
def set_output_im... | FAILED = "failed" |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatu... |
class GeneratorState(rx.State):
is_generating: bool = False
is_upscaling: bool = False
_request_id: str = None
output_image: str = DEFAULT_IMAGE
output_list: list[str] = []
upscaled_image: str = ""
is_downloading: bool = False
@rx.event
def set_output_image(self, value: str):
... | CANCELED = "canceled" |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatu... |
@rx.event(background=True)
async def generate_image(self):
try:
# Check if the env variable is set
if not self._check_api_token():
return
if self.is_upscaling:
yield rx.toast.warning("Wait for the image to upscale first")
... | def set_output_image(self, value: str):
self.output_image = value |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatu... |
@rx.event(background=True)
async def generate_image(self):
try:
# Check if the env variable is set
if not self._check_api_token():
return
if self.is_upscaling:
yield rx.toast.warning("Wait for the image to upscale first")
... | self.output_image = value |
import asyncio
import datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatu... |
if self.is_upscaling:
yield rx.toast.warning("Wait for the image to upscale first")
return
async with self:
Options = await self.get_state(OptionsState)
# If prompt is empty
if Options.prompt == "":
yield rx... | if not self._check_api_token():
return |
ort datetime
import os
from enum import Enum
import reflex as rx
import replicate
import requests
from .options import OptionsState
DEFAULT_IMAGE = "/default.webp"
API_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatus(Enum):
START... |
async with self:
Options = await self.get_state(OptionsState)
# If prompt is empty
if Options.prompt == "":
yield rx.toast.warning("Please enter a prompt")
return
input = {
"width": Options.selected_dimensio... | if self.is_upscaling:
yield rx.toast.warning("Wait for the image to upscale first")
return |
PI_TOKEN_ENV_VAR = "REPLICATE_API_TOKEN"
CopyLocalState = rx._x.client_state(default=False, var_name="copying")
class ResponseStatus(Enum):
STARTING = "starting"
PROCESSING = "processing"
SUCCEEDED = "succeeded"
FAILED = "failed"
CANCELED = "canceled"
class GeneratorState(rx.State):
is_gene... |
# If prompt is empty
if Options.prompt == "":
yield rx.toast.warning("Please enter a prompt")
return
input = {
"width": Options.selected_dimensions[0],
"height": Options.selected_dimensions[1],
"prompt":... | Options = await self.get_state(OptionsState) |
e, var_name="copying")
class ResponseStatus(Enum):
STARTING = "starting"
PROCESSING = "processing"
SUCCEEDED = "succeeded"
FAILED = "failed"
CANCELED = "canceled"
class GeneratorState(rx.State):
is_generating: bool = False
is_upscaling: bool = False
_request_id: str = None
output... |
input = {
"width": Options.selected_dimensions[0],
"height": Options.selected_dimensions[1],
"prompt": Options.prompt + Options.selected_style_prompt,
"negative_prompt": Options.negative_prompt,
"num_inference_steps": Options.s... | if Options.prompt == "":
yield rx.toast.warning("Please enter a prompt")
return |
"succeeded"
FAILED = "failed"
CANCELED = "canceled"
class GeneratorState(rx.State):
is_generating: bool = False
is_upscaling: bool = False
_request_id: str = None
output_image: str = DEFAULT_IMAGE
output_list: list[str] = []
upscaled_image: str = ""
is_downloading: bool = False
... |
# Add "seed" to the input if it is not 0
if Options.seed != 0:
input["seed"] = Options.seed
# Await the output from the replicate API
response = await replicate.predictions.async_create(
"5f24084160c9089501c1b3545d9be3c27883ae2239b6f41299... | input = {
"width": Options.selected_dimensions[0],
"height": Options.selected_dimensions[1],
"prompt": Options.prompt + Options.selected_style_prompt,
"negative_prompt": Options.negative_prompt,
"num_inference_steps": Options.steps,
... |
if not self._check_api_token():
return
if self.is_upscaling:
yield rx.toast.warning("Wait for the image to upscale first")
return
async with self:
Options = await self.get_state(OptionsState)
# If prompt is empty
... |
# Await the output from the replicate API
response = await replicate.predictions.async_create(
"5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f",
input=input,
)
if response.status != ResponseStatus.STARTING.value or not ... | if Options.seed != 0:
input["seed"] = Options.seed |
return
if self.is_upscaling:
yield rx.toast.warning("Wait for the image to upscale first")
return
async with self:
Options = await self.get_state(OptionsState)
# If prompt is empty
if Options.prompt == "":
... |
# Await the output from the replicate API
response = await replicate.predictions.async_create(
"5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f",
input=input,
)
if response.status != ResponseStatus.STARTING.value or not ... | input["seed"] = Options.seed |
for the image to upscale first")
return
async with self:
Options = await self.get_state(OptionsState)
# If prompt is empty
if Options.prompt == "":
yield rx.toast.warning("Please enter a prompt")
return
inpu... |
if response.status != ResponseStatus.STARTING.value or not response:
async with self:
self._reset_state()
yield rx.toast.error("Error starting generation")
return
async with self:
self.is_generating = True
... | response = await replicate.predictions.async_create(
"5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f",
input=input,
) |
f Options.prompt == "":
yield rx.toast.warning("Please enter a prompt")
return
input = {
"width": Options.selected_dimensions[0],
"height": Options.selected_dimensions[1],
"prompt": Options.prompt + Options.selected_style_prompt... |
async with self:
self.is_generating = True
self._request_id = response.id
yield
yield rx.scroll_to(elem_id="mobile-header")
while True:
response = await replicate.predictions.async_get(response.id)
async... | if response.status != ResponseStatus.STARTING.value or not response:
async with self:
self._reset_state()
yield rx.toast.error("Error starting generation")
return |
tions.prompt + Options.selected_style_prompt,
"negative_prompt": Options.negative_prompt,
"num_inference_steps": Options.steps,
"num_outputs": Options.num_outputs,
"scheduler": Options.scheduler,
"guidance_scale": Options.guidance_scale,
... |
self._request_id = response.id
yield
yield rx.scroll_to(elem_id="mobile-header")
while True:
response = await replicate.predictions.async_get(response.id)
async with self:
if response.status in (
... | self.is_generating = True |
pt,
"negative_prompt": Options.negative_prompt,
"num_inference_steps": Options.steps,
"num_outputs": Options.num_outputs,
"scheduler": Options.scheduler,
"guidance_scale": Options.guidance_scale,
}
# Add "seed" to th... |
yield
yield rx.scroll_to(elem_id="mobile-header")
while True:
response = await replicate.predictions.async_get(response.id)
async with self:
if response.status in (
ResponseStatus.CANCELED.value,
... | self._request_id = response.id |
"num_outputs": Options.num_outputs,
"scheduler": Options.scheduler,
"guidance_scale": Options.guidance_scale,
}
# Add "seed" to the input if it is not 0
if Options.seed != 0:
input["seed"] = Options.seed
# Awai... |
async with self:
self.upscaled_image = ""
self.output_image = response.output[0]
self.output_list = [] if len(response.output) == 1 else response.output
self._reset_state()
except Exception as e:
async with self:
... | while True:
response = await replicate.predictions.async_get(response.id)
async with self:
if response.status in (
ResponseStatus.CANCELED.value,
ResponseStatus.FAILED.value,
):
... |
Options.num_outputs,
"scheduler": Options.scheduler,
"guidance_scale": Options.guidance_scale,
}
# Add "seed" to the input if it is not 0
if Options.seed != 0:
input["seed"] = Options.seed
# Await the output from the replic... |
async with self:
if response.status in (
ResponseStatus.CANCELED.value,
ResponseStatus.FAILED.value,
):
self._reset_state()
if response.status == ResponseStatus.FAILED... | response = await replicate.predictions.async_get(response.id) |
ance_scale,
}
# Add "seed" to the input if it is not 0
if Options.seed != 0:
input["seed"] = Options.seed
# Await the output from the replicate API
response = await replicate.predictions.async_create(
"5f24084160c9089501c1b3545... |
await asyncio.sleep(0.15)
async with self:
self.upscaled_image = ""
self.output_image = response.output[0]
self.output_list = [] if len(response.output) == 1 else response.output
self._reset_state()
except Exception as... | if response.status in (
ResponseStatus.CANCELED.value,
ResponseStatus.FAILED.value,
):
self._reset_state()
if response.status == ResponseStatus.FAILED.value:
yield rx.toast.war... |
response = await replicate.predictions.async_create(
"5f24084160c9089501c1b3545d9be3c27883ae2239b6f412990e82d4a6210f8f",
input=input,
)
if response.status != ResponseStatus.STARTING.value or not response:
async with self:
sel... |
return
elif response.status == ResponseStatus.SUCCEEDED.value:
break
await asyncio.sleep(0.15)
async with self:
self.upscaled_image = ""
self.output_image = response.output[0]
... | if response.status == ResponseStatus.FAILED.value:
yield rx.toast.warning(
f"Error generating image: {response.error}"
) |
se:
async with self:
self._reset_state()
yield rx.toast.error("Error starting generation")
return
async with self:
self.is_generating = True
self._request_id = response.id
yield
yi... |
await asyncio.sleep(0.15)
async with self:
self.upscaled_image = ""
self.output_image = response.output[0]
self.output_list = [] if len(response.output) == 1 else response.output
self._reset_state()
except Exception as... | elif response.status == ResponseStatus.SUCCEEDED.value:
break |
async with self:
self.is_generating = True
self._request_id = response.id
yield
yield rx.scroll_to(elem_id="mobile-header")
while True:
response = await replicate.predictions.async_get(response.id)
async with se... |
self.output_image = response.output[0]
self.output_list = [] if len(response.output) == 1 else response.output
self._reset_state()
except Exception as e:
async with self:
self._reset_state()
yield rx.toast.error(f"Error, p... | self.upscaled_image = "" |
f.is_generating = True
self._request_id = response.id
yield
yield rx.scroll_to(elem_id="mobile-header")
while True:
response = await replicate.predictions.async_get(response.id)
async with self:
if response.statu... |
self.output_list = [] if len(response.output) == 1 else response.output
self._reset_state()
except Exception as e:
async with self:
self._reset_state()
yield rx.toast.error(f"Error, please try again: {e}")
@rx.event(background=True)
... | self.output_image = response.output[0] |
= response.id
yield
yield rx.scroll_to(elem_id="mobile-header")
while True:
response = await replicate.predictions.async_get(response.id)
async with self:
if response.status in (
ResponseStatus.CANCELED.... |
self._reset_state()
except Exception as e:
async with self:
self._reset_state()
yield rx.toast.error(f"Error, please try again: {e}")
@rx.event(background=True)
async def upscale_image(self):
try:
# Check if the env variable ... | self.output_list = [] if len(response.output) == 1 else response.output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.