diff --git a/src/run.py b/src/run.py new file mode 100644 index 0000000..ddcb0d2 --- /dev/null +++ b/src/run.py @@ -0,0 +1,85 @@ +#!/usr/bin/env python +"""Run script for Deep Agent with filesystem export.""" + +import sys +import argparse +from dotenv import load_dotenv + +from .agent import create_my_agent, extract_virtual_files, export_files_to_disk + + +# Load environment variables +load_dotenv() + + +def main(): + parser = argparse.ArgumentParser( + description="Run Deep Agent with internet search and file export" + ) + parser.add_argument( + "task", + type=str, + nargs="?", + default="Find the latest advancements in AI and save to summary.md", + help="Task description for the agent" + ) + parser.add_argument( + "--export-dir", + type=str, + default="./exported_files", + help="Directory to export files to" + ) + parser.add_argument( + "--thread-id", + type=str, + default="default", + help="Thread ID for state persistence" + ) + + args = parser.parse_args() + + print("\n" + "=" * 60) + print("šŸ¤– DEEP AGENT") + print("=" * 60) + print(f"\nšŸ“‹ Task: {args.task}\n") + print("-" * 60) + + # Create and run the agent + agent = create_my_agent() + + print("\nšŸ”„ Running agent...\n") + + # Invoke the agent + result = agent.invoke( + {"messages": [{"role": "user", "content": args.task}]}, + config={"configurable": {"thread_id": args.thread_id}} + ) + + # Display the agent's response + print("\n" + "=" * 60) + print("šŸ“ AGENT RESPONSE") + print("=" * 60) + + if "messages" in result: + last_message = result["messages"][-1] + if hasattr(last_message, 'content'): + print(f"\n{last_message.content}\n") + else: + print(f"\n{last_message}\n") + + # Extract and export virtual files + print("\n" + "=" * 60) + print("šŸ’¾ EXPORTING VIRTUAL FILES") + print("=" * 60) + print() + + files = extract_virtual_files(agent, thread_id=args.thread_id) + export_files_to_disk(files, export_dir=args.export_dir) + + print("\n" + "=" * 60) + print("āœ… DONE") + print("=" * 60) + + +if __name__ == "__main__": + main() \ No newline at end of file