@@ -288,6 +288,8 @@ def convert_to_tuples_format(history):
288288 else :
289289 # Assistant message without preceding user message
290290 tuples .append ([None , content ])
291+ elif isinstance (item , str ):
292+ tuples .append ([None , item ])
291293 i += 1
292294 return tuples
293295
@@ -1122,73 +1124,6 @@ async def collect_events():
11221124
11231125def create_interface ():
11241126 """Create Gradio interface"""
1125- # Workaround for Gradio schema parsing bug with additionalProperties
1126- # This error occurs when Gradio tries to generate API info from function signatures
1127- # We'll patch the get_api_info method to handle errors gracefully and prevent blocking
1128- original_blocks_init = gr .Blocks .__init__
1129-
1130- def patched_blocks_init (self , * args , ** kwargs ):
1131- """Patched Blocks.__init__ that adds defensive API info generation"""
1132- try :
1133- original_blocks_init (self , * args , ** kwargs )
1134- except Exception as e :
1135- # If Blocks initialization fails, log but continue
1136- print (f"Warning: Error during Blocks initialization: { type (e ).__name__ } : { str (e )} " )
1137- # Try to continue with minimal initialization
1138- try :
1139- original_blocks_init (self , * args , ** kwargs )
1140- except :
1141- pass
1142-
1143- # Safely get the original get_api_info method
1144- try :
1145- original_get_api_info = self .get_api_info
1146- except AttributeError :
1147- # If get_api_info doesn't exist, create a dummy method
1148- original_get_api_info = lambda : {}
1149-
1150- def safe_get_api_info ():
1151- """Safely get API info, never raising exceptions to prevent blocking"""
1152- try :
1153- api_info = original_get_api_info ()
1154- # Ensure we always return a dict, even if None
1155- return api_info if isinstance (api_info , dict ) else {}
1156- except TypeError as e :
1157- if "argument of type 'bool' is not iterable" in str (e ) or "additionalProperties" in str (e ):
1158- # Return empty API info to avoid crashing
1159- return {}
1160- # Catch all TypeError and return empty dict
1161- print (f"Warning: TypeError generating API info: { str (e )} " )
1162- return {}
1163- except ValueError as e :
1164- # Handle value errors during API generation
1165- print (f"Warning: ValueError generating API info: { str (e )} " )
1166- return {}
1167- except AttributeError as e :
1168- # Handle attribute errors during API generation
1169- print (f"Warning: AttributeError generating API info: { str (e )} " )
1170- return {}
1171- except KeyError as e :
1172- # Handle key errors during API generation
1173- print (f"Warning: KeyError generating API info: { str (e )} " )
1174- return {}
1175- except (ImportError , ModuleNotFoundError ) as e :
1176- # Handle import errors during API generation
1177- print (f"Warning: Import error generating API info: { str (e )} " )
1178- return {}
1179- except Exception as e :
1180- # Catch all other errors and log but don't crash
1181- print (f"Warning: Unexpected error generating API info: { type (e ).__name__ } : { str (e )} " )
1182- return {}
1183-
1184- # Safely assign the patched method
1185- try :
1186- self .get_api_info = safe_get_api_info
1187- except Exception as e :
1188- print (f"Warning: Could not patch get_api_info: { str (e )} " )
1189-
1190- # Temporarily patch Blocks class
1191- gr .Blocks .__init__ = patched_blocks_init
11921127
11931128 # Helper function to render Agent Cards
11941129 def render_agent_cards ():
@@ -1232,9 +1167,8 @@ def render_agent_cards():
12321167 with gr .Column ():
12331168 gr .Markdown ("#### Synthesizer B (Concise)" )
12341169 gr .JSON (value = all_cards .get ("synthesizer_agent_v2" , {}))
1235-
1236- try :
1237- with gr .Blocks (title = "Agentic RAG System" ) as interface :
1170+
1171+ with gr .Blocks (title = "Agentic RAG System" , css = CUSTOM_CSS , theme = gr .themes .Soft ()) as interface :
12381172 gr .Markdown ("""
12391173 # 🤖 Agentic RAG System
12401174
@@ -2075,16 +2009,13 @@ def run_all_a2a_tests():
20752009 outputs = [a2a_chatbot ],
20762010 api_name = False
20772011 )
2078- a2a_clear_button .click (lambda : None , None , a2a_chatbot , queue = False , api_name = False )
2012+ a2a_clear_button .click (lambda : [] , None , a2a_chatbot , queue = False , api_name = False )
20792013 # a2a_status_button removed from Chat tab
20802014
20812015 # Checkbox event listener removed
20822016
20832017
20842018 return interface
2085- finally :
2086- # Restore original Blocks.__init__
2087- gr .Blocks .__init__ = original_blocks_init
20882019
20892020def main ():
20902021 # Check configuration
@@ -2111,9 +2042,7 @@ def main():
21112042 server_name = "0.0.0.0" ,
21122043 server_port = 7860 ,
21132044 share = True ,
2114- inbrowser = True ,
2115- css = CUSTOM_CSS ,
2116- theme = gr .themes .Soft ()
2045+ inbrowser = True
21172046 )
21182047
21192048def download_model (model_type : str ) -> str :
0 commit comments