TheR1D / shell_gpt

A command-line productivity tool powered by AI large language models like GPT-4, will help you accomplish your tasks faster and more efficiently.
MIT License
9.43k stars 746 forks source link

Problem with repl sessions in 1.0 #408

Closed hcal closed 9 months ago

hcal commented 9 months ago

After updating to version1.0 today, I ran into a couple of interesting issues. I don't think I'm doing anything wrong, but i would welcome the correction if i am.

Issue 1

The first time starting a new repl chat, it enters a normal repl session. Then when I try to reenter it, it shows me the history and dumps me back out at the bash prompt. Previously this command would bring me back into my session.

[~] 🌖 sgpt --list-chats
/tmp/chat_cache/quick_chat
/tmp/chat_cache/quick_chat2
/tmp/chat_cache/temp
[~] 🌗 sgpt --repl quick_chat
──────────────────────────────────────────────────── Chat History ─────────────────────────────────────────────────────
system: You are ShellGPT
You are ShellGPT
You are programming and system administration assistant.
You are managing Linux/Arch Linux operating system with bash shell.
Provide short responses in about 100 words, unless you are specifically asked for more details.
Use and apply Markdown formatting when possible.
If you need to store any data, assume it will be stored in the conversation.
user: Hi
assistant: Hello! How can I assist you today?
user: in md, show me a list of planets we know of
assistant: Sure! Here is a list of some of the planets in our solar system:

1. Mercury
2. Venus
3. Earth
4. Mars
5. Jupiter
6. Saturn
7. Uranus
8. Neptune

These are the eight planets in our solar system that orbit around the Sun.
[~] 🌘 

Issue 2

Also, using a previously working role presents the following error.

[~] 🌘 sgpt --list-roles
/home/username/.config/shell_gpt/roles/default.json
/home/username/.config/shell_gpt/roles/shell.json
/home/username/.config/shell_gpt/roles/describe_shell.json
/home/username/.config/shell_gpt/roles/code.json
/home/username/.config/shell_gpt/roles/chatr.json
/home/username/.config/shell_gpt/roles/improver.json
/home/username/.config/shell_gpt/roles/min.json
/home/username/.config/shell_gpt/roles/ShellGPT.json
/home/username/.config/shell_gpt/roles/Shell Command Generator.json
/home/username/.config/shell_gpt/roles/Shell Command Descriptor.json
/home/username/.config/shell_gpt/roles/Code Generator.json
[~] 🌑 sgpt  --repl quick_chat --role chatr
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/username/.lousername/pipx/venvs/shell-gpt/lib/python3.11/site-packages/sgpt/app.py:154 in main       │
│                                                                                                  │
│   151 │   role_class = (                                                                         │
│   152 │   │   DefaultRoles.check_get(shell, describe_shell, code)                                │
│   153 │   │   if not role                                                                        │
│ ❱ 154 │   │   else SystemRole.get(role)                                                          │
│   155 │   )                                                                                      │
│   156 │                                                                                          │
│   157 │   if repl:                                                                               │
│                                                                                                  │
│ ╭─────────────── locals ────────────────╮                                                        │
│ │               cache = True            │                                                        │
│ │                chat = None            │                                                        │
│ │                code = False           │                                                        │
│ │         create_role = None            │                                                        │
│ │      describe_shell = False           │                                                        │
│ │              editor = False           │                                                        │
│ │ install_integration = None            │                                                        │
│ │          list_chats = None            │                                                        │
│ │          list_roles = None            │                                                        │
│ │               model = 'gpt-3.5-turbo' │                                                        │
│ │              prompt = None            │                                                        │
│ │                repl = 'quick_chat'    │                                                        │
│ │                role = 'chatr'         │                                                        │
│ │               shell = False           │                                                        │
│ │           show_chat = None            │                                                        │
│ │           show_role = None            │                                                        │
│ │        stdin_passed = False           │                                                        │
│ │         temperature = 0.0             │                                                        │
│ │     top_probability = 1.0             │                                                        │
│ │             version = None            │                                                        │
│ ╰───────────────────────────────────────╯                                                        │
│                                                                                                  │
│ /home/username/.lousername/pipx/venvs/shell-gpt/lib/python3.11/site-packages/sgpt/role.py:79 in get        │
│                                                                                                  │
│    76 │   │   file_path = cls.storage / f"{name}.json"                                           │
│    77 │   │   if not file_path.exists():                                                         │
│    78 │   │   │   raise BadArgumentUsage(f'Role "{name}" not found.')                            │
│ ❱  79 │   │   return cls(**json.loads(file_path.read_text()))                                    │
│    80 │                                                                                          │
│    81 │   @classmethod                                                                           │
│    82 │   @option_callback                                                                       │
│                                                                                                  │
│ ╭─────────────────────────────── locals ────────────────────────────────╮                        │
│ │       cls = <class 'sgpt.role.SystemRole'>                            │                        │
│ │ file_path = PosixPath('/home/username/.config/shell_gpt/roles/chatr.json') │                        │
│ │      name = 'chatr'                                                   │                        │
│ ╰───────────────────────────────────────────────────────────────────────╯                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: SystemRole.__init__() got an unexpected keyword argument 'expecting'
WolframRavenwolf commented 9 months ago

Can confirm Issue 1: REPL mode isn't working anymore with v1.0, it just shows the history, it's no longer possible to continue the conversation.

TheR1D commented 9 months ago

Thank you for reporting this issue. I can confirm there was a bug in REPL mode since last release. it is fixed in PR https://github.com/TheR1D/shell_gpt/pull/410 and released ShellGPT 1.0.1.

Regarding second issue sgpt --repl quick_chat --role chatr as it is stated in release notes ShellGPT 1.0.0 because of significant changes in roles, unfortunately previously created custom roles and chats will not work with ShellGPT v1.0.0 and you will need to re-create them using new version.