tzachar / cmp-ai

MIT License
196 stars 36 forks source link

OpenAI model not working #6

Closed henryoliver closed 1 year ago

henryoliver commented 1 year ago

Hi there, I'm getting the "Completion started" notification in each keystroke, but the suggestion does not show up at all.

All other completion cmp plugins are working fine, even tabnine.

My OPENAI_API_KEY key is set and working.

Please let me know what is missing:

        local cmp_ai = require("cmp_ai.config")
        local ai_compare = require("cmp_ai.compare")

...
        -- Cmp AI config
        cmp_ai:setup({
            max_lines = 1000,
            provider = "OpenAI",
            model = "gpt-4",
            notify = true,
            run_on_every_keystroke = true,
            ignored_file_types = {
                -- default is not to ignore
                -- uncomment to ignore in lua:
                -- lua = true
            },
        })

            sources = cmp.config.sources({
                { name = "cmp_ai" },
...

                    -- Set source name
                    vim_item.menu = ({
                        cmp_ai = "[CMP_AI ]",
....
                    -- AI custom symbol and type
                    if entry.source.name == ("cmp_tabnine" or "cmp_ai") then
                        local detail = (entry.completion_item.labelDetails or {}).detail

                        vim_item.kind = ""

                        if detail and detail:find(".*%%.*") then
                            vim_item.kind = vim_item.kind .. " " .. detail
                        end

                        if (entry.completion_item.data or {}).multiline then
                            vim_item.menu = "[AI - ML]"
                        end
                    end

                    local maxwidth = 80
                    vim_item.abbr = string.sub(vim_item.abbr, 1, maxwidth)

                    return vim_item
                end,
                ....

            sorting = {
                priority_weight = 2,
                comparators = {
                    ai_compare,
tzachar commented 1 year ago

The apis are very slow. Personally, I am not adding this to the regular completion path, rather binding it to a specific keystroke (). Check the Readme: https://github.com/tzachar/cmp-ai#dedicated-cmp-keybindings