@@ -553,27 +553,31 @@ def to_prompt_dict(self, include_data: bool = True) -> dict[str, Any]:
553553 # and not isinstance(getattr(models.WindowEvent, key), property)
554554 }
555555 )
556- if include_data :
557- key_suffixes = ["value" , "h" , "w" , "x" , "y" , "description" , "title" , "help" ]
558- if sys .platform == "win32" :
559- logger .warning (
560- "key_suffixes have not yet been defined on Windows."
561- "You can help by uncommenting the lines below and pasting "
562- "the contents of the window_dict into a new GitHub Issue."
563- )
564- # from pprint import pformat
565- # logger.info(f"window_dict=\n{pformat(window_dict)}")
566- # import ipdb; ipdb.set_trace()
567- window_state = window_dict ["state" ]
568- window_state ["data" ] = utils .clean_dict (
569- utils .filter_keys (
570- window_state ["data" ],
571- key_suffixes ,
572- )
573- )
574- else :
575- window_dict ["state" ].pop ("data" )
576- window_dict ["state" ].pop ("meta" )
556+ if "state" in window_dict :
557+ if include_data :
558+ key_suffixes = [
559+ "value" , "h" , "w" , "x" , "y" , "description" , "title" , "help" ,
560+ ]
561+ if sys .platform == "win32" :
562+ logger .warning (
563+ "key_suffixes have not yet been defined on Windows."
564+ "You can help by uncommenting the lines below and pasting "
565+ "the contents of the window_dict into a new GitHub Issue."
566+ )
567+ # from pprint import pformat
568+ # logger.info(f"window_dict=\n{pformat(window_dict)}")
569+ # import ipdb; ipdb.set_trace()
570+ if "state" in window_dict :
571+ window_state = window_dict ["state" ]
572+ window_state ["data" ] = utils .clean_dict (
573+ utils .filter_keys (
574+ window_state ["data" ],
575+ key_suffixes ,
576+ )
577+ )
578+ else :
579+ window_dict ["state" ].pop ("data" )
580+ window_dict ["state" ].pop ("meta" )
577581 return window_dict
578582
579583
0 commit comments