instruction
stringlengths
0
1k
input
stringlengths
1
1k
output
stringlengths
10
6.51k
if self.search_value: search_value = f"%{str(self.search_value).lower()}%" query = query.where( or_( *[ getattr(Customer, field).ilike(search_value) for field in Customer.get_fields() ...
self.load_entries() def toggle_sort(self): self.sort_reverse = not self.sort_reverse self.load_entries() def filter_values(self, search_value): self.search_value = search_value self.load_entries() def get_user(self, user: Customer): self.current_user = use...
self.sort_value = sort_value
elf.search_value).lower()}%" query = query.where( or_( *[ getattr(Customer, field).ilike(search_value) for field in Customer.get_fields() ], ) )...
def filter_values(self, search_value): self.search_value = search_value self.load_entries() def get_user(self, user: Customer): self.current_user = user def add_customer_to_db(self, form_data: dict): self.current_user = Customer(**form_data) with rx.session() as ...
def toggle_sort(self): self.sort_reverse = not self.sort_reverse self.load_entries()
query = query.where( or_( *[ getattr(Customer, field).ilike(search_value) for field in Customer.get_fields() ], ) ) if self.sort_valu...
self.load_entries() def filter_values(self, search_value): self.search_value = search_value self.load_entries() def get_user(self, user: Customer): self.current_user = user def add_customer_to_db(self, form_data: dict): self.current_user = Customer(**form_data) ...
self.sort_reverse = not self.sort_reverse
*[ getattr(Customer, field).ilike(search_value) for field in Customer.get_fields() ], ) ) if self.sort_value: sort_column = getattr(Customer, self.sort_value) ...
def get_user(self, user: Customer): self.current_user = user def add_customer_to_db(self, form_data: dict): self.current_user = Customer(**form_data) with rx.session() as session: if session.exec( select(Customer).where(Customer.email == self.current_user....
def filter_values(self, search_value): self.search_value = search_value self.load_entries()
(Customer, field).ilike(search_value) for field in Customer.get_fields() ], ) ) if self.sort_value: sort_column = getattr(Customer, self.sort_value) if self.sort_value == "salary": ...
self.load_entries() def get_user(self, user: Customer): self.current_user = user def add_customer_to_db(self, form_data: dict): self.current_user = Customer(**form_data) with rx.session() as session: if session.exec( select(Customer).where(Customer...
self.search_value = search_value
for field in Customer.get_fields() ], ) ) if self.sort_value: sort_column = getattr(Customer, self.sort_value) if self.sort_value == "salary": order = desc(sort_column) if self.sort_reverse else ...
def add_customer_to_db(self, form_data: dict): self.current_user = Customer(**form_data) with rx.session() as session: if session.exec( select(Customer).where(Customer.email == self.current_user.email) ).first(): return rx.window_alert("User...
def get_user(self, user: Customer): self.current_user = user
], ) ) if self.sort_value: sort_column = getattr(Customer, self.sort_value) if self.sort_value == "salary": order = desc(sort_column) if self.sort_reverse else asc(sort_column) else: ...
def add_customer_to_db(self, form_data: dict): self.current_user = Customer(**form_data) with rx.session() as session: if session.exec( select(Customer).where(Customer.email == self.current_user.email) ).first(): return rx.window_alert("User...
self.current_user = user
) ) if self.sort_value: sort_column = getattr(Customer, self.sort_value) if self.sort_value == "salary": order = desc(sort_column) if self.sort_reverse else asc(sort_column) else: order = ( ...
def update_customer_to_db(self, form_data: dict): with rx.session() as session: customer = session.exec( select(Customer).where(Customer.id == self.current_user.id) ).first() customer.set(**form_data) session.commit() session.refr...
def add_customer_to_db(self, form_data: dict): self.current_user = Customer(**form_data) with rx.session() as session: if session.exec( select(Customer).where(Customer.email == self.current_user.email) ).first(): return rx.window_alert("User with ...
alue: sort_column = getattr(Customer, self.sort_value) if self.sort_value == "salary": order = desc(sort_column) if self.sort_reverse else asc(sort_column) else: order = ( desc(func.lower(sort_column)) ...
with rx.session() as session: if session.exec( select(Customer).where(Customer.email == self.current_user.email) ).first(): return rx.window_alert("User with this email already exists") session.add(self.current_user) session.commi...
self.current_user = Customer(**form_data)
f.sort_value == "salary": order = desc(sort_column) if self.sort_reverse else asc(sort_column) else: order = ( desc(func.lower(sort_column)) if self.sort_reverse else asc(func.lower(sort_colum...
session.add(self.current_user) session.commit() session.refresh(self.current_user) self.load_entries() return rx.toast.info( f"User {self.current_user.customer_name} has been added.", position="bottom-right", ) def update_customer...
if session.exec( select(Customer).where(Customer.email == self.current_user.email) ).first(): return rx.window_alert("User with this email already exists")
f.sort_value = sort_value self.load_entries() def toggle_sort(self): self.sort_reverse = not self.sort_reverse self.load_entries() def filter_values(self, search_value): self.search_value = search_value self.load_entries() def get_user(self, user: Customer): ...
def delete_customer(self, id: int): """Delete a customer from the database.""" with rx.session() as session: customer = session.exec(select(Customer).where(Customer.id == id)).first() session.delete(customer) session.commit() self.load_entries() ...
def update_customer_to_db(self, form_data: dict): with rx.session() as session: customer = session.exec( select(Customer).where(Customer.id == self.current_user.id) ).first() customer.set(**form_data) session.commit() session.refresh(cu...
reverse = not self.sort_reverse self.load_entries() def filter_values(self, search_value): self.search_value = search_value self.load_entries() def get_user(self, user: Customer): self.current_user = user def add_customer_to_db(self, form_data: dict): self.current_...
customer.set(**form_data) session.commit() session.refresh(customer) self.current_user = customer self.load_entries() return rx.toast.info( f"User {self.current_user.customer_name} has been modified.", position="bottom-right", ...
customer = session.exec( select(Customer).where(Customer.id == self.current_user.id) ).first()
= user def add_customer_to_db(self, form_data: dict): self.current_user = Customer(**form_data) with rx.session() as session: if session.exec( select(Customer).where(Customer.email == self.current_user.email) ).first(): return rx.window_alert...
self.load_entries() return rx.toast.info( f"User {self.current_user.customer_name} has been modified.", position="bottom-right", ) def delete_customer(self, id: int): """Delete a customer from the database.""" with rx.session() as session: ...
self.current_user = customer
re(Customer.email == self.current_user.email) ).first(): return rx.window_alert("User with this email already exists") session.add(self.current_user) session.commit() session.refresh(self.current_user) self.load_entries() return rx.toast.in...
@rx.event(background=True) async def call_openai(self): session = get_openai_client().chat.completions.create( user=self.router.session.client_token, stream=True, model="gpt-3.5-turbo", messages=[ { "role": "system", ...
def delete_customer(self, id: int): """Delete a customer from the database.""" with rx.session() as session: customer = session.exec(select(Customer).where(Customer.id == id)).first() session.delete(customer) session.commit() self.load_entries() return...
exists") session.add(self.current_user) session.commit() session.refresh(self.current_user) self.load_entries() return rx.toast.info( f"User {self.current_user.customer_name} has been added.", position="bottom-right", ) def update...
session.delete(customer) session.commit() self.load_entries() return rx.toast.info( f"User {customer.customer_name} has been deleted.", position="bottom-right" ) @rx.event(background=True) async def call_openai(self): session = get_openai_cli...
customer = session.exec(select(Customer).where(Customer.id == id)).first()
hat sells clothing. You have a list of products and customer data. Your task is to write a sales email to a customer recommending one of the products. The email should be personalized and include a recommendation based on the customer's data. The email should be {self.tone} and {self.length} characters long.", ...
async with self: self.gen_response = False def generate_email(self, user: Customer): self.current_user = user self.gen_response = True self.email_content_data = "" return State.call_openai
for item in session: if hasattr(item.choices[0].delta, "content"): response_text = item.choices[0].delta.content async with self: if response_text is not None: self.email_content_data += response_text yield
st of products and customer data. Your task is to write a sales email to a customer recommending one of the products. The email should be personalized and include a recommendation based on the customer's data. The email should be {self.tone} and {self.length} characters long.", }, { ...
async with self: self.gen_response = False def generate_email(self, user: Customer): self.current_user = user self.gen_response = True self.email_content_data = "" return State.call_openai
if hasattr(item.choices[0].delta, "content"): response_text = item.choices[0].delta.content async with self: if response_text is not None: self.email_content_data += response_text yield
s email to a customer recommending one of the products. The email should be personalized and include a recommendation based on the customer's data. The email should be {self.tone} and {self.length} characters long.", }, { "role": "user", "content":...
async with self: if response_text is not None: self.email_content_data += response_text yield async with self: self.gen_response = False def generate_email(self, user: Customer): self.current_user = user ...
response_text = item.choices[0].delta.content
e a recommendation based on the customer's data. The email should be {self.tone} and {self.length} characters long.", }, { "role": "user", "content": f"Based on these {products} write a sales email to {self.current_user.customer_name} and email {se...
yield async with self: self.gen_response = False def generate_email(self, user: Customer): self.current_user = user self.gen_response = True self.email_content_data = "" return State.call_openai
if response_text is not None: self.email_content_data += response_text
"role": "user", "content": f"Based on these {products} write a sales email to {self.current_user.customer_name} and email {self.current_user.email} who is {self.current_user.age} years old and a {self.current_user.gender} gender. {self.current_user.customer_name} lives in {self.c...
def generate_email(self, user: Customer): self.current_user = user self.gen_response = True self.email_content_data = "" return State.call_openai
self.gen_response = False
er", "content": f"Based on these {products} write a sales email to {self.current_user.customer_name} and email {self.current_user.email} who is {self.current_user.age} years old and a {self.current_user.gender} gender. {self.current_user.customer_name} lives in {self.current_user.location} and works...
def generate_email(self, user: Customer): self.current_user = user self.gen_response = True self.email_content_data = "" return State.call_openai
se {products} write a sales email to {self.current_user.customer_name} and email {self.current_user.email} who is {self.current_user.age} years old and a {self.current_user.gender} gender. {self.current_user.customer_name} lives in {self.current_user.location} and works as a {self.current_user.job} and earns {self.curr...
self.gen_response = True self.email_content_data = "" return State.call_openai
self.current_user = user
to {self.current_user.customer_name} and email {self.current_user.email} who is {self.current_user.age} years old and a {self.current_user.gender} gender. {self.current_user.customer_name} lives in {self.current_user.location} and works as a {self.current_user.job} and earns {self.current_user.salary} per year. Make s...
self.email_content_data = "" return State.call_openai
self.gen_response = True
ame} and email {self.current_user.email} who is {self.current_user.age} years old and a {self.current_user.gender} gender. {self.current_user.customer_name} lives in {self.current_user.location} and works as a {self.current_user.job} and earns {self.current_user.salary} per year. Make sure the email recommends one prod...
return State.call_openai
self.email_content_data = ""
class Customer(rx.Model, table=True): # type: ignore """The customer model.""" customer_name: str email: str age: int gender: str location: str job: str salary: int
import reflex as rx
def form_field( label: str, placeholder: str, type: str, name: str, icon: str, default_value: str = "", ) -> rx.Component: return rx.form.field( rx.flex( rx.hstack( rx.icon(icon, size=16, stroke_width=1.5), rx.form.label(label), ...
import reflex as rx
def _badge(text: str, color_scheme: str): return rx.badge( text, color_scheme=color_scheme, radius="full", variant="soft", size="3" ) def gender_badge(gender: str): badge_mapping = { "Male": ("♂️ Male", "blue"), "Female": ("♀️ Female", "pink"), "Other": ("Other", "gray")...
import reflex as rx
from ..backend.backend import State def email_box(): return rx.box( rx.scroll_area( rx.icon_button( rx.icon("copy"), variant="soft", color_scheme="gray", size="2", on_click=[ rx.set_clipboard(...
import reflex as rx
import reflex as rx
def email_box(): return rx.box( rx.scroll_area( rx.icon_button( rx.icon("copy"), variant="soft", color_scheme="gray", size="2", on_click=[ rx.set_clipboard(State.email_content_data), ...
from ..backend.backend import State
def navbar(): return rx.flex( rx.badge( rx.icon(tag="mails", size=28), rx.heading("Personalized Sales", size="6"), radius="large", align="center", color_scheme="blue", variant="surface", padding="0.65rem", ), ...
import reflex as rx
from ..backend.backend import Customer, State from ..components.form_field import form_field from ..components.gender_badges import gender_badge def _header_cell(text: str, icon: str): return rx.table.column_header_cell( rx.hstack( rx.icon(icon, size=18), rx.text(text), ...
import reflex as rx
import reflex as rx
from ..components.form_field import form_field from ..components.gender_badges import gender_badge def _header_cell(text: str, icon: str): return rx.table.column_header_cell( rx.hstack( rx.icon(icon, size=18), rx.text(text), align="center", spacing="2", ...
from ..backend.backend import Customer, State
import reflex as rx from ..backend.backend import Customer, State
from ..components.gender_badges import gender_badge def _header_cell(text: str, icon: str): return rx.table.column_header_cell( rx.hstack( rx.icon(icon, size=18), rx.text(text), align="center", spacing="2", ), ) def _show_customer(user: Custom...
from ..components.form_field import form_field
import reflex as rx from ..backend.backend import Customer, State from ..components.form_field import form_field
def _header_cell(text: str, icon: str): return rx.table.column_header_cell( rx.hstack( rx.icon(icon, size=18), rx.text(text), align="center", spacing="2", ), ) def _show_customer(user: Customer): """Show a customer in a table row.""" r...
from ..components.gender_badges import gender_badge
import reflex as rx from ..backend.backend import Customer, State from ..components.form_field import form_field from ..components.gender_badges import gender_badge
def _show_customer(user: Customer): """Show a customer in a table row.""" return rx.table.row( rx.table.row_header_cell(user.customer_name), rx.table.cell(user.email), rx.table.cell(user.age), rx.table.cell( rx.match( user.gender, ("...
def _header_cell(text: str, icon: str): return rx.table.column_header_cell( rx.hstack( rx.icon(icon, size=18), rx.text(text), align="center", spacing="2", ), )
from space_dashboard.components.alert_indicator import alert_indicator from space_dashboard.components.control_buttons import control_buttons from space_dashboard.components.data_stream import data_stream_section from space_dashboard.components.environment import environment_section from space_dashboard.components.he...
import reflex as rx
import reflex as rx
from space_dashboard.components.control_buttons import control_buttons from space_dashboard.components.data_stream import data_stream_section from space_dashboard.components.environment import environment_section from space_dashboard.components.header import header from space_dashboard.components.hq_coms import hq_com...
from space_dashboard.components.alert_indicator import alert_indicator
import reflex as rx from space_dashboard.components.alert_indicator import alert_indicator
from space_dashboard.components.data_stream import data_stream_section from space_dashboard.components.environment import environment_section from space_dashboard.components.header import header from space_dashboard.components.hq_coms import hq_coms_section from space_dashboard.components.planets import planets_sectio...
from space_dashboard.components.control_buttons import control_buttons
import reflex as rx from space_dashboard.components.alert_indicator import alert_indicator from space_dashboard.components.control_buttons import control_buttons
from space_dashboard.components.environment import environment_section from space_dashboard.components.header import header from space_dashboard.components.hq_coms import hq_coms_section from space_dashboard.components.planets import planets_section from space_dashboard.components.pos_tracking import pos_tracking_sect...
from space_dashboard.components.data_stream import data_stream_section
import reflex as rx from space_dashboard.components.alert_indicator import alert_indicator from space_dashboard.components.control_buttons import control_buttons from space_dashboard.components.data_stream import data_stream_section
from space_dashboard.components.header import header from space_dashboard.components.hq_coms import hq_coms_section from space_dashboard.components.planets import planets_section from space_dashboard.components.pos_tracking import pos_tracking_section from space_dashboard.components.speed_display import speed_display ...
from space_dashboard.components.environment import environment_section
import reflex as rx from space_dashboard.components.alert_indicator import alert_indicator from space_dashboard.components.control_buttons import control_buttons from space_dashboard.components.data_stream import data_stream_section from space_dashboard.components.environment import environment_section
from space_dashboard.components.hq_coms import hq_coms_section from space_dashboard.components.planets import planets_section from space_dashboard.components.pos_tracking import pos_tracking_section from space_dashboard.components.speed_display import speed_display def index() -> rx.Component: """The main dashbo...
from space_dashboard.components.header import header
import reflex as rx from space_dashboard.components.alert_indicator import alert_indicator from space_dashboard.components.control_buttons import control_buttons from space_dashboard.components.data_stream import data_stream_section from space_dashboard.components.environment import environment_section from space_dash...
from space_dashboard.components.planets import planets_section from space_dashboard.components.pos_tracking import pos_tracking_section from space_dashboard.components.speed_display import speed_display def index() -> rx.Component: """The main dashboard page.""" return rx.el.div( header(), rx...
from space_dashboard.components.hq_coms import hq_coms_section
import reflex as rx from space_dashboard.components.alert_indicator import alert_indicator from space_dashboard.components.control_buttons import control_buttons from space_dashboard.components.data_stream import data_stream_section from space_dashboard.components.environment import environment_section from space_dash...
from space_dashboard.components.pos_tracking import pos_tracking_section from space_dashboard.components.speed_display import speed_display def index() -> rx.Component: """The main dashboard page.""" return rx.el.div( header(), rx.el.main( rx.el.div( rx.el.div( ...
from space_dashboard.components.planets import planets_section
import reflex as rx from space_dashboard.components.alert_indicator import alert_indicator from space_dashboard.components.control_buttons import control_buttons from space_dashboard.components.data_stream import data_stream_section from space_dashboard.components.environment import environment_section from space_dash...
from space_dashboard.components.speed_display import speed_display def index() -> rx.Component: """The main dashboard page.""" return rx.el.div( header(), rx.el.main( rx.el.div( rx.el.div( environment_section(), planets_secti...
from space_dashboard.components.pos_tracking import pos_tracking_section
import reflex as rx from space_dashboard.components.alert_indicator import alert_indicator from space_dashboard.components.control_buttons import control_buttons from space_dashboard.components.data_stream import data_stream_section from space_dashboard.components.environment import environment_section from space_dash...
def index() -> rx.Component: """The main dashboard page.""" return rx.el.div( header(), rx.el.main( rx.el.div( rx.el.div( environment_section(), planets_section(), class_name="flex flex-col gap-6", ...
from space_dashboard.components.speed_display import speed_display
planets_section(), class_name="flex flex-col gap-6", ), rx.el.div( rx.el.div( speed_display(), alert_indicator(), control_buttons(), class_name="f...
app.add_page(index)
app = rx.App(theme=rx.theme(appearance="light"))
from space_dashboard.states.dashboard_state import DashboardState def alert_indicator() -> rx.Component: """A flashing red alert indicator.""" return rx.el.div( rx.el.div( DashboardState.alert_value.to_string(), class_name="text-white text-xs font-bold", ), cl...
import reflex as rx
from space_dashboard.states.dashboard_state import DashboardState def control_buttons() -> rx.Component: """The bottom center control buttons.""" return rx.el.div( rx.foreach( DashboardState.control_buttons, lambda button_text: rx.el.button( button_text, ...
import reflex as rx
import reflex as rx
def control_buttons() -> rx.Component: """The bottom center control buttons.""" return rx.el.div( rx.foreach( DashboardState.control_buttons, lambda button_text: rx.el.button( button_text, class_name="flex-1 bg-gradient-to-br from-blue-900/50 to...
from space_dashboard.states.dashboard_state import DashboardState
from space_dashboard.components.section_wrapper import section_wrapper from space_dashboard.states.dashboard_state import ( DashboardState, StreamData, ) def data_stream_item(data: StreamData) -> rx.Component: """Displays a single data stream item.""" return rx.el.div( rx.el.p( d...
import reflex as rx
import reflex as rx
from space_dashboard.states.dashboard_state import ( DashboardState, StreamData, ) def data_stream_item(data: StreamData) -> rx.Component: """Displays a single data stream item.""" return rx.el.div( rx.el.p( data["label"], class_name="text-sm text-cyan-400 uppercase fo...
from space_dashboard.components.section_wrapper import section_wrapper
import reflex as rx from space_dashboard.components.section_wrapper import section_wrapper
def data_stream_item(data: StreamData) -> rx.Component: """Displays a single data stream item.""" return rx.el.div( rx.el.p( data["label"], class_name="text-sm text-cyan-400 uppercase font-semibold", ), rx.el.p( data["value"].to_string(), ...
from space_dashboard.states.dashboard_state import ( DashboardState, StreamData, )
from space_dashboard.components.section_wrapper import section_wrapper from space_dashboard.states.dashboard_state import ( DashboardState, EnvData, ) def environment_item(data: EnvData) -> rx.Component: """Displays a single environment metric.""" return rx.el.div( rx.el.div( rx....
import reflex as rx
import reflex as rx
from space_dashboard.states.dashboard_state import ( DashboardState, EnvData, ) def environment_item(data: EnvData) -> rx.Component: """Displays a single environment metric.""" return rx.el.div( rx.el.div( rx.el.div( rx.el.span( data["unit"], ...
from space_dashboard.components.section_wrapper import section_wrapper
import reflex as rx from space_dashboard.components.section_wrapper import section_wrapper
def environment_item(data: EnvData) -> rx.Component: """Displays a single environment metric.""" return rx.el.div( rx.el.div( rx.el.div( rx.el.span( data["unit"], class_name="text-xs text-cyan-400 font-bold", ), ...
from space_dashboard.states.dashboard_state import ( DashboardState, EnvData, )
from space_dashboard.states.dashboard_state import DashboardState def header() -> rx.Component: """The dashboard header.""" return rx.el.header( rx.el.div( rx.el.span("// ", class_name="text-cyan-600"), rx.el.span( "ARES_DASHBOARD", class_name=...
import reflex as rx
import reflex as rx
def header() -> rx.Component: """The dashboard header.""" return rx.el.header( rx.el.div( rx.el.span("// ", class_name="text-cyan-600"), rx.el.span( "ARES_DASHBOARD", class_name="text-white font-semibold tracking-wider", ), ...
from space_dashboard.states.dashboard_state import DashboardState
import reflex as rx
from space_dashboard.states.dashboard_state import ( ComData, DashboardState, ) def hq_com_item(data: ComData) -> rx.Component: """Displays a single HQ Coms channel.""" return rx.el.div( rx.el.p( f"{data['channel']} [{data['value'].to_string()}]", class_name="text-sm t...
from space_dashboard.components.section_wrapper import section_wrapper
from space_dashboard.components.section_wrapper import section_wrapper from space_dashboard.states.dashboard_state import ( DashboardState, PlanetData, ) def planet_item(data: PlanetData) -> rx.Component: """Displays a single planet distance.""" return rx.el.div( rx.el.div( rx.el...
import reflex as rx
import reflex as rx
from space_dashboard.states.dashboard_state import ( DashboardState, PlanetData, ) def planet_item(data: PlanetData) -> rx.Component: """Displays a single planet distance.""" return rx.el.div( rx.el.div( rx.el.div( class_name=f"w-8 h-8 rounded-full {data['color']} ...
from space_dashboard.components.section_wrapper import section_wrapper
import reflex as rx from space_dashboard.components.section_wrapper import section_wrapper
def planet_item(data: PlanetData) -> rx.Component: """Displays a single planet distance.""" return rx.el.div( rx.el.div( rx.el.div( class_name=f"w-8 h-8 rounded-full {data['color']} mr-4 border-2 border-white/50" ), class_name="flex-shrink-0", ...
from space_dashboard.states.dashboard_state import ( DashboardState, PlanetData, )
from space_dashboard.components.section_wrapper import section_wrapper from space_dashboard.states.dashboard_state import ( DashboardState, PosData, ) def pos_tracking_item(data: PosData) -> rx.Component: """Displays a single position tracking metric with a progress bar.""" return rx.el.div( ...
import reflex as rx
import reflex as rx
from space_dashboard.states.dashboard_state import ( DashboardState, PosData, ) def pos_tracking_item(data: PosData) -> rx.Component: """Displays a single position tracking metric with a progress bar.""" return rx.el.div( rx.el.div( rx.el.span( f"{data['label']}:",...
from space_dashboard.components.section_wrapper import section_wrapper
import reflex as rx from space_dashboard.components.section_wrapper import section_wrapper
def pos_tracking_item(data: PosData) -> rx.Component: """Displays a single position tracking metric with a progress bar.""" return rx.el.div( rx.el.div( rx.el.span( f"{data['label']}:", class_name="text-sm text-cyan-400 mr-2 font-semibold", ), ...
from space_dashboard.states.dashboard_state import ( DashboardState, PosData, )
def section_wrapper(title: str, *children, **props) -> rx.Component: """A styled container for dashboard sections.""" return rx.el.div( rx.el.h2( title, class_name="text-xs uppercase text-cyan-500 tracking-wider font-semibold mb-3", ), rx.el.div(*children), ...
import reflex as rx
from space_dashboard.states.dashboard_state import DashboardState def speed_display() -> rx.Component: """The central speed display.""" return rx.el.div( rx.el.div( rx.el.div( rx.el.div( rx.el.p( DashboardState.current_speed.to_...
import reflex as rx
import reflex as rx
def speed_display() -> rx.Component: """The central speed display.""" return rx.el.div( rx.el.div( rx.el.div( rx.el.div( rx.el.p( DashboardState.current_speed.to_string(), class_name="text-6xl text-white f...
from space_dashboard.states.dashboard_state import DashboardState
import reflex as rx class EnvData(TypedDict): label: str value: str unit: str icon: str class PlanetData(TypedDict): name: str distance: str color: str class ComData(TypedDict): channel: str value: int class PosData(TypedDict): label: str value: int class StreamDa...
from typing import List, TypedDict
from typing import List, TypedDict
class EnvData(TypedDict): label: str value: str unit: str icon: str class PlanetData(TypedDict): name: str distance: str color: str class ComData(TypedDict): channel: str value: int class PosData(TypedDict): label: str value: int class StreamData(TypedDict): la...
import reflex as rx
from typing import List, TypedDict import reflex as rx
class PlanetData(TypedDict): name: str distance: str color: str class ComData(TypedDict): channel: str value: int class PosData(TypedDict): label: str value: int class StreamData(TypedDict): label: str value: int class DashboardState(rx.State): """Holds the state for t...
class EnvData(TypedDict): label: str value: str unit: str icon: str
from typing import List, TypedDict import reflex as rx class EnvData(TypedDict): label: str value: str unit: str icon: str
class ComData(TypedDict): channel: str value: int class PosData(TypedDict): label: str value: int class StreamData(TypedDict): label: str value: int class DashboardState(rx.State): """Holds the state for the Ares Dashboard.""" environment_data: List[EnvData] = [ { ...
class PlanetData(TypedDict): name: str distance: str color: str
from typing import List, TypedDict import reflex as rx class EnvData(TypedDict): label: str value: str unit: str icon: str class PlanetData(TypedDict): name: str distance: str color: str
class PosData(TypedDict): label: str value: int class StreamData(TypedDict): label: str value: int class DashboardState(rx.State): """Holds the state for the Ares Dashboard.""" environment_data: List[EnvData] = [ { "label": "PRESSURE", "value": "15.65", ...
class ComData(TypedDict): channel: str value: int
from typing import List, TypedDict import reflex as rx class EnvData(TypedDict): label: str value: str unit: str icon: str class PlanetData(TypedDict): name: str distance: str color: str class ComData(TypedDict): channel: str value: int
class StreamData(TypedDict): label: str value: int class DashboardState(rx.State): """Holds the state for the Ares Dashboard.""" environment_data: List[EnvData] = [ { "label": "PRESSURE", "value": "15.65", "unit": "PSI", "icon": "gauge", ...
class PosData(TypedDict): label: str value: int
from typing import List, TypedDict import reflex as rx class EnvData(TypedDict): label: str value: str unit: str icon: str class PlanetData(TypedDict): name: str distance: str color: str class ComData(TypedDict): channel: str value: int class PosData(TypedDict): label: s...
class DashboardState(rx.State): """Holds the state for the Ares Dashboard.""" environment_data: List[EnvData] = [ { "label": "PRESSURE", "value": "15.65", "unit": "PSI", "icon": "gauge", }, { "label": "OXYGEN", "...
class StreamData(TypedDict): label: str value: int
from stock_graph_app.components.stock_chart_display import ( stock_graph_page, ) def index() -> rx.Component: return rx.el.div( stock_graph_page(), class_name="min-h-screen bg-[#202123] flex items-center justify-center p-4 font-['Inter']", ) app = rx.App( theme=rx.theme(appearance=...
import reflex as rx
from stock_graph_app.states.stock_state import StockState TOOLTIP_PROPS = { "content_style": { "background": "#2d2e30", "borderColor": "#2d2e3065", "borderRadius": "0.75rem", "boxShadow": "0px 24px 12px 0px light-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0.00)), 0px 8px 8px 0px l...
import reflex as rx
import reflex as rx
TOOLTIP_PROPS = { "content_style": { "background": "#2d2e30", "borderColor": "#2d2e3065", "borderRadius": "0.75rem", "boxShadow": "0px 24px 12px 0px light-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0.00)), 0px 8px 8px 0px light-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0.00)), 0px...
from stock_graph_app.states.stock_state import StockState
import reflex as rx from stock_graph_app.states.stock_state import StockState
def live_indicator_dot() -> rx.Component: """Creates a pulsing green dot to indicate live market activity.""" return rx.el.span( rx.el.span( class_name="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75" ), rx.el.span(class_name="relative...
TOOLTIP_PROPS = { "content_style": { "background": "#2d2e30", "borderColor": "#2d2e3065", "borderRadius": "0.75rem", "boxShadow": "0px 24px 12px 0px light-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0.00)), 0px 8px 8px 0px light-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0.00)), 0px 2...
import reflex as rx from stock_graph_app.states.stock_state import StockState TOOLTIP_PROPS = { "content_style": { "background": "#2d2e30", "borderColor": "#2d2e3065", "borderRadius": "0.75rem", "boxShadow": "0px 24px 12px 0px light-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0.00))...
def search_bar_component() -> rx.Component: return rx.el.form( rx.el.input( name="ticker_input", placeholder="Enter Ticker (e.g., AAPL, MSFT)", class_name="bg-[#2d2e30] text-white placeholder-neutral-400 border border-neutral-600 rounded-lg p-2 text-sm w-full sm:flex-g...
def live_indicator_dot() -> rx.Component: """Creates a pulsing green dot to indicate live market activity.""" return rx.el.span( rx.el.span( class_name="animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75" ), rx.el.span(class_name="relative in...
t-dark(rgba(28, 32, 36, 0.02), rgba(0, 0, 0, 0.00))", "fontFamily": "sans-serif", "fontSize": "0.875rem", "lineHeight": "1.25rem", "fontWeight": "500", "minWidth": "8rem", "padding": "0.375rem 0.625rem", "position": "relative", }, "item_style": { "...
def stock_header_component() -> rx.Component: return rx.el.div( rx.el.div( rx.el.div( rx.el.h1( StockState.stock_ticker, class_name="text-2xl sm:text-3xl md:text-4xl font-bold tracking-tight text-white", ), ...
def search_bar_component() -> rx.Component: return rx.el.form( rx.el.input( name="ticker_input", placeholder="Enter Ticker (e.g., AAPL, MSFT)", class_name="bg-[#2d2e30] text-white placeholder-neutral-400 border border-neutral-600 rounded-lg p-2 text-sm w-full sm:flex-grow...
ction, rx.el.div( rx.el.p( StockState.after_hours_price_display_val, " ", rx.el.span( StockState.after_hours_change_display_val, class_name="text-neutral-500 font-semibold", ...
def chart_component() -> rx.Component: gradient_id = "stockPriceGradient" return rx.el.div( rx.el.svg( rx.el.defs( rx.el.svg.linear_gradient( rx.el.svg.stop( offset="5%", stop_color="#22C55E", ...
def time_range_selector_component() -> rx.Component: return rx.el.div( rx.foreach( StockState.time_ranges, lambda time_range: rx.el.button( time_range, on_click=lambda: StockState.set_time_range(time_range), class_name=rx.cond( ...
urn rx.el.div( rx.foreach( StockState.time_ranges, lambda time_range: rx.el.button( time_range, on_click=lambda: StockState.set_time_range(time_range), class_name=rx.cond( StockState.selected_time_range == time_range, ...
return rx.el.div( rx.el.svg( rx.el.defs( rx.el.svg.linear_gradient( rx.el.svg.stop( offset="5%", stop_color="#22C55E", stop_opacity=0.4, ), rx.el.s...
gradient_id = "stockPriceGradient"
ht": 0, "left": 0, "bottom": 5, }, class_name="w-full [&_.recharts-tooltip-item-unit]:text-neutral-100 [&_.recharts-tooltip-item-unit]:font-mono [&_.recharts-tooltip-item-value]:!text-neutral-100 [&_.recharts-tooltip-item-value]:!font-mono [&_.recharts-tooltip-ite...
def error_message_component() -> rx.Component: return rx.el.div( StockState.error_message, class_name="text-red-400 text-sm my-4 p-3 bg-red-900/40 border border-red-700/50 rounded-lg flex items-center shadow", ) def no_data_component() -> rx.Component: return rx.el.div( "No data...
def loading_spinner_component() -> rx.Component: return rx.el.div( rx.spinner(class_name="text-green-500 w-12 h-12"), class_name="w-full h-[300px] flex justify-center items-center", )
rts-tooltip-item-value]:!text-neutral-100 [&_.recharts-tooltip-item-value]:!font-mono [&_.recharts-tooltip-item-value]:mr-[0.2rem] [&_.recharts-tooltip-item]:flex [&_.recharts-tooltip-item]:items-center [&_.recharts-tooltip-item]:before:content-[''] [&_.recharts-tooltip-item]:before:size-2.5 [&_.recharts-tooltip-item]:...
def no_data_component() -> rx.Component: return rx.el.div( "No data to display. Please search for a stock ticker above or select a different time range.", class_name="w-full h-[300px] flex flex-col justify-center items-center text-neutral-500 text-center p-4", ) def stock_graph_page() -> rx...
def error_message_component() -> rx.Component: return rx.el.div( StockState.error_message, class_name="text-red-400 text-sm my-4 p-3 bg-red-900/40 border border-red-700/50 rounded-lg flex items-center shadow", )
ontent-[''] [&_.recharts-tooltip-item]:before:size-2.5 [&_.recharts-tooltip-item]:before:rounded-[2px] [&_.recharts-tooltip-item]:before:shrink-0 [&_.recharts-tooltip-item]:before:!bg-[currentColor] [&_.recharts-tooltip-item-name]:text-neutral-300 [&_.recharts-tooltip-item-list]:flex [&_.recharts-tooltip-item-list]:fle...
def stock_graph_page() -> rx.Component: return rx.el.div( search_bar_component(), rx.cond(StockState.error_message, error_message_component(), rx.el.div()), rx.cond( StockState.is_loading, loading_spinner_component(), rx.cond( StockState...
def no_data_component() -> rx.Component: return rx.el.div( "No data to display. Please search for a stock ticker above or select a different time range.", class_name="w-full h-[300px] flex flex-col justify-center items-center text-neutral-500 text-center p-4", )
recharts-tooltip-item-list]:flex-col [&_.recharts-tooltip-item-name]:pr-[3rem] [&_.recharts-tooltip-item-name]:pl-1.5 [&_.recharts-tooltip-item-separator]:w-full [&_.recharts-tooltip-wrapper]:z-[1]", ), class_name="w-full h-[350px] mt-4", ) def loading_spinner_component() -> rx.Component: retu...
def stock_graph_page() -> rx.Component: return rx.el.div( search_bar_component(), rx.cond(StockState.error_message, error_message_component(), rx.el.div()), rx.cond( StockState.is_loading, loading_spinner_component(), rx.cond( StockState.ha...
import reflex as rx import yfinance as yf class HistoricalDataPoint(TypedDict): name: str price: float def format_market_cap(cap): if cap is None: return "N/A" if cap >= 1_000_000_000_000: return f"{cap / 1_000_000_000_000:.2f}T" if cap >= 1_000_000_000: return f"{cap /...
from typing import List, TypedDict
from typing import List, TypedDict
import yfinance as yf class HistoricalDataPoint(TypedDict): name: str price: float def format_market_cap(cap): if cap is None: return "N/A" if cap >= 1_000_000_000_000: return f"{cap / 1_000_000_000_000:.2f}T" if cap >= 1_000_000_000: return f"{cap / 1_000_000_000:.2f}B"...
import reflex as rx
from typing import List, TypedDict import reflex as rx
class HistoricalDataPoint(TypedDict): name: str price: float def format_market_cap(cap): if cap is None: return "N/A" if cap >= 1_000_000_000_000: return f"{cap / 1_000_000_000_000:.2f}T" if cap >= 1_000_000_000: return f"{cap / 1_000_000_000:.2f}B" if cap >= 1_000_0...
import yfinance as yf
from typing import List, TypedDict import reflex as rx import yfinance as yf
def format_market_cap(cap): if cap is None: return "N/A" if cap >= 1_000_000_000_000: return f"{cap / 1_000_000_000_000:.2f}T" if cap >= 1_000_000_000: return f"{cap / 1_000_000_000:.2f}B" if cap >= 1_000_000: return f"{cap / 1_000_000:.2f}M" return str(cap) clas...
class HistoricalDataPoint(TypedDict): name: str price: float
from typing import List, TypedDict import reflex as rx import yfinance as yf class HistoricalDataPoint(TypedDict): name: str price: float
class StockState(rx.State): """A state to fetch and display stock data.""" search_ticker_input: str = "AAPL" company_info: dict = {} historical_data: List[HistoricalDataPoint] = [] is_loading: bool = False error_message: str = "" selected_time_range: str = "1Y" time_ranges: list[st...
def format_market_cap(cap): if cap is None: return "N/A" if cap >= 1_000_000_000_000: return f"{cap / 1_000_000_000_000:.2f}T" if cap >= 1_000_000_000: return f"{cap / 1_000_000_000:.2f}B" if cap >= 1_000_000: return f"{cap / 1_000_000:.2f}M" return str(cap)
from typing import List, TypedDict import reflex as rx import yfinance as yf class HistoricalDataPoint(TypedDict): name: str price: float def format_market_cap(cap):
if cap >= 1_000_000_000_000: return f"{cap / 1_000_000_000_000:.2f}T" if cap >= 1_000_000_000: return f"{cap / 1_000_000_000:.2f}B" if cap >= 1_000_000: return f"{cap / 1_000_000:.2f}M" return str(cap) class StockState(rx.State): """A state to fetch and display stock data....
if cap is None: return "N/A"
from typing import List, TypedDict import reflex as rx import yfinance as yf class HistoricalDataPoint(TypedDict): name: str price: float def format_market_cap(cap): if cap is None: return "N/A"
if cap >= 1_000_000_000: return f"{cap / 1_000_000_000:.2f}B" if cap >= 1_000_000: return f"{cap / 1_000_000:.2f}M" return str(cap) class StockState(rx.State): """A state to fetch and display stock data.""" search_ticker_input: str = "AAPL" company_info: dict = {} histori...
if cap >= 1_000_000_000_000: return f"{cap / 1_000_000_000_000:.2f}T"
from typing import List, TypedDict import reflex as rx import yfinance as yf class HistoricalDataPoint(TypedDict): name: str price: float def format_market_cap(cap): if cap is None: return "N/A" if cap >= 1_000_000_000_000: return f"{cap / 1_000_000_000_000:.2f}T"
if cap >= 1_000_000: return f"{cap / 1_000_000:.2f}M" return str(cap) class StockState(rx.State): """A state to fetch and display stock data.""" search_ticker_input: str = "AAPL" company_info: dict = {} historical_data: List[HistoricalDataPoint] = [] is_loading: bool = False ...
if cap >= 1_000_000_000: return f"{cap / 1_000_000_000:.2f}B"
from typing import List, TypedDict import reflex as rx import yfinance as yf class HistoricalDataPoint(TypedDict): name: str price: float def format_market_cap(cap): if cap is None: return "N/A" if cap >= 1_000_000_000_000: return f"{cap / 1_000_000_000_000:.2f}T" if cap >= 1_00...
return str(cap) class StockState(rx.State): """A state to fetch and display stock data.""" search_ticker_input: str = "AAPL" company_info: dict = {} historical_data: List[HistoricalDataPoint] = [] is_loading: bool = False error_message: str = "" selected_time_range: str = "1Y" ...
if cap >= 1_000_000: return f"{cap / 1_000_000:.2f}M"
from typing import List, TypedDict import reflex as rx import yfinance as yf class HistoricalDataPoint(TypedDict): name: str price: float def format_market_cap(cap): if cap is None: return "N/A" if cap >= 1_000_000_000_000: return f"{cap / 1_000_000_000_000:.2f}T" if cap >= 1_00...
_DEFAULT_PERIOD_INTERVAL = {"period": "1y", "interval": "1d"} @rx.event async def on_load_fetch(self): """Fetch initial data when the page loads.""" if not self.company_info: await self.fetch_stock_data() def _determine_period_interval(self, time_range: str) -> dict: ...
_PERIOD_INTERVAL_MAP = { "1D": {"period": "1d", "interval": "5m"}, "5D": {"period": "5d", "interval": "30m"}, "1M": {"period": "1mo", "interval": "1d"}, "6M": {"period": "6mo", "interval": "1d"}, "1Y": {"period": "1y", "interval": "1d"}, "5Y": {"period": "5y", "interval":...
cap >= 1_000_000_000_000: return f"{cap / 1_000_000_000_000:.2f}T" if cap >= 1_000_000_000: return f"{cap / 1_000_000_000:.2f}B" if cap >= 1_000_000: return f"{cap / 1_000_000:.2f}M" return str(cap) class StockState(rx.State): """A state to fetch and display stock data.""" ...
@rx.event async def on_load_fetch(self): """Fetch initial data when the page loads.""" if not self.company_info: await self.fetch_stock_data() def _determine_period_interval(self, time_range: str) -> dict: """Determines yfinance period and interval from UI time_range."...
_DEFAULT_PERIOD_INTERVAL = {"period": "1y", "interval": "1d"}
return f"{cap / 1_000_000:.2f}M" return str(cap) class StockState(rx.State): """A state to fetch and display stock data.""" search_ticker_input: str = "AAPL" company_info: dict = {} historical_data: List[HistoricalDataPoint] = [] is_loading: bool = False error_message: str = "" ...
def _determine_period_interval(self, time_range: str) -> dict: """Determines yfinance period and interval from UI time_range.""" return self._PERIOD_INTERVAL_MAP.get(time_range, self._DEFAULT_PERIOD_INTERVAL) async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str): """...
if not self.company_info: await self.fetch_stock_data()
kState(rx.State): """A state to fetch and display stock data.""" search_ticker_input: str = "AAPL" company_info: dict = {} historical_data: List[HistoricalDataPoint] = [] is_loading: bool = False error_message: str = "" selected_time_range: str = "1Y" time_ranges: list[str] = ["1D", "...
async def _internal_fetch_stock_data(self, ticker_symbol_to_fetch: str): """Internal logic to fetch company data and historical prices.""" self.is_loading = True self.error_message = "" if not ticker_symbol_to_fetch: self.error_message = "Ticker symbol cannot be empty....
def _determine_period_interval(self, time_range: str) -> dict: """Determines yfinance period and interval from UI time_range.""" return self._PERIOD_INTERVAL_MAP.get(time_range, self._DEFAULT_PERIOD_INTERVAL)
"1D": {"period": "1d", "interval": "5m"}, "5D": {"period": "5d", "interval": "30m"}, "1M": {"period": "1mo", "interval": "1d"}, "6M": {"period": "6mo", "interval": "1d"}, "1Y": {"period": "1y", "interval": "1d"}, "5Y": {"period": "5y", "interval": "1wk"}, "MAX": ...
self.error_message = "" if not ticker_symbol_to_fetch: self.error_message = "Ticker symbol cannot be empty." self.is_loading = False return try: ticker = yf.Ticker(ticker_symbol_to_fetch) if ( not self.company_info ...
self.is_loading = True