Skip to content

Commit

Permalink
Add new var mind-wave-api-key-path
Browse files Browse the repository at this point in the history
  • Loading branch information
manateelazycat committed Mar 15, 2023
1 parent 86e978a commit 91b0645
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions mind-wave.el
Expand Up @@ -87,6 +87,11 @@
:type 'boolean
:group 'mind-wave)

(defcustom mind-wave-api-key-path (expand-file-name (file-name-concat user-emacs-directory "mind-wave" "chatgpt_api_key.txt"))
"The path to store OpenAI API Key."
:type 'boolean
:group 'mind-wave)

(defvar mind-wave-server nil
"The Mind-Wave Server.")

Expand Down
6 changes: 2 additions & 4 deletions mind_wave.py
Expand Up @@ -27,7 +27,7 @@
import base64
from epc.server import ThreadingEPCServer
from functools import wraps
from utils import (get_command_result, init_epc_client, eval_in_emacs, logger, close_epc_client, get_emacs_func_result, message_emacs, string_to_base64)
from utils import (get_command_result, get_emacs_var, init_epc_client, eval_in_emacs, logger, close_epc_client, get_emacs_func_result, message_emacs, string_to_base64)

def threaded(func):
@wraps(func)
Expand Down Expand Up @@ -85,9 +85,7 @@ def event_dispatcher(self):
logger.error(traceback.format_exc())

def chat_get_api_key(self):
user_emacs_dir = get_emacs_func_result("get-user-emacs-directory")
mind_wave_dir = os.path.join(user_emacs_dir, "mind-wave")
mind_wave_chat_api_key_file_path = os.path.join(mind_wave_dir, "chatgpt_api_key.txt")
mind_wave_chat_api_key_file_path = get_emacs_var("mind-wave-api-key-path")
key = None
if os.path.exists(mind_wave_chat_api_key_file_path):
with open(mind_wave_chat_api_key_file_path, "r") as f:
Expand Down

0 comments on commit 91b0645

Please sign in to comment.