Giter Club home page Giter Club logo

ai-review.vim's Introduction

ai-review.vim

The ai-review.vim plugin harnesses the power of OpenAI's API for conducting code reviews and more.

Dependencies

This plugin relies on denops.vim and ddu.vim.

Instead of ddu.vim, you can use nui.nvim which enables you to use functionality beyond history management with Fuzzy Finder.

Demo

ai-review-demo.mp4

How to Use

First, set your OPENAI_API_KEY environment variable. If you want to use it on a selected range, please set ddu as follows.

call ddu#custom#patch_global({
  \ 'kindOptions': {
  \   'ai-review-request': {
  \     'defaultAction': 'open',
  \   },
  \   'ai-review-log': {
  \     'defaultAction': 'resume',
  \   },
  \ }
  \ })

Then, activate the plugin by executing :AiReview or :'<,'>AiReview.

By default, it is set to use the gpt-3.5-turbo model. If you want to use GPT-4, please call ai_review#config with gpt-4.

call ai_review#config({ 'chat_gpt': { 'model': 'gpt-4' } })

If you want to use with Azure OpenAI Service, you'll need to include an endpoint and an api-version:

call ai_review#config({ 'chat_gpt': { 'model': 'gpt-4', 'azure': { 'use': v:true, 'url': 'https://YOUR_RESOURCE_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT_NAME', 'api_version': '2023-07-01-preview' } } })

If you want to use nui.nvim instead of ddu, please set as follows:

call ai_review#config({ 'backend': 'nui' })

To get the default value of the setting, please execute ai_review#get_default_config.

Request preset

The request preset is defined as a list of objects of the following type (expressed in TypeScript).

The request and preview can be defined with Vim script's funcref or Lua function, and you can modify it by setting the list of objects to call ai_review#config({ 'chat_gpt': { 'requests': [] } }).

(Ref: https://github.com/yuki-yano/ai-review.vim/blob/main/autoload/ai_review/open_ai/request.vim)

type Request = {
  title: string;
  request: (opts: {
    file_type: string;
    first_line: number;
    last_line: number;
    bufnr: number;
  }) => {
    context: string;
    text: string;
    code: string;
    file_type: string;
  };
  preview: (opts: {
    file_type: string;
    first_line: number;
    last_line: number;
    bufnr: number;
  }) => string;
};

History Management

The commands :AiReviewSave and :AiReviewLoad allow you to easily save and retrieve your chat history.

The log save location is set to call ai_review#config. The default is ~/.cache/vim/ai-review.

call ai_review#config({ 'log_dir': 'path/to/dir' })

Additionally, you can display the history using ddu with the :AiReviewLog command.

Requirements

This plugin requires

Optional

When using nui.nvim instead of ddu.vim:

Acknowledgements

Special thanks to butler.vim contributors.

ai-review.vim's People

Contributors

yuki-yano avatar kkb0318 avatar ryu-ichiroh avatar

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.