codercooke / vim-chatgpt Goto Github PK
View Code? Open in Web Editor NEWVim Plugin For ChatGPT
License: The Unlicense
Vim Plugin For ChatGPT
License: The Unlicense
Temperature value seems high in default which is 0.7
Maybe this can be changed optionally (i.e. from vimrc -> let g:chat_gpt_temperature)
Thank you for the wonderful software.
By the way, I would like to converse with ChatGPT in Japanese (my mother tongue), but in the source code that's being created, I would like the comments to always be written in English.
I've considered adding the following:
diff --git a/chatgpt.vim b/chatgpt.vim
index 5cbc81b..b721474 100755
--- a/chatgpt.vim
+++ b/chatgpt.vim
@@ -45,6 +45,10 @@ if !exists("g:chat_gpt_lang")
let g:chat_gpt_lang = ''
endif
+if !exists("g:chat_gpt_comment_lang")
+ let g:chat_gpt_comment_lang = ''
+endif
+
" Function to show ChatGPT responses in a new buffer
function! DisplayChatGPTResponse(response, finish_reason, chat_gpt_session_id)
call cursor('$', 1)
@@ -97,7 +101,9 @@ def chat_gpt(prompt):
model = str(vim.eval('g:chat_gpt_model'))
temperature = float(vim.eval('g:chat_gpt_temperature'))
lang = str(vim.eval('g:chat_gpt_lang'))
+ comment_lang = str(vim.eval('g:chat_gpt_comment_lang'))
resp = lang and f" And respond in {lang}." or ""
+ resp += comment_lang and f" But code comments must be in {comment_lang} always." or ""
systemCtx = {"role": "system", "content": f"You are a helpful expert programmer we are working together to solve complex coding challenges, and I need your help. Please make sure to wrap all code blocks in ``` annotate the programming language you are using. {resp}"}
try:
I've posted this as it might be useful to others.
Regards,
Atsushi
I want to be able to create custom prompts and modify the existing prompts for my use cases. Currently I have to edit the plugins source code in order to change these, but custom prompts and commands could be defined in the .vimrc
Hi,
Thanks for this nice plug-in!
It's not very clear to me how one can continue asking questions based on the last output?
I've been visually selecting the last output from the chat and enter the prompt in the command line - Is there a better way ?
Thanks!
It would be useful if there would be a way to specify custom prompts without the hardcoded "Given the..." sentence in the end. For example, a prompt like this would work better without it:
let g:chat_gpt_custom_prompts = {'grammar': 'Suggest ways to improve the grammar of this sentence. Style: accessible yet academic.'}
I'm running vim on mac and install openai with pip. If I open python3 and import openai, the module is correctly imported.
However, vim fails when importing openai:
Error: openai module not found. Please install with Pip and ensure equality of the versions given by :!python3 -V, and :python3 import sys; print(sys.version) Error detected while processing /Users/user/.vim/bundle/vim-chatgpt/plugin/chatgpt.vim: line 20: Traceback (most recent call last): File "<string>", line 6, in <module> ModuleNotFoundError: No module named 'openai' line 34: Traceback (most recent call last): File "<string>", line 1, in <module> NameError: name 'openai' is not defined. Did you mean: 'open'?
Is there any constraint to run the plugin with conda environment?
I'm a tad new to vim and have been using neovim to get this working. I ran this through my plugin manager and I have my leader key with p+v set to open netrw. For some reason when I attempt to do this, it says that the command for netrw no longer exists. I'm not sure what about this plugin causes it to break, but after I remove it netrw works fine again.
You can also install this plugin via the Vim-Plugged plugin manager
call plug#begin('~/.vim/plugged')
" Vim-ChatGPT
Plug 'CoderCookE/vim-chatgpt'
call plug#end()
When displaying the prompt, the lines are too long, what would you say of adding a text wrap, something like
setlocal buftype=nofile bufhidden=hide noswapfile nobuflisted wrap nolist linebreak breakat=\
in DisplayChatGPTResponse
I got following errors at vim startup
Error from .../.vim/pack/enabled/start/vim-chatgpt/plugin/chatgpt.vim :
line 21 :
Traceback (most recent call last):
File "<string>", line 2, in <module>
vim.error: Vim:E121: Variable not defined : g:chatgpt_venv_path
line 26 :
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'os' is not defined
line 21 :
Traceback (most recent call last):
File "<string>", line 2, in <module>
vim.error: Vim:E121: Variable not defined : g:chatgpt_venv_path
line 26 :
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'os' is not defined
I did the export CHAT_GPT_KEY
in my .zshrc
Hi, I have followed the instructions to install the plugin on my macOS. I have copied the chatgpt.vim
file into
~/.vim/plugged/vim-chatgpt
MacBook-Air@Momo: cs plugin/
total 8
-rw-r--r-- 1 Momo 5101 Apr 7 14:03 chatgpt.vim
Also, I have edited my .vimrc
file including the path for openai
executable
MacBook-Air@Momo: pip3 show openai
Name: openai
Version: 0.27.4
Summary: Python client library for the OpenAI API
Home-page: https://github.com/openai/openai-python
Author: OpenAI
Author-email: [email protected]
License: None
Location: /usr/local/lib/python3.9/site-packages
Requires: aiohttp, requests, tqdm
Required-by:
but when I run nvim
to ask something I get the error
E492: Not an editor command: Ask 'how to split the screen in vim'
It seems I don't have activated this plugin. However, I have in my .vimrc
filetype plugin indent on
so I don't know what I am losing
Hi, I absolutely love this plugin and use it almost every day in my work.
I've noticed though that when using a persistent session, the resulting text is not valid markdown due to the user and assistant syntax, which causes my syntax highlighting to break.
Is there some reason for using these symbols? If prefixing both with e.g. >
it would become valid Markdown.
Anyone know why I am getting this
I have python installed:
(base) ➜ ~ python
Python 3.10.9 | packaged by conda-forge | (main, Feb 2 2023, 20:26:08) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
and python3
(base) ➜ ~ python3
Python 3.10.9 | packaged by conda-forge | (main, Feb 2 2023, 20:26:08) [Clang 14.0.6 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Both used from
(base) ➜ ~ which python3
/Users/tag/miniforge3/bin/python3
Thanks
Thanks for this great code. I think it would be great to upgrade code to support latest openai
package. By doing so, we can not only support official openai api, but also auzure gpt api and local gpt-like api with vllm.
I have dev some code to support this on my fork repo. Any suggestions to contribute to this repo?
Changing the key inside vimrc with let g:openai_api_key='your-api-key-here'
doesn't udpate the key.
The old key is persistent even if the plugin is re-installed.
The only way to update the key is to exit vim and change the ENV variable from the terminal.
Every time I trigger the plugin, the original buffer that contained my cursor scrolls to the very bottom, and my cursor ends up being in the end.
In general, I typically utilize a 4K context. However, there are cases where I require a longer context of 16 tokens. In such cases, I have two options:
The system provides an error message indicating the context limit (e.g., "Error: This model's maximum context length is 4097 tokens. However, you requested X tokens (Y in the messages, Z in the completion). Please reduce the length of the messages or completion.").
Based on this message or through automated calculation, the system can select the alternative model automatically.
When I run :Ask hello
I see this in my buffer:
^A>>>User:^A
hello
^A>>>Assistant:^A
Hello! How can I assist you today?
Any idea what's causing these ^A
control characters to appear and what their purpose is? I'm using neovim (the plugin works great otherwise, I'm not sure if the intention was to support neovim).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.