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.
78
78
79
79
** Default** : ` gpt-4o `
80
80
81
+ ### ` GPT_CMD_TOKEN `
82
+
83
+ Provide your OpenAI token via this env var instead of storing it in a file.
84
+
81
85
### ` GPT_CMD_TOKEN_FILE_PATH `
82
86
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 ` .
84
88
85
89
** Default** : ` ~/OPENAI_TOKEN `
86
90
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ def write_file(file_path, content):
37
37
'model' : os .environ .get ('GPT_CMD_MODEL' , 'gpt-4o' ),
38
38
'token_file_path' : os .environ .get (
39
39
'GPT_CMD_TOKEN_FILE_PATH' ,
40
- os .path .join (os .path .expanduser ('~' ), 'OPENAI_TOKEN' ),
40
+ os .path .join (os .path .expanduser ('~' ), 'OPENAI_TOKEN' )
41
41
),
42
42
}
43
43
@@ -79,7 +79,11 @@ def red(text):
79
79
def call_gpt (messages ):
80
80
global OPENAI_CLIENT
81
81
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 )
83
87
84
88
response = OPENAI_CLIENT .chat .completions .create (
85
89
model = OPTIONS ['model' ],
You can’t perform that action at this time.
0 commit comments