Giter VIP home page Giter VIP logo

gpt.vim's Introduction

gpt.vim

(unfinished project, you may encounter problems.)

A plugin for interfacing with general purpose text models, such as openai-chatgpt, localai, etc. Works with vim and neovim.

TODO

  • Implement a localai backend as a demo back
  • Implement proper openai backend
  • Tidy the code and remove wonk
  • Reset function for the sessions
  • (MAYBE) option to change session on the fly to enable multiple contexts for the backend.
  • The Gpt command is quite wonky but seems useful, needs quite bit of fixing & rewriting.

Goals

  • vim & neovim compatible codebase
  • small & simple
  • Heavy lifting should be done by the "backend". Openai is not the only player anymore, local & private general purpose language models exist.
  • simple interface with the backends using pipes.

Requirements

An application that accepts a stdin stream of JSON. Such an application can be found at github.com/zutto/python-chatgpt-vimbackend (WIP) or github.com/mattn/chatgpt. You can also build your own simple piped handling.

Example of the JSON stream:

{"model": "gpt-4", "text":"Hello world", "systemrole":"custom role", "session": "<name of session, optional>"}

Sessions are just different chat sessions, so for completion you could use completion as session name, for chat just chat.

Example of the output stream expected from the application:

{"eof": false, "error": "", "text": ""}
{"eof": false, "error": "", "text": "Hello"}
{"eof": false, "error": "", "text": "!"}
{"eof": false, "error": "", "text": " How"}
{"eof": false, "error": "", "text": " can"}
{"eof": false, "error": "", "text": " I"}
{"eof": false, "error": "", "text": " assist"}
{"eof": false, "error": "", "text": " you"}
{"eof": false, "error": "", "text": " today"}
{"eof": false, "error": "", "text": "?"}
{"eof": false, "error": "", "text": ""}
{"eof": false, "error": "", "text": ""}
{"eof": true, "error": "", "text": ""}

Reset session (cleans the conversations, resets the underlying chatsession, reauthenticates, etc):

{"model": "gpt-4", "text":""", "systemrole":"","session": "<optional>", "reset"="true"}

Settings

  • g:chatgpt_bin - Location of the program this plugin interfaces with. Default value: ['python3.11', '/usr/local/bin/chatgpt']. Example:

    let g:chatgpt_bin = ['python3.11', '/usr/local/bin/chatgpt']
  • g:chatgpt_role - Role to set for the assistant. This is a great place to use augroups to set different roles for different files. The program that interfaces with this plugin should handle updating the role for the assistant as needed. Example:

    let g:chatgpt_role = "You are a helpful commit writer who likes to write easy to understand and compact commit messages."
  • g:chatgpt_role_completion - same as g:chatgpt_role but for completion requests.

Commands

  • Chatgpt - Calls the assistant. Note: You highlight contents with visual mode. The highlighted contents will be sent to the assistant along with your request.

  • Gpt - Calls the assistant with completion session, using the completion role. This may be wonky, as this uses chat session for completion. Mainly made for fun.

  • ChatgptSetRole - Set a custom role on the fly.

Credits

mattn's project was an inspiration for this project. This is basically a personal rewrite of the original project: github.com/mattn/vim-chatgpt. Give mattn all the love.

Demo

normal usage asciicast

Example of using visual mode. asciicast

Gpt command demo asciicast

gpt.vim's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  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.