laya-browser / code /apps /browser_task.py
cklxx's picture
laya-browser v10 / v10s: laya fine-tuned as a browser-agent decision head + code + results
adf912b verified
Raw History Blame Contribute Delete
1.32 kB
import os, sys, json, time
sys.path.insert(0, "/home/ckl/projects/S/jev-ultrafast")
os.environ.update(BU_CDP_URL="http://127.0.0.1:9222", TYPESAFE_BASE_URL="http://127.0.0.1:8791", TYPESAFE_API_KEY="local",
TEXT_MODEL_API_KEY="local", TEXT_MODEL_BASE_URL="http://127.0.0.1:30000/v1", TEXT_MODEL="Qwen/Qwen3-4B-AWQ",
TEXT_MODEL_EXTRA_JSON='{"chat_template_kwargs": {"enable_thinking": false}}')
from jev_ultrafast import Agent
url = sys.argv[1]; goal = sys.argv[2]
t = time.time()
with Agent(url, goal) as agent:
print("elements on first page:", len(agent.snapshot()["elements"]), "| title:", agent.state["page"]["title"])
for state in agent.run():
h = state["history"][-1] if state["history"] else None
d = state["decisions"][-1] if state["decisions"] else None
print(f"{state['elapsed_ms']:6d} ms status={state['status']:9s} op={d['operation'] if d else None:9s} "
f"conf={d['confidence'] if d else 0:.2f} model={d['latency_ms'] if d else 0:4d}ms "
f"action={h['action'][:60] if h else None} text={h['text'] if h else None}")
if len(state["history"]) > 25: break
print("FINAL:", state["status"], "| url:", state["page"]["url"], "| title:", state["page"]["title"], "| wall", round(time.time() - t, 1), "s")