Merge h2/browser-tools: prompt speaks the one-tool shape (H2/H3)
This commit is contained in:
commit
6b5c9ccf49
|
|
@ -1132,7 +1132,7 @@ pub fn spawn(job: Job, bot_id: u64, tx: Sender<(u64, StreamEvent)>, cancel: Arc<
|
|||
let times = tried.iter().rev().take(10).filter(|k| **k == key).count() + 1;
|
||||
tried.push(key);
|
||||
if times >= 4 {
|
||||
let text = format!("沒有執行:這一步你已經試了 {times} 次,畫面都沒有變成你要的樣子。不要再試同一步。改用別的方法:照截圖上的編號點、網頁改用 browser_read 拿連結直接 browser_open,或用 hand_over_computer 請使用者幫忙。");
|
||||
let text = format!("沒有執行:這一步你已經試了 {times} 次,畫面都沒有變成你要的樣子。不要再試同一步。改用別的方法:照截圖上的編號點、網頁改用 browser(action=read)拿連結直接 action=open,或用 hand_over_computer 請使用者幫忙。");
|
||||
trouble.set(true);
|
||||
send(StreamEvent::ToolStatus(call.id.clone(), ToolStatus::Failed));
|
||||
let result = Message::tool_result(&call.id, &call.name, &text);
|
||||
|
|
@ -1149,7 +1149,7 @@ pub fn spawn(job: Job, bot_id: u64, tx: Sender<(u64, StreamEvent)>, cancel: Arc<
|
|||
if repeat_note.is_empty() {
|
||||
let same = same_answers(&history, &asked.name, &asked.args);
|
||||
if same >= 3 {
|
||||
let text = format!("沒有執行:同一個工具、同樣的參數你已經做了 {same} 次,每次結果都一模一樣,再做也不會不同。換一個做法(例如用 browser_open 打開要看的網址),或直接告訴使用者你看到了什麼。");
|
||||
let text = format!("沒有執行:同一個工具、同樣的參數你已經做了 {same} 次,每次結果都一模一樣,再做也不會不同。換一個做法(例如用 browser 的 action=open 打開要看的網址),或直接告訴使用者你看到了什麼。");
|
||||
trouble.set(true);
|
||||
send(StreamEvent::ToolStatus(call.id.clone(), ToolStatus::Failed));
|
||||
let result = Message::tool_result(&call.id, &call.name, &text);
|
||||
|
|
|
|||
|
|
@ -4211,16 +4211,16 @@ fn system_prompt(b: &Bot, st: &State, computers: &[tools::Target], default_compu
|
|||
做完 App 操作後,用一句話告訴使用者結果(例如排程的時間)。\n\n\
|
||||
你也可以上網和用使用者的瀏覽器:\n\
|
||||
- 公開網頁:web_fetch。\n\
|
||||
- 要登入才看得到的(Threads、Instagram、Facebook、Gmail、銀行…):用 browser_open 在 AnyBot 自己的瀏覽器視窗打開:它會等頁面載入,直接回傳頁面內容和可以點的編號(不用再 browser_read;之後頁面變了才用 browser_read 重讀)。例如看 Threads 帳號:browser_open(\"https://www.threads.net\")。要知道某個網站有沒有登入,一定要打開那個網站看,不要看目前的分頁(常常是空白頁)就下結論。\n\
|
||||
- 網頁上的事(任何電腦、任何網站)一律用 browser_* 工具:先 browser_read(或 browser_screenshot)拿到每個連結、按鈕、欄位的編號和網址,再用 browser_click/browser_type/browser_select/browser_press 照編號操作;要去的頁面有網址就直接 browser_open。網頁上絕對不要看截圖猜座標點。表格用 browser_table 讀,找字用 browser_find,要等載入用 browser_wait,匯出報表用 browser_download。不要猜網址;找不到想要的功能(例如排序、篩選),就看欄位標題、篩選器、下拉選單或分頁標籤,還是沒有就照頁面現有的資料自己整理,並說明網站沒有這個功能。
|
||||
- 要登入才看得到的(Threads、Instagram、Facebook、Gmail、銀行…):用 browser(action=open,url)在 AnyBot 自己的瀏覽器視窗打開:它會等頁面載入,直接回傳頁面內容和可以點的編號(不用再 action=read;之後頁面變了才用 action=read 重讀)。例如看 Threads 帳號:browser(action=open, url=\"https://www.threads.net\")。要知道某個網站有沒有登入,一定要打開那個網站看,不要看目前的分頁(常常是空白頁)就下結論。\n\
|
||||
- 網頁上的事(任何電腦、任何網站)一律用 browser 一個工具(action 選動作):先 action=read(或 action=screenshot)拿到每個連結、按鈕、欄位的編號和網址,再用 action=click/type/select/press 照編號操作;要去的頁面有網址就直接 action=open。網頁上絕對不要看截圖猜座標點。表格用 action=table 讀,找字用 action=find,要等載入用 action=wait,匯出報表用 action=download。不要猜網址;找不到想要的功能(例如排序、篩選),就看欄位標題、篩選器、下拉選單或分頁標籤,還是沒有就照頁面現有的資料自己整理,並說明網站沒有這個功能。
|
||||
- 絕對不要直接呼叫網站的內部 API、下載網站的程式碼來研究,或用程式大量抓資料:網站會把帳號當成機器人(例如跳出拼圖驗證、封鎖帳號)。也絕對不要用指令去讀瀏覽器的 Cookie、瀏覽紀錄、密碼或設定檔資料庫。
|
||||
- 需要使用者親手做的步驟(讀到登入頁、輸入密碼、驗證碼、拼圖、簡訊或 email 驗證、確認付款):先在那台電腦上把那一頁打開、點到要輸入的地方,再呼叫 hand_over_computer,instruction 寫清楚要他做什麼。聊天裡會出現那台電腦的即時畫面,他點「接管」做完後按「我完成了」,你再確認、接著做(登入一次之後就會記住)。不要只用文字叫他自己去找視窗,絕對不要替他打密碼,也不要叫他改瀏覽器的設定或選單、或說要從 Chrome 複製登入或 Cookie(都不需要,也沒有這個功能)。\n\
|
||||
- AnyBot 瀏覽器有設定檔(profile),每個有自己的登入。使用者說要換 profile/設定檔/另一個帳號時,用 browser_profiles:list 看有哪些,use 切換,add 新增(新的要登入一次)。也可以在 browser_open / browser_read 帶 profile 參數。使用者想用自己平常的 Chrome(自己的 Chrome 設定檔、已經登入的帳號)時,用 profile「你的瀏覽器」:請使用者在 Chrome 切到想要的設定檔,再 browser_read。\n\
|
||||
- AnyBot 瀏覽器有設定檔(profile),每個有自己的登入。使用者說要換 profile/設定檔/另一個帳號時,用 browser 的 action=profiles:list 看有哪些,use 切換,add 新增(新的要登入一次)。也可以在 action=open/read 帶 profile 參數。使用者想用自己平常的 Chrome(自己的 Chrome 設定檔、已經登入的帳號)時,用 profile「你的瀏覽器」:請使用者在 Chrome 切到想要的設定檔,再 browser_read。\n\
|
||||
- 你也能像人一樣操作螢幕({screens}),用在檔案、指令和網頁工具做不到的事(例如操作其他 App)。照截圖上的編號操作(工具說明裡有怎麼用),按鈕名字清楚的也可以直接用 name 指定(例如計算機的 name「4」、name「=」),不用自己對編號;只有沒有編號的東西才用 x、y。結果說「畫面和上一步完全一樣」就是沒點到:換一個編號或換方法,絕對不要重複同一步。已經從畫面知道接下來幾步時(填一張表、一組捷徑),用 computer(action=batch)一次做完;要看上一步結果才知道下一步的,就一步一步來。每次看截圖用一句話說畫面顯示什麼、這步成功與否。\n\
|
||||
- 每件事動手前先選好路:① 有專用工具就用專用工具(網頁用 browser_*,Mac 的提醒事項、行事曆、郵件等用它們的專門工具)。② 改設定、處理檔案、安裝、開關服務、App 有自己的指令列:用指令。③ 只有畫面上才做得到的(App 裡的按鈕或開關、選單列的圖示、沒有指令可改的設定):操作畫面,先把那個 App 的視窗打開到最前面(Mac 用 open -a App名稱),再照編號點。\n\
|
||||
- 換路的規則:一條指令因為環境失敗(Operation not permitted、程式當掉、結果寫著是沙盒擋的),就不要換寫法再試同一條路,改走畫面;畫面上找不到要的東西,先想有沒有指令或專用工具做得到。絕對不要用指令截圖或分析圖片(screencapture、import、PIL):看畫面一律用 computer(action=screenshot),看不清楚就用 action=zoom。\n\
|
||||
- 像一個熟練的人那樣做事:動手前先想好要做哪幾步、做完怎樣才算成功(照「電腦現況」挑那台電腦上最直接的做法,不用再試探環境);選定一條路就做到底,不要在指令和畫面之間來回換。出錯先讀錯誤訊息想原因再換方法,同一個做法失敗兩次就換。做完只用一種最直接的方法確認一次(讀設定檔、查狀態、看一眼畫面),確認了就回答,不要用好幾種方法反覆確認。\n\
|
||||
- 沒見過的 App 或畫面也一樣:先看清楚(截圖、需要就放大),找選單、設定、按鈕上的字,照編號點;網頁上的東西用 browser_* 的編號。\n\
|
||||
- 沒見過的 App 或畫面也一樣:先看清楚(截圖、需要就放大),找選單、設定、按鈕上的字,照編號點;網頁上的東西用 browser 的編號。\n\
|
||||
- 使用者交代的事就做完:不要做到一半停下來問「要我繼續嗎」「要我現在做嗎」,畫面不如預期就自己處理(關掉擋路的視窗、打開要用的 App)再接著做。只有需要使用者親手做、或要先確認會切斷連線、刪除、付款這類事情時才停下來問。\n\
|
||||
- 系統跳出的權限或安全詢問(「允許…存取」「要允許…嗎」、輸入密碼、Touch ID)不要替使用者按:告訴他是什麼、請他自己決定(需要時用 hand_over_computer)。\n\
|
||||
- 按快捷鍵(cmd+w、cmd+q、cmd+s…)前先確定最前面的是你要操作的 App;關掉一個視窗以後,最前面的可能已經換成別的 App。\n\
|
||||
|
|
|
|||
|
|
@ -517,7 +517,7 @@ pub fn action_tool(action: &str) -> Option<&'static str> {
|
|||
pub fn tool(profile: &Value) -> Value {
|
||||
json!({
|
||||
"name": TOOL,
|
||||
"description": "Drive AnyBot's browser: one tool, picked by action. For anything on a web page use this, never screen coordinates. Start with open (it answers like read) or read, then act by the numbers (ref) or visible text the last result showed. Ask the person before anything that buys, pays, sends, posts or deletes.
|
||||
"description": "Drive AnyBot's browser: one tool, picked by action. For anything on a web page use this, never screen coordinates. Start with open (it answers like read) or read, then act by the numbers (ref) or visible text the last result showed. Never act on a page from memory — use the numbers the latest result showed.
|
||||
actions:
|
||||
- open {url}: open a link in a new tab and report the page (title, address, text, numbered controls)
|
||||
- read {max_chars}: read the current tab the same way (numbers for click/type/select)
|
||||
|
|
@ -525,7 +525,7 @@ actions:
|
|||
- find {text}: like Cmd-F: every place the text appears with words around it
|
||||
- table {index, all, max_rows}: read the page's tables as Markdown (reports, product lists)
|
||||
- screenshot {full, marks}: the page as a picture with numbered boxes on every control; needs no screen permission
|
||||
- click {ref|text, double, button}: real mouse click (menus, date pickers, dropdowns, calendar days)
|
||||
- click {ref|text, double, button}: real mouse click (menus, date pickers, dropdowns, calendar days); buying/paying/sending/deleting needs the person's OK first
|
||||
- hover {ref|text}: move over a control (opens hover menus) and report what appeared
|
||||
- type {ref|text, value, append, submit}: real keystrokes into a field (clears first unless append). Never type passwords here: use fill
|
||||
- press {key}: Enter, Tab, Escape, ctrl+a, … (optionally on ref/text first)
|
||||
|
|
|
|||
Loading…
Reference in New Issue