llm
llm copied to clipboard
works on windows
os.sep + path + skipping readline for windows.
Why I suggest skipping readline:
Me & Chat GPT (back when it thought its name was Assistant) made a pacman game in the terminal that ran on windows. It took win32 API calls. Textual does it better: https://github.com/Textualize/textual/blob/main/src/textual/drivers/win32.py
Also I just wasn't sure what the motivation was. When I run llm
in the input field I can use the arrows just fine. The regular input()
function allows for left/right arrows. Prefilling an input and up/down arrows would make sense.
Addresses issue : https://github.com/simonw/llm/issues/409
Would pyreadline3
work on Windows here though?
https://github.com/simonw/llm/blob/8021e12aaafdb452c9efd7b8571690f94efd579b/setup.py#L50
Pushed a tiny fix for this failing test:
if os.name != "nt":
# Should be chmod 600
> assert oct(keys_path.stat().st_mode)[-3:] == "600"
tests/test_keys.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest._py.path.Stat object at 0x7f598d774490>, name = 'st_mode'
def __getattr__(self, name: str) -> Any:
> return getattr(self._osstatresult, "st_" + name)
E AttributeError: 'os.stat_result' object has no attribute 'st_st_mode'
Oh that bot! It changed mode
to st_mode
and I didn't see it fail.
pyreadline3
no longer throws on import, but doesn't handle that key. I get the impression that it has only reimplemented some of what readline can do.
File "E:\github\llm\llm\cli.py", line 347, in chat
readline.parse_and_bind("\\e[D: backward-char")
File "E:\.virtualenv\llm-Ou002Y_x\Lib\site-packages\pyreadline3\rlmain.py", line 112, in parse_and_bind
self.mode._bind_key(key, func)
File "E:\.virtualenv\llm-Ou002Y_x\Lib\site-packages\pyreadline3\modes\basemode.py", line 181, in _bind_key
keyinfo = make_KeyPress_from_keydescr(key.lower()).tuple()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\.virtualenv\llm-Ou002Y_x\Lib\site-packages\pyreadline3\keysyms\common.py", line 138, in make_KeyPress_from_keydescr
raise IndexError("Not a valid key: '%s'" % keydescr)
IndexError: Not a valid key: '\e[d'
I still don't know where the left/right arrows are failing to work so I'm not sure about how to go about implementing it for windows.