mirror of
https://github.com/NCBM/plyngent.git
synced 2026-07-23 05:55:16 +08:00
core/cli: resume sessions, history, editline Tab, higher tool rounds
Default to file SQLite DB and latest session; /history and /rounds; bind Tab for libedit; max tool rounds default 32.
This commit is contained in:
@@ -80,6 +80,23 @@ def test_completer_commands(tmp_path: object, monkeypatch: object) -> None:
|
||||
assert set(found) <= set(SLASH_COMMANDS)
|
||||
|
||||
|
||||
def test_bind_tab_complete_runs() -> None:
|
||||
from plyngent.cli.readline_setup import bind_tab_complete
|
||||
|
||||
class FakeReadline:
|
||||
binds: list[str]
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.binds = []
|
||||
|
||||
def parse_and_bind(self, s: str) -> None:
|
||||
self.binds.append(s)
|
||||
|
||||
fake = FakeReadline()
|
||||
bind_tab_complete(fake)
|
||||
assert any("complete" in b or "rl_complete" in b for b in fake.binds)
|
||||
|
||||
|
||||
def test_completer_provider_args(tmp_path: object, monkeypatch: object) -> None:
|
||||
import readline
|
||||
from pathlib import Path
|
||||
|
||||
@@ -121,3 +121,22 @@ async def test_resume(state: ReplState) -> None:
|
||||
assert sid is not None
|
||||
state.agent.messages.clear()
|
||||
assert await handle_slash(state, f"/resume {sid}") is True
|
||||
|
||||
|
||||
async def test_history(state: ReplState, capsys: pytest.CaptureFixture[str]) -> None:
|
||||
from plyngent.lmproto.openai_compatible.model import AssistantChatMessage, UserChatMessage
|
||||
|
||||
state.agent.messages = [
|
||||
UserChatMessage(content="hello"),
|
||||
AssistantChatMessage(content="hi there"),
|
||||
]
|
||||
assert await handle_slash(state, "/history") is True
|
||||
out = capsys.readouterr().out
|
||||
assert "user: hello" in out
|
||||
assert "assistant: hi there" in out
|
||||
|
||||
|
||||
async def test_rounds(state: ReplState) -> None:
|
||||
assert await handle_slash(state, "/rounds 40") is True
|
||||
assert state.max_rounds == 40 # noqa: PLR2004
|
||||
assert state.agent.max_rounds == 40 # noqa: PLR2004
|
||||
|
||||
Reference in New Issue
Block a user