Spaces:
Sleeping
Sleeping
| from pathlib import Path | |
| import click | |
| from second_brain_online.application.agents import get_agent | |
| from second_brain_online.application.ui.custom_gradio_ui import CustomGradioUI | |
| def main(retriever_config_path: Path, ui: bool, query: str) -> None: | |
| """Run the agent either in Gradio UI or CLI mode. | |
| Args: | |
| ui: If True, launches Gradio UI. If False, runs in CLI mode | |
| query: Query string to run in CLI mode | |
| """ | |
| agent = get_agent(retriever_config_path=Path(retriever_config_path)) | |
| if ui: | |
| # Pass the AgentWrapper directly so it uses our custom run() method | |
| CustomGradioUI(agent).launch() | |
| else: | |
| assert query, "Query is required in CLI mode" | |
| result = agent.run(query) | |
| # DEBUG: Print raw result | |
| print("\n" + "="*80) | |
| print("DEBUG: RAW AGENT RESULT") | |
| print("="*80) | |
| print(f"Type: {type(result)}") | |
| print(f"Full Content:\n{result}") | |
| print("="*80) | |
| # DEBUG: Check agent object attributes | |
| print("\n" + "="*80) | |
| print("DEBUG: AGENT OBJECT ATTRIBUTES") | |
| print("="*80) | |
| print(f"Agent type: {type(agent)}") | |
| print(f"Agent attributes: {dir(agent)}") | |
| if hasattr(agent, '_AgentWrapper__agent'): | |
| actual_agent = agent._AgentWrapper__agent | |
| print(f"Actual agent type: {type(actual_agent)}") | |
| print(f"Actual agent attributes: {dir(actual_agent)}") | |
| if hasattr(actual_agent, 'conversation_history'): | |
| print(f"Conversation history: {actual_agent.conversation_history}") | |
| if hasattr(actual_agent, 'messages'): | |
| print(f"Messages: {actual_agent.messages}") | |
| if hasattr(actual_agent, 'logs'): | |
| print(f"Logs: {actual_agent.logs}") | |
| if hasattr(actual_agent, 'state'): | |
| print(f"State: {actual_agent.state}") | |
| print("="*80) | |
| # Display the raw result directly (it's already perfectly formatted) | |
| print("\n" + "="*80) | |
| print("FINAL OUTPUT") | |
| print("="*80) | |
| print(result) | |
| print("="*80) | |
| if __name__ == "__main__": | |
| main() | |