Skip to content

Commit 9bc5a26

Browse files
author
Bryley Hayter
committed
fix: Use of old deprecated openai call (#63)
1 parent 33723e1 commit 9bc5a26

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

lua/neoai.lua

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ M.setup = function(options)
3939
end
4040

4141
---Toggles opening and closing neoai window
42-
---@param toggle boolean | nil If true will open GUI and false will close, nil will toggle
43-
---@param prompt string | nil If set then this prompt will be sent to the GUI if toggling on
42+
---@param toggle boolean | nil If true will open GUI and false will close, nil will toggle.
43+
---@param prompt string | nil If set then this prompt will be sent to the GUI if toggling on.
4444
---@return boolean true if opened and false if closed
4545
M.toggle = function(toggle, prompt)
4646
local open = (toggle ~= "" and toggle) or (toggle == "" and not ui.is_open())
@@ -60,7 +60,7 @@ end
6060

6161
---Smart focus, if closed then will open on GUI, if opened and focused then it
6262
---will close GUI and if opened and not focused then it will focus on the GUI.
63-
---@param prompt string The prompt to inject, to inject no prompt just do empty string
63+
---@param prompt string The prompt to inject, to inject no prompt just do empty string.
6464
M.smart_toggle = function(prompt)
6565
local send_args = function()
6666
if not utils.is_empty(prompt) then
@@ -81,30 +81,30 @@ M.smart_toggle = function(prompt)
8181
end
8282

8383
---Toggles the GUI in Context mode
84-
---@param toggle boolean | nil True will force open, False will force close, nil will toggle
85-
---@param prompt string The prompt to inject into the GUI if any (otherwise specify an empty string)
86-
---@param line1 integer | nil The first line number for context range otherwise will use visual selection
87-
---@param line2 integer | nil The second line number for context range otherwise will use visual selection
84+
---@param toggle boolean | nil True will force open, False will force close, nil will toggle.
85+
---@param prompt string The prompt to inject into the GUI if any (otherwise specify an empty string).
86+
---@param line1 integer | nil The first line number for context range otherwise will use visual selection.
87+
---@param line2 integer | nil The second line number for context range otherwise will use visual selection.
8888
---@return boolean True if was opened
8989
M.context_toggle = function (toggle, prompt, line1, line2)
9090
set_context(line1, line2)
9191
return M.toggle(toggle, prompt)
9292
end
9393

9494
---Smart toggles context GUI
95-
---@param prompt string The prompt to inject into the GUI if any (otherwise specify an empty string)
96-
---@param line1 integer | nil The first line number for context range otherwise will use visual selection
97-
---@param line2 integer | nil The second line number for context range otherwise will use visual selection
95+
---@param prompt string The prompt to inject into the GUI if any (otherwise specify an empty string).
96+
---@param line1 integer | nil The first line number for context range otherwise will use visual selection.
97+
---@param line2 integer | nil The second line number for context range otherwise will use visual selection.
9898
M.context_smart_toggle = function (prompt, line1, line2)
9999
set_context(line1, line2)
100100
M.smart_toggle(prompt)
101101
end
102102

103103
---Sends prompt and injects the response straight back into the buffer without
104-
---opening the GUI
105-
---@param prompt string The prompt to send to the AI
106-
---@param strip_function (fun(output: string): string) | nil A function that strips the output
107-
---@param start_line integer | nil The line to start injecting onto (After inserting 2 newlines), nil = current selected line
104+
---opening the GUI.
105+
---@param prompt string The prompt to send to the AI.
106+
---@param strip_function (fun(output: string): string) | nil A function that strips the output.
107+
---@param start_line integer | nil The line to start injecting onto (After inserting 2 newlines), nil = current selected line.
108108
M.inject = function(prompt, strip_function, start_line)
109109
chat.new_chat_history()
110110

@@ -131,10 +131,10 @@ M.inject = function(prompt, strip_function, start_line)
131131
end
132132

133133
---Same as inject except uses a context
134-
---@param prompt string The prompt to send to the AI
135-
---@param strip_function (fun(output: string): string) | nil A function that strips the output
136-
---@param line1 integer | nil The first line num in the range if nil will use '<
137-
---@param line2 integer | nil The second line num in the range if nil will use '>
134+
---@param prompt string The prompt to send to the AI.
135+
---@param strip_function (fun(output: string): string) | nil A function that strips the output.
136+
---@param line1 integer | nil The first line num in the range if nil will use '<.
137+
---@param line2 integer | nil The second line num in the range if nil will use '>.
138138
M.context_inject = function(prompt, strip_function, line1, line2)
139139
line1, line2 = set_context(line1, line2)
140140
M.inject(prompt, strip_function, line2)

lua/neoai/chat/models/openai.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ end
5252
---@param on_stdout_chunk fun(chunk: string) Function to call whenever a stdout chunk occurs
5353
---@param on_complete fun(err?: string, output?: string) Function to call when model has finished
5454
M.send_to_model = function (chat_history, on_stdout_chunk, on_complete)
55-
local api_key = os.getenv(config.options.open_api_key_env)
55+
local api_key = os.getenv(config.options.open_ai.api_key.get())
5656
if not api_key then
5757
on_complete("OpenAI API Key is missing.", nil)
5858
return

0 commit comments

Comments
 (0)