chore: run stylua [generated] (#460)

* chore: add stylua

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

* chore: running stylua

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>

---------

Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
This commit is contained in:
Aaron Pham
2024-09-03 04:19:54 -04:00
committed by GitHub
parent 4ad913435c
commit e8c71d931e
28 changed files with 608 additions and 1181 deletions

View File

@@ -1,7 +1,7 @@
local Utils = require("avante.utils")
local Config = require("avante.config")
local Clipboard = require("avante.clipboard")
local P = require("avante.providers")
local Utils = require "avante.utils"
local Config = require "avante.config"
local Clipboard = require "avante.clipboard"
local P = require "avante.providers"
---@class OpenAIChatResponse
---@field id string
@@ -29,9 +29,7 @@ M.api_key_name = "OPENAI_API_KEY"
M.tokenizer_id = "gpt-4o"
---@param opts AvantePromptOptions
M.get_user_message = function(opts)
return opts.user_prompt
end
M.get_user_message = function(opts) return opts.user_prompt end
M.parse_message = function(opts)
---@type string | OpenAIMessage[]
@@ -58,11 +56,11 @@ M.parse_message = function(opts)
end
M.parse_response = function(data_stream, _, opts)
if data_stream:match('"%[DONE%]":') then
if data_stream:match '"%[DONE%]":' then
opts.on_complete(nil)
return
end
if data_stream:match('"delta":') then
if data_stream:match '"delta":' then
---@type OpenAIChatResponse
local json = vim.json.decode(data_stream)
if json.choices and json.choices[1] then
@@ -70,9 +68,7 @@ M.parse_response = function(data_stream, _, opts)
if choice.finish_reason == "stop" then
opts.on_complete(nil)
elseif choice.delta.content then
if choice.delta.content ~= vim.NIL then
opts.on_chunk(choice.delta.content)
end
if choice.delta.content ~= vim.NIL then opts.on_chunk(choice.delta.content) end
end
end
end
@@ -84,9 +80,7 @@ M.parse_curl_args = function(provider, code_opts)
local headers = {
["Content-Type"] = "application/json",
}
if not P.env.is_local("openai") then
headers["Authorization"] = "Bearer " .. provider.parse_api_key()
end
if not P.env.is_local "openai" then headers["Authorization"] = "Bearer " .. provider.parse_api_key() end
return {
url = Utils.trim(base.endpoint, { suffix = "/" }) .. "/chat/completions",