File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -78,9 +78,13 @@ Override the gpt model used by the tool.
7878
7979** Default** : ` gpt-4o `
8080
81+ ### ` GPT_CMD_TOKEN `
82+
83+ Provide your OpenAI token via this env var instead of storing it in a file.
84+
8185### ` GPT_CMD_TOKEN_FILE_PATH `
8286
83- Override the file path the tool gets your OpenAI token from.
87+ Override the file path the tool gets your OpenAI token from. Alternatively, you can provide the token directly via ` GPT_CMD_TOKEN ` .
8488
8589** Default** : ` ~/OPENAI_TOKEN `
8690
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ def write_file(file_path, content):
3737 'model' : os .environ .get ('GPT_CMD_MODEL' , 'gpt-4o' ),
3838 'token_file_path' : os .environ .get (
3939 'GPT_CMD_TOKEN_FILE_PATH' ,
40- os .path .join (os .path .expanduser ('~' ), 'OPENAI_TOKEN' ),
40+ os .path .join (os .path .expanduser ('~' ), 'OPENAI_TOKEN' )
4141 ),
4242}
4343
@@ -79,7 +79,11 @@ def red(text):
7979def call_gpt (messages ):
8080 global OPENAI_CLIENT
8181 if OPENAI_CLIENT is None :
82- OPENAI_CLIENT = OpenAI (api_key = read_file (OPTIONS ['token_file_path' ]))
82+ token = os .environ .get (
83+ 'GPT_CMD_TOKEN' ,
84+ read_file (OPTIONS ['token_file_path' ])
85+ )
86+ OPENAI_CLIENT = OpenAI (api_key = token )
8387
8488 response = OPENAI_CLIENT .chat .completions .create (
8589 model = OPTIONS ['model' ],
You can’t perform that action at this time.
0 commit comments