28 lines
1.7 KiB
Python
28 lines
1.7 KiB
Python
"""Small opt-in test using the existing model config and a disposable workspace."""
|
||
import json
|
||
import os
|
||
from pathlib import Path
|
||
import subprocess
|
||
import tempfile
|
||
|
||
BINARY=Path(__file__).resolve().parents[1]/'target/debug/grokboy'
|
||
def main():
|
||
with tempfile.TemporaryDirectory(prefix='grokboy-live-') as root:
|
||
Path(root,'items.txt').write_text('banana\napple\nbanana\npear\n')
|
||
env={**os.environ,'GROKBOY_MAX_ROUNDS_TOTAL':'12','GROKBOY_MAX_ROUNDS':'4',
|
||
'GROKBOY_SESSIONS_DIR':str(Path(root,'sessions')),'GROKBOY_PROGRESS':'1'}
|
||
prompt='幫我整理目前目錄的 items.txt:去除重複、依字母排序,另存 clean.txt,每行一筆;再產生 report.txt,用數字記錄原本幾筆、整理後幾筆。請實際讀回兩個產物確認內容,最後告訴我結果。只需要操作目前目錄,不需要上網。'
|
||
result=subprocess.run([str(BINARY),'run',prompt],cwd=root,env=env,stdin=subprocess.DEVNULL,
|
||
capture_output=True,text=True,timeout=240)
|
||
print(result.stderr[-5000:])
|
||
print(result.stdout)
|
||
assert result.returncode==0, result.returncode
|
||
assert Path(root,'clean.txt').read_text().splitlines()==['apple','banana','pear']
|
||
report=Path(root,'report.txt').read_text()
|
||
assert '4' in report and '3' in report,report
|
||
assert '〔進度〕' in result.stderr or '〔計畫〕' in result.stderr
|
||
session=json.loads(next(Path(root,'sessions').glob('*.json')).read_text())
|
||
assert session['last_verdict'] in ('done','answer')
|
||
print('PASS live model: opening/progress, tools, two verified artifacts and final answer')
|
||
if __name__=='__main__':main()
|