@@ -30,15 +30,26 @@ class State(rx.State):
3030 # Whether we are processing the question.
3131 processing : bool = False
3232
33- # The name of the new chat.
34- new_chat_name : str = ""
33+ # Whether the new chat modal is open .
34+ is_modal_open : bool = False
3535
3636 @rx .event
37- def create_chat (self ):
37+ def create_chat (self , form_data : dict [ str , Any ] ):
3838 """Create a new chat."""
3939 # Add the new chat to the list of chats.
40- self .current_chat = self .new_chat_name
41- self ._chats [self .new_chat_name ] = []
40+ new_chat_name = form_data ["new_chat_name" ]
41+ self .current_chat = new_chat_name
42+ self ._chats [new_chat_name ] = []
43+ self .is_modal_open = False
44+
45+ @rx .event
46+ def set_is_modal_open (self , is_open : bool ):
47+ """Set the new chat modal open state.
48+
49+ Args:
50+ is_open: Whether the modal is open.
51+ """
52+ self .is_modal_open = is_open
4253
4354 @rx .var
4455 def selected_chat (self ) -> list [QA ]:
@@ -97,7 +108,7 @@ async def process_question(self, form_data: dict[str, Any]):
97108 question = form_data ["question" ]
98109
99110 # Check if the question is empty
100- if question == "" :
111+ if not question :
101112 return
102113
103114 async for value in self .openai_process_question (question ):
0 commit comments