Skip to content

Selection context not being sent with lmstudio provider #822

@ruicsh

Description

@ruicsh

hey, I'm using some local models served by lmstudio. But the visual selection isn't being sent to the model. I'm using this config:

providers = {
  lmstudio = {
    embed = "copilot_embeddings",
    prepare_input = function(inputs, opts)
      return {
        model = opts.model,
        messages = inputs,
        stream = true,
      }
    end,
    get_headers = function()
      return {
        ["Content-Type"] = "application/json",
      }
    end,
    get_models = function(headers)
      local utils = require("CopilotChat.utils")
      local response = utils.curl_get("http://localhost:5946/v1/models", { headers = headers })
      if not response or response.status ~= 200 then
        error("Failed to fetch models: " .. tostring(response and response.status))
      end

      local models = {}
      for _, model in ipairs(vim.json.decode(response.body)["data"]) do
        table.insert(models, {
          id = model.id,
          name = model.id,
        })
      end
      return models
    end,
    get_url = function()
      return "http://localhost:5946/v1/chat/completions"
    end,
  },
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions