Giter VIP home page Giter VIP logo

ai.nvim's Introduction

Hi there ๐Ÿ‘‹

I'm a full-stack developer and open source enthusiast, good at front-end development.

  • ๐ŸŒฑ Iโ€™m currently learning cryptocurrency
  • ๐Ÿ’ฌ Follow me on Twitter
  • ๐Ÿ“ซ Ping me if you can find a way

ai.nvim's People

Contributors

gera2ld avatar rakotomandimby avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

ai.nvim's Issues

Send line breaks in the prompt.

When sending multiline prompt to Gemini, the lines are joined without line break.
This is because lines are just joined without appending \n.
Appending \n to each lines would help having a prettier loading_tpl if we include the ${input} in it, and may be, will make the promt more understandable by Gemini.

Gemini requests are failing with a 400 error code

Hi @gera2ld, I've been trying out your plugin with great results until recently, when all the commands I try to send using gemini are returning with a bad request response:

Gemini

Error: Gemini API responded with the status 400

{
  "error": {
    "code": 400,
    "message": "Invalid JSON payload received. Unknown name \"role\" at 'contents[0].parts': Cannot find field.\nInvalid JSON payload received. Unknown name \"role\" at 'contents[1].parts': Cannot find field.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "contents[0].parts",
            "description": "Invalid JSON payload received. Unknown name \"role\" at 'contents[0].parts': Cannot find field."
          },
          {
            "field": "contents[1].parts",
            "description": "Invalid JSON payload received. Unknown name \"role\" at 'contents[1].parts': Cannot find field."
          }
        ]
      }
    ]
  }
}

If it helps, this is the configuration I'm using: https://github.com/davidmh/dot-files/blob/main/nvim/fnl/plugins/gemini.fnl

Use system instruction

Hello @gera2ld,
Gemini Pro 1.5 now supports "system instruction", just like ChatGPT does.
We did not leverage it before, but now we can.
I made it here: natixgroup/code-ai.nvim@ec8f0c1
Unfortunately, my fork has too much divergence with here so that it would be too much hard to merge.
I just put this here if you want to implement it.
Regards.

When selecting text in visual-line: Column index is too high

Error executing Lua callback: .../ai.nvim/lua/ai/init.lua:83: Column index is too high
stack traceback:
        [C]: in function 'nvim_buf_get_text'
        .../ai.nvim/lua/ai/init.lua:83: in function 'getSelectedText'

If selecting in simple visual mode, no problem.
This occurs only in visual-line selecting

[RFC] Add chatGPT and also display its answer

@gera2ld,
I propose to add chatGPT API to the extension.
Implementation is very similar to Gemini's one, this wont be a lot more lines of code.
We would display Gemini and chatGPT in the pop up, like this:

Gemini says:

Gemini answer
Gemini answer
Gemini answer

ChatGPT says:

ChatGPT answer
ChatGPT answer
ChatGPT answer

There will be feature flags: in the config, users will be able to enable or disable one or another.
Note that it is not a perfect thing, but you know is software development, improvements are incremental ;-)

Percent caracter must be escaped

When AI answer contains %, that caracter is silently ignored.

Lets take as exemple this Symfony services.yaml file:

# This is a services.yaml file in a Symfony project.
# In ../.env file, I set MIHAMINA_ID to 1234.
# I want to set the parameter mihamina_id to the value of MIHAMINA_ID.
# Modify the parameters section of this services.yaml file 
# to set the mihamina_id parameter to the value of MIHAMINA_ID.
parameters:

services:
    _defaults:
        autowire: true      
        autoconfigure: true 

    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'

If I prompt AI with the whole file, the displayed result is :

parameters:
    mihamina_id: 'env(MIHAMINA_ID)'

services:
    _defaults:
        autowire: true      
        autoconfigure: true 

    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'

We notice the % are missing.

It should be:

parameters:
    mihamina_id: '%env(MIHAMINA_ID)%'

services:
    _defaults:
        autowire: true      
        autoconfigure: true 

    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'

We must escape the % in the AI response with a kind of :

function query.escapePercent(s)
  return string.gsub(s, "%%", "%%%%")
end

I made it quickly in https://github.com/natixgroup/ai.nvim/commit/0356e9a7ecb19937720d4cd5b8c6239870821fa6 but it very ugly as it needs to be factorized.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.