Skip to content

Commit

Permalink
chore: formating
Browse files Browse the repository at this point in the history
  • Loading branch information
Robitx committed Jan 20, 2024
1 parent d1eca2e commit 12900cf
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
66 changes: 33 additions & 33 deletions lua/gp/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,36 @@ local config = {
openai_api_key = os.getenv("OPENAI_API_KEY"),
-- api endpoint (you can change this to azure endpoint)
openai_api_endpoint = "https://api.openai.com/v1/chat/completions",
--- openai_api_endpoint = "https://$URL.openai.azure.com/openai/deployments/{{model}}/chat/completions",
--- openai_api_endpoint = "https://$URL.openai.azure.com/openai/deployments/{{model}}/chat/completions",

-- at least one working provider is required
-- provider needs to have endpoint
providers = {
-- secrets can be strings or tables with command and arguments
-- secret = { "cat", "path_to/openai_api_key" },
-- secret = { "bw", "get", "password", "OPENAI_API_KEY" },
-- secret : "sk-...",
-- secret = os.getenv("env_name.."),
openai = {
endpoint = "https://api.openai.com/v1/chat/completions",
secret = os.getenv("OPENAI_API_KEY"),
},
azure = {
-- endpoint = "https://$URL.openai.azure.com/openai/deployments/{{model}}/chat/completions",
-- secret = os.getenv("AZURE_API_KEY"),
},
copilot = {
endpoint = "https://api.githubcopilot.com/chat/completions",
secret = {
"bash",
"-c",
"cat ~/.config/github-copilot/hosts.json | sed -e 's/.*oauth_token...//;s/\".*//'",
},
},
ollama = {
-- endpoint = "http://localhost:8000/v1/chat/completions",
},
},
-- at least one working provider is required
-- provider needs to have endpoint
providers = {
-- secrets can be strings or tables with command and arguments
-- secret = { "cat", "path_to/openai_api_key" },
-- secret = { "bw", "get", "password", "OPENAI_API_KEY" },
-- secret : "sk-...",
-- secret = os.getenv("env_name.."),
openai = {
endpoint = "https://api.openai.com/v1/chat/completions",
secret = os.getenv("OPENAI_API_KEY"),
},
azure = {
-- endpoint = "https://$URL.openai.azure.com/openai/deployments/{{model}}/chat/completions",
-- secret = os.getenv("AZURE_API_KEY"),
},
copilot = {
endpoint = "https://api.githubcopilot.com/chat/completions",
secret = {
"bash",
"-c",
"cat ~/.config/github-copilot/hosts.json | sed -e 's/.*oauth_token...//;s/\".*//'",
},
},
ollama = {
-- endpoint = "http://localhost:8000/v1/chat/completions",
},
},

-- prefix for all commands
cmd_prefix = "Gp",
Expand All @@ -66,7 +66,7 @@ local config = {
-- agents = { { name = "ChatGPT4" }, ... },
agents = {
{
provider = "openai",
provider = "openai",
name = "ChatGPT4",
chat = true,
command = false,
Expand All @@ -84,7 +84,7 @@ local config = {
.. "- Take a deep breath; You've got this!\n",
},
{
provider = "openai",
provider = "openai",
name = "ChatGPT3-5",
chat = true,
command = false,
Expand All @@ -102,7 +102,7 @@ local config = {
.. "- Take a deep breath; You've got this!\n",
},
{
provider = "openai",
provider = "openai",
name = "CodeGPT4",
chat = false,
command = true,
Expand All @@ -114,7 +114,7 @@ local config = {
.. "START AND END YOUR ANSWER WITH:\n\n```",
},
{
provider = "openai",
provider = "openai",
name = "CodeGPT3-5",
chat = false,
command = true,
Expand Down
10 changes: 5 additions & 5 deletions lua/gp/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,10 @@ M.append_selection = function(params, origin_buf, target_buf)
end

function M.refresh_copilot_bearer()
if not M.providers.copilot or not M.providers.copilot.secret then
return
end
local secret = M.providers.copilot.secret
if not M.providers.copilot or not M.providers.copilot.secret then
return
end
local secret = M.providers.copilot.secret

local bearer = M._state.copilot_bearer or {}
if bearer.token and bearer.expires_at and bearer.expires_at > os.time() then
Expand Down Expand Up @@ -897,7 +897,7 @@ function M.resolve_secret(provider)
p.secret = p.secret:gsub("^%s*(.-)%s*$", "%1")
end

M.refresh_copilot_bearer()
M.refresh_copilot_bearer()
end

local secret = M.providers[provider].secret
Expand Down

0 comments on commit 12900cf

Please sign in to comment.