Skip to content

Commit

Permalink
Fix feedback from input api key
Browse files Browse the repository at this point in the history
Removed getpass, added prompt_toolkit.
Now shows * when typing characters
  • Loading branch information
Notnaton committed Jan 16, 2024
1 parent d2e7450 commit dcf2cde
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion interpreter/terminal_interface/utils/get_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def get_config(path=user_config_path):
config = None

try:
with open(path, "r", encoding='utf-8') as file:
with open(path, "r", encoding="utf-8") as file:
config = yaml.safe_load(file)
if config is not None:
return config
Expand Down
9 changes: 5 additions & 4 deletions interpreter/terminal_interface/validate_llm_settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import getpass
import os
import time

import litellm
from prompt_toolkit import prompt

from .utils.display_markdown_message import display_markdown_message

Expand All @@ -25,7 +25,9 @@ def validate_llm_settings(interpreter):

# OpenAI
if interpreter.llm.model in litellm.open_ai_chat_completion_models:
if not os.environ.get("OPENAI_API_KEY") and not interpreter.llm.api_key:
if (
True
): # not os.environ.get("OPENAI_API_KEY") and not interpreter.llm.api_key:
display_welcome_message_once()

display_markdown_message(
Expand All @@ -40,8 +42,7 @@ def validate_llm_settings(interpreter):
"""
)

response = getpass.getpass("OpenAI API key: ")
print(f"OpenAI API key: {response[:4]}...{response[-4:]}")
response = prompt("OpenAI API key: ", is_password=True)

display_markdown_message(
"""
Expand Down
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pywinctl = { version = "^0.3", optional = true }
semgrep = { version = "^1.52.0", optional = true }
yaspin = { version = "^3.0.1", optional = true }
pytesseract = { version = "^0.3.10", optional = true }
prompt-toolkit = "^3.0.43"

[tool.poetry.extras]
os = ["opencv-python", "pyautogui", "plyer", "pywinctl", "pytesseract"]
Expand Down

0 comments on commit dcf2cde

Please sign in to comment.