Skip to content

init

2024-09-19 -- Layer between Reflex frontend and backend services.

Code in this layer is responsible for validating inputs that come from the frontend layer and calling the backend services appropriately. It should also handle errors from the backend, converting them into something that the frontend can understand.

service_interface layer includes: - frontend logic - calling all backend services: - assistant_run - database crud (config, conversation, user, etc.) - basic validation of inputs - anything that can be validated before sending to backend - backend may carry out further validation (where access to database information is required for example) - coordination of backend services that make sense from a frontend perspective - I.e. frontend/reflex layer should only have to make one call (either direct to backend for simple reads) or through this layer for anything more complex. - Cancelling and re-running a request -- might involve a few backend service calls, but not justify whole new backend services

Responsibilities: - Validate inputs that come from frontend layer - Injecting dependencies - Call backend services - Handle errors from backend services - Propagate updates to the frontend/reflex layer

Should NOT be responsible for: - Any rendering logic (return/apply updates that are handled in the frontend layer) - State management - Note: Can rely on protocols that the frontend/reflex layer must implement - E.g. with run_context() as context: (where that reads/updates some state in the reflex layer)

For additional context, I think the Frontend/reflex layer includes: - all pages - layout - event handlers - components - shared states - NOT any significant logic

__all__ = ['delete_agent_config', 'delete_assistant_config', 'delete_options_config', 'handle_submit_event', 'load_agent_config', 'load_assistant_config', 'load_options_config', 're_vectorize_all_user_messages', 'save_agent_config', 'save_assistant_config', 'save_options_config'] module-attribute

delete_agent_config = partial(_delete_config_with_update, AgentDeletedUpdate) module-attribute

delete_assistant_config = partial(_delete_config_with_update, AssistantDeletedUpdate) module-attribute

delete_options_config = partial(_delete_config_with_update, OptionsDeletedUpdate) module-attribute

load_agent_config = partial(_load_config_with_update, AgentLoadedUpdate, AgentSchema) module-attribute

load_assistant_config = partial(_load_config_with_update, AssistantLoadedUpdate, AssistantSchema) module-attribute

load_options_config = partial(_load_config_with_update, OptionsLoadedUpdate, OptionsSchema) module-attribute

handle_submit_event(updatable, run_context_provider, user_info, assistant_id, conversation_id, user_input, dependencies=None) async

re_vectorize_all_user_messages(deps, updatable, user_id) async

save_agent_config(updatable, save_name, save_type, current_conf_id, modified_data, user_id, allow_create_overwrite, deps=None) async

save_assistant_config(updatable, save_name, save_type, current_conf_id, modified_data, user_id, allow_create_overwrite, deps=None) async

save_options_config(updatable, save_name, save_type, current_conf_id, modified_data, user_id, allow_create_overwrite, deps=None) async