File tree Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Expand file tree Collapse file tree 2 files changed +4
-8
lines changed Original file line number Diff line number Diff line change 13
13
BLUE = "\033 [94m"
14
14
RESET = "\033 [0m"
15
15
16
- openai . api_key = os .getenv ("OPENAI_API_KEY" , "YOUR-OPENAI-KEY-HERE " )
16
+ API_KEY = os .getenv ("OPENAI_API_KEY" , "" )
17
17
18
- if not openai . api_key :
18
+ if not API_KEY :
19
19
# in order to use application, you need to set OPENAI_API_KEY
20
20
# provide example usage
21
21
print (f"{ RED } In order to use this application, you need to set OPENAI_API_KEY environment variable.{ RESET } "
@@ -34,7 +34,6 @@ def call_openai_for_command(user_message, chat_history=None):
34
34
if chat_history is None :
35
35
chat_history = []
36
36
37
- # We add a system message to instruct the model to return only valid shell commands, etc.
38
37
system_msg = {
39
38
"role" : "system" ,
40
39
"content" : (
@@ -44,14 +43,11 @@ def call_openai_for_command(user_message, chat_history=None):
44
43
"No explanations, just the command."
45
44
)
46
45
}
47
- # Then we add the user prompt
48
46
user_msg = {"role" : "user" , "content" : user_message }
49
47
50
- # Construct the full message set
51
48
messages = [system_msg ] + chat_history + [user_msg ]
52
49
53
- # Call OpenAI API
54
- client = openai .OpenAI ()
50
+ client = openai .OpenAI (api_key = API_KEY )
55
51
56
52
try :
57
53
response = client .chat .completions .create (
Original file line number Diff line number Diff line change 1
1
[project ]
2
2
name = " ghost-in-the-shell"
3
- version = " 0.1.4 "
3
+ version = " 0.1.5 "
4
4
description = " CLI with OpenAI integration"
5
5
readme = " README.md"
6
6
requires-python = " >=3.11"
You can’t perform that action at this time.
0 commit comments