Skip to content

Commit

Permalink
Added v2.1.5 Fixed Bugs and Open file default editor
Browse files Browse the repository at this point in the history
  • Loading branch information
haseeb-heaven committed Jan 1, 2025
1 parent f7a61e2 commit d9bca80
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 75 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,8 @@ output/*
*.env
.env
history.json
*.json
interp
venv
myvenv
heaven_venv
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ If you're interested in contributing to **Code-Interpreter**, we'd love to have
- **v2.1.2** - Added **Prompt Modes** now you can set prompt from file as well just place your prompt in `prompt.txt` file inside `system` directory.
- **v2.1.3** - Updated **OS Type detection** now for Linux **Arch & Debian** and generate accurate commands for all OS types.
- **v2.1.4** - Added **GPT-4o** models they are most effecient and cost effective models from **OpenAI**
- **v2.1.5** - Fixed OS type detection **Bug** for MacOS and feautre to open file with default editor.

## 📜 **License**

Expand Down
2 changes: 1 addition & 1 deletion history/history.json

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
--display_code, -dc: Displays the generated code in the output.
Author: HeavenHM
Date: 2023/12/01
Date: 2025/01/01
"""

from libs.interpreter_lib import Interpreter
Expand All @@ -24,15 +24,15 @@
from libs.utility_manager import UtilityManager

# The main version of the interpreter.
INTERPRETER_VERSION = "2.1.4"
INTERPRETER_VERSION = "2.1.5"

def main():
parser = argparse.ArgumentParser(description='Code - Interpreter')
parser.add_argument('--exec', '-e', action='store_true', default=False, help='Execute the code')
parser.add_argument('--save_code', '-s', action='store_true', default=False, help='Save the generated code')
parser.add_argument('--mode', '-md', choices=['code', 'script', 'command','vision','chat'], help='Select the mode (`code` for generating code, `script` for generating shell scripts, `command` for generating single line commands) `vision` for generating text from images')
parser.add_argument('--mode', '-md', choices=['code', 'script', 'command', 'vision', 'chat'], help='Select the mode (`code` for generating code, `script` for generating shell scripts, `command` for generating single line commands) `vision` for generating text from images')
parser.add_argument('--model', '-m', type=str, default='code-llama', help='Set the model for code generation. (Defaults to gpt-3.5-turbo)')
parser.add_argument('--version', '-v', action='version', version='%(prog)s '+ INTERPRETER_VERSION)
parser.add_argument('--version', '-v', action='version', version='%(prog)s ' + INTERPRETER_VERSION)
parser.add_argument('--lang', '-l', type=str, default='python', help='Set the interpreter language. (Defaults to Python)')
parser.add_argument('--display_code', '-dc', action='store_true', default=False, help='Display the code in output')
parser.add_argument('--history', '-hi', action='store_true', default=False, help='Use history as memory')
Expand All @@ -55,17 +55,18 @@ def main():
# Create an instance of the Interpreter class and call the main method.
interpreter = Interpreter(args)
interpreter.interpreter_main(INTERPRETER_VERSION)



if __name__ == "__main__":
try:
main()
except SystemExit:
pass # Ignore the SystemExit exception caused by --version argument
except Exception as exception:
try:
main()
except SystemExit:
pass # Ignore the SystemExit exception caused by --version argument
except Exception as exception:

# Print a meaningful error message if the interpreter is not setup properly.
if ".env file" in str(exception):
display_markdown_message("Interpreter is not setup properly. Please follow these steps \
# Print a meaningful error message if the interpreter is not setup properly.
if ".env file" in str(exception):
display_markdown_message("Interpreter is not setup properly. Please follow these steps \
to setup the interpreter:\n\
1. Create a .env file in the root directory of the project.\n\
2. Add the following line to the .env file:\n\
Expand All @@ -74,7 +75,7 @@ def main():
ANTHROPIC_API_KEY=<your api key>\n\
3. Replace <your api key> with your OpenAI/Gemini API key.\n\
4. Run the interpreter again.")
else:
display_markdown_message(f"An error occurred: {exception}")
traceback.print_exc()
else:
display_markdown_message(f"An error occurred: {exception}")
traceback.print_exc()
Loading

0 comments on commit d9bca80

Please sign in to comment.