microsoft / Codex-CLI

CLI tool that uses Codex to turn natural language commands into their Bash/ZShell/PowerShell equivalents
MIT License
1.99k stars 182 forks source link

Converted state management from file saving to prompt engine #114

Open abhimasand opened 2 years ago

abhimasand commented 2 years ago

This PR focuses on changing the file config method with prompt engine. This has 2 major benefits - Easy State Management and Faster Reload Times.

Prompt Engine support has majorly changed the implementation of these below items:-

  1. The txt config files have been converted to YAML. 1.1. This allows for easy change of model parameters without having to worry about unintended space characters in the config causing an issue. 1.2. Additionally, now the config won't be in the OpenAI prediction string while querying and will only be used for constructing the prompt. 1.3 Prompt sharing can be done via the YAML files directly, and if there is some problem in the config declaration, the YAML decoding process will pre-intimate while loading the YAML.
  2. Global variables have been replaced by function passing and have been made much more streamlined and provided access to functions which need access to those variables. Moved around some logic from some functions to others to allow this, for example, the shell prefix.
  3. Readline functions to get custom input parameters like 0.2 in "set temperature 0.2" have been converted to regex.
abhimasand commented 2 years ago

Tested on Windows and ZSH, to be tested on Bash

ryanvolum commented 2 years ago

@codehruv, @dluc, mind taking a look at @abhimasand's PR? It makes some fairly major changes - all look positive to me (code cleanup, factoring in prompt-engine, etc.).

dluc commented 2 years ago

Overall it seems working, however I have the impression that the PR includes fixes and refactoring not needed by the move to prompt-engine, which makes the review harder. If that's the case, I would have preferred splitting the PR in 2, one to clean up and one to migrate (or viceversa).

dluc commented 2 years ago

wrt the migration from TXT to YAML, also considering https://github.com/microsoft/Codex-CLI/issues/112, I think there was value in the simplicity of TXT files quite easy to edit, while YAML will cause some friction for users looking to customize the examples. Not sure if we have it, is there some documentation helping with this task, e.g. "how to add more examples" and "how to include custom suggestions" ?