Add agent
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
import os
|
||||||
|
from utils import web_search, create_virtual_file, export_files, log
|
||||||
|
|
||||||
|
# Simple orchestrator
|
||||||
|
|
||||||
|
def run_agent(query: str, out_dir: str = "."):
|
||||||
|
log(f"Searching for '{query}'")
|
||||||
|
results = web_search(query)
|
||||||
|
files = []
|
||||||
|
for i, r in enumerate(results, 1):
|
||||||
|
name = f"result_{i}.txt"
|
||||||
|
content = f"Title: {r.get('title','')}\nURL: {r.get('url','')}\n\n---\n"
|
||||||
|
files.append(create_virtual_file(name, content))
|
||||||
|
log(f"Created {len(files)} virtual files")
|
||||||
|
export_files(files, out_dir)
|
||||||
|
log("Exported to filesystem")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
import argparse
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("query", help="Search query")
|
||||||
|
parser.add_argument("--out", default="output", help="Output directory")
|
||||||
|
args = parser.parse_args()
|
||||||
|
run_agent(args.query, args.out)
|
||||||
Reference in New Issue
Block a user