dylanjcastillo / shell-genie

Your wishes are my commands
MIT License
478 stars 36 forks source link

Support for non-english explanations #6

Closed yuri-ccp closed 1 year ago

yuri-ccp commented 1 year ago

Currently the shell-genie understands non-english questions but when explain it's explains only in english.

Could do more useful for many non-english speakers to allow the shell-genie to ask the AI to respond in same language of the question or if it's not possible or to maintain more consistent responses to detect the current shell language and ask the AI to respond in that language.

dylanjcastillo commented 1 year ago

That's a good idea. Will try to implement it this week.

dylanjcastillo commented 1 year ago

Give it a try. It should work now!

yuri-ccp commented 1 year ago

Worked fine. Now it's response in the same language.

But this last update break my configuration after update due backend name change:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/yuri/.local/pipx/venvs/shell-genie/lib/python3.11/site-packages/shell_genie/main.py:102   │
│ in ask                                                                                           │
│                                                                                                  │
│    99 │   with open(config_path, "r") as f:                                                      │
│   100 │   │   config = json.load(f)                                                              │
│   101 │                                                                                          │
│ ❱ 102 │   genie = get_backend(**config)                                                          │
│   103 │   try:                                                                                   │
│   104 │   │   command, description = genie.ask(wish, explain)                                    │
│   105 │   except Exception as e:                                                                 │
│                                                                                                  │
│ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
│ │     app_dir = '/Users/yuri/Library/Application Support/.shell_genie'                         │ │
│ │      config = {                                                                              │ │
│ │               │   'backend': 'openai-gpt3',                                                  │ │
│ │               │   'os': 'MacOS',                                                             │ │
│ │               │   'os_fullname': 'macOS-12.6.5',                                             │ │
│ │               │   'shell': 'zsh',                                                            │ │
│ │               │   'openai_api_key': 'secret'    │ │
│ │               }                                                                              │ │
│ │ config_path = PosixPath('/Users/yuri/Library/Application Support/.shell_genie/config.json')  │ │
│ │     explain = True                                                                           │ │
│ │           f = <_io.TextIOWrapper name='/Users/yuri/Library/Application                       │ │
│ │               Support/.shell_genie/config.json' mode='r' encoding='UTF-8'>                   │ │
│ │        wish = 'what can I do with command ls -lh'                                            │ │
│ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
│                                                                                                  │
│ /Users/yuri/.local/pipx/venvs/shell-genie/lib/python3.11/site-packages/shell_genie/utils.py:29   │
│ in get_backend                                                                                   │
│                                                                                                  │
│   26 │   │   │   shell=config["shell"],                                                          │
│   27 │   │   )                                                                                   │
│   28 │   else:                                                                                   │
│ ❱ 29 │   │   raise ValueError(f"Unknown backend: {backend_name}")                                │
│   30                                                                                             │
│                                                                                                  │
│ ╭────────────────────────────────────────── locals ──────────────────────────────────────────╮   │
│ │ backend_name = 'openai-gpt3'                                                               │   │
│ │       config = {                                                                           │   │
│ │                │   'backend': 'openai-gpt3',                                               │   │
│ │                │   'os': 'MacOS',                                                          │   │
│ │                │   'os_fullname': 'macOS-12.6.5',                                          │   │
│ │                │   'shell': 'zsh',                                                         │   │
│ │                │   'openai_api_key': 'secret' │   │
│ │                }                                                                           │   │
│ ╰────────────────────────────────────────────────────────────────────────────────────────────╯   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: Unknown backend: openai-gpt3

But after deleted the config.json and inited again I notice that the new GPT name is now openai-gpt-3.5-turbo and after using it worked fine.