0xstabby / chatgpt-vim Goto Github PK
View Code? Open in Web Editor NEWUse ChatGPT/OpenAI from inside Vim.
License: MIT License
Use ChatGPT/OpenAI from inside Vim.
License: MIT License
Could you add a command or feature to send the correct answer to chatgpt?
I am studying "figures of speech" and chatgpt gives me lots of wrong answers. Then I call the prompt and say: No. It is wrong (...), but the model does not learn it after asking the same question it gives me another wrong guessing answer...
:(
When running the command gpt
and on the input prompt the phrase has some special character, for instance '
, it breaks the system
call of the plugin.
For example:
This is caused by how the system
call is made here https://github.com/0xStabby/chatgpt-vim/blob/master/plugin/chatgpt.vim#L10
So, we should escape the input string with shellescape
, like this:
let prompt = shellescape(input("Enter chatgpt prompt: "))
as described here: https://github.com/airblade/vim-system-escape/blob/master/README.md
And remove the single quote from system
call:
Previous code:
let output = system("echo '" . prompt . "' | openai complete - -t " . g:openaiToken)
New code:
let output = system("echo " . prompt . " | openai complete - -t " . g:openaiToken)
So we can perform queries with special characters:
PS: Great plugin by the way! :)
I configured openAI API and it works fine in bash but not using the app:
GptFile returns:
Traceback (most recent call last):
File "/usr/local/bin/openai", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/openai_cli/cli.py", line 24, in complete
result = client.generate_response(prompt, model)
File "/usr/local/lib/python3.10/site-packages/openai_cli/client.py", line 36, in generate_response
response.raise_for_status()
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.openai.com/v1/completions```
GptRun returns:
```Run with: Make a doctring for DESeq2
Make: *** No rule to make target `a'. Stop.
Traceback (most recent call last):
File "/usr/local/bin/openai", line 8, in <module>
sys.exit(cli())
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.10/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/openai_cli/cli.py", line 24, in complete
result = client.generate_response(prompt, model)
File "/usr/local/lib/python3.10/site-packages/openai_cli/client.py", line 36, in generate_response
response.raise_for_status()
File "/usr/local/lib/python3.10/site-packages/requests/models.py", line 1021, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.openai.com/v1/completions```
The whole code is concatenated on one line for me. How to fix this?
Could you change the command names to:
gpt
gptFile
gptRun
or
chatGPT
chatGPTfile
chatGPTrun
etc...
The reason is that, it is annoying to uppercase the first letter (g) all the time when using it in (n)vim :(
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.