Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whisper API endpoint and key. Groq, ollama and other custom providers #220

Open
Himujjal opened this issue Oct 12, 2024 · 1 comment
Open

Comments

@Himujjal
Copy link

Himujjal commented Oct 12, 2024

What is the issue?

  • Unable to set API key for groq whisper (only text supported by plugin)

Error that shows up:

image
Error in text:

Gp.nvim: Whisper query, no text:
'{"error":{"message":"Invalid API Key","type":"invalid_request_error","code":"invalid_api_key"}}\n'

Relevant resources:

My config for reference:

local OPENAI_KEY = env.OPENAI_KEY
local GROQ_KEY = env.GROQ_KEY
local OPENAI_HOST = "https://api.openai.com/v1/chat/completions"
local GROQ_HOST = "https://api.groq.com/openai/v1/chat/completions"
local GROQ_AUDIO = "https://api.groq.com/openai/v1/audio/transcriptions"

local config = {
  providers = {
    openai = {
      disable = false,
      endpoint = OPENAI_HOST,
      secret = OPENAI_KEY,
    },
    groq = {
      disable = false,
      endpoint = GROQ_HOST,
      secret = GROQ_KEY,
    },
  },

  chat_shortcut_respond = { modes = { "n", "i", "v", "x" }, shortcut = "<C-g><cr>" },
  chat_confirm_delete = false,

  -- prefix for all commands
  cmd_prefix = "Gp",

  default_chat_agent = "GroqLLAMA_8B",
  whisper = {
    -- -- TODO: In the future, when gpnvim will support whisper options
    endpoint = GROQ_AUDIO,
    secret = GROQ_KEY,
  },

  agents = {
    {
      provider = "openai",
      name = "ChatGPT4o",
      chat = false,
      command = true,
      -- string with model name or table with model name and parameters
      model = { model = "gpt-4o", temperature = 0.8, top_p = 1 },
      -- system prompt (use this to specify the persona/role of the AI)
      system_prompt = "You are an AI working as a code editor.\n\n"
        .. "Please AVOID COMMENTARY OUTSIDE OF THE SNIPPET RESPONSE.\n"
        .. "START AND END YOUR ANSWER WITH:\n\n```",
    },
    {
      provider = "openai",
      name = "ChatGPT4o-mini",
      chat = true,
      command = true,
      -- string with model name or table with model name and parameters
      model = { model = "gpt-4o-mini", temperature = 0.8, top_p = 1 },
      -- system prompt (use this to specify the persona/role of the AI)
      system_prompt = "You are an AI working as a code editor.\n\n"
        .. "Please AVOID COMMENTARY OUTSIDE OF THE SNIPPET RESPONSE.\n"
        .. "START AND END YOUR ANSWER WITH:\n\n```",
    },
    {
      provider = "groq",
      name = "GroqLLAMA_8B",
      chat = true,
      command = true,
      -- string with model name or table with model name and parameters
      model = { model = "llama-3.1-70b-versatile", temperature = 0.8, top_p = 1 },
      system_prompt = "You are an AI helping the user with code and other tasks\n\n"
        .. "Please AVOID COMMENTARY OUTSIDE OF THE SNIPPET RESPONSE.\n",
    },
    {
      provider = "groq",
      name = "GroqLLAMA_8B",
      chat = true,
      command = true,
      -- string with model name or table with model name and parameters
      model = { model = "llama-3.2-11b-text-preview", temperature = 0.8, top_p = 1 },
      system_prompt = "Given a task or problem, please provide a concise and well-formatted solution or answer.\n\n"
        .. "Please keep your response within a code snippet, and avoid unnecessary commentary.\n",
    },
  },
}
@Himujjal
Copy link
Author

Added a PR: #221 w.r.t. this issue. Please review and merge it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant