Hello readers of 2coffee.dev! It's just a few days left until the Year of the Quý Mão officially comes to an end, making way for the new Year of the Giáp Thìn with hopes of more success. This may also be the last article in the old year that I want to dedicate to all of you.
A few days ago, I wrote an article Transforming ChatGPT into an "Expert", in which I mentioned the issue of using the ChatGPT API to be able to use the "expert" because only in the API can we set up the system
role, which helps ChatGPT narrow down the context and provide more accurate answers.
API calls to ChatGPT are paid, depending on the GPT model you are using. Honestly, I have tried every possible way to use the API for free, but all efforts have been in vain.
Yesterday, while "browsing" on Github, I stumbled upon a code repository that allows us to use gpt-4 for free through Github Copilot. Yes, you heard it right, completely free as long as you have a Github Copilot account.
For those who don't know, Github Copilot is an AI assistant developed by Github, which helps us with coding. Personally, I have been using Copilot for over a year and realized that its benefits are worth $10 per month. Yes, you heard it right! I mean, you need to spend $10 per month to use Copilot. If you're interested, I might write an article about Copilot in the future.
Therefore, the prerequisite for using gpt-4 for free is to have Github Copilot. Next, let's see how to leverage gpt-4 from Copilot!
If I remember correctly, Copilot was introduced by Github before the ChatGPT model was widely announced worldwide. When I heard that Copilot was about to be released, I was curious to see what it was. They described Copilot as a real coding assistant, meaning that it would write code with us, based on what we have written or want to write.
After OpenAI announced the GPT model, developers started integrating it into their products to make them smarter and more interactive. Instead of clicking buttons and selecting features, now you can directly communicate with the product through text or voice, and it will immediately understand and help you with that task.
Copilot is no exception, and the Copilot Chat Beta feature was introduced shortly after the release of ChatGPT. Basically, it is integrated into the Editor/IDE, which are code editors, so Copilot Chat has the context of the code you are writing, allowing it to understand more about the context and provide accurate answers to your questions.
Here is an example of source code for the mounted
function of my search page:
async mounted() {
await this.fetchResult();
if (!this.isHasResult) {
this.resetLimitOffset();
await this.fetchOtherResult();
}
process.nextTick(() => {
this.isMounted = true;
setTimeout(() => {
window.lazyload();
}, 1500);
});
},
Let's ask Copilot to explain what mounted
does, and here is the result:
In general, Copilot Chat uses the "GPT model" to answer our questions. Therefore, someone on Github has taken advantage of this to use gpt-4 outside of code. This means that the context of use is no longer limited to code, and you can ask it any question, even turning it into an "expert".
Some may wonder why not chat directly with Copilot Chat? Well, Github has gone a step further and blocked unrelated questions to code, only answering relevant questions.
Do you remember NextChat (ChatGPT Next Web)? After some simple setup, it is now working with gpt-4 from Copilot Chat instead of the OpenAI API key, which means there is no more cost for API calls.
At this point, many readers are probably eager to try it out. That's why I have explained in detail how the copilot-gpt4-service tool is leveraging gpt-4.
copilot-gpt4-service is the mentioned code repository at the beginning of the article. "Convert Github Copilot to ChatGPT" is a very concise description that goes straight to the point, allowing you to create a local gpt-4 server based on your Github Copilot.
However, before using it, there are a few very important notes: only use it for personal purposes, preferably for personal use only, because your Copilot account or even Github account may be banned if abused.
Basically, when you start up this code, it will create a proxy server to ChatGPT. Do you remember the ChatGPT API address? It is https://api.openai.com
. After deploying with copilot-gpt4-service, a local address is created for connection, which is http://localhost:8080
.
If you use Docker, the fastest way to create a server is with a single command:
$ docker run -d \
--name copilot-gpt4-service \
--restart always \
-p 8080:8080 \
aaamoon/copilot-gpt4-service:latest
You will need to take an additional step to obtain the GitHub Copilot Plugin Token, which can be used instead of the OpenAI API key. The process is quite simple, here is an example for MacOS/Linux:
$ python3 <(curl -fsSL https://raw.githubusercontent.com/aaamoon/copilot-gpt4-service/master/shells/get_copilot_token.py)
But before that, you need to install the requests
library for Python:
pip install requests
# or for Python3
pip3 install requests
Then follow the detailed instructions in the returned result.
Finally, go to the configuration settings in NextChat.
Let's try to see if gpt-4 is working!
If you don't believe that the above model is gpt-4, the author proposed a way to verify it by asking a question: "Why weren't I invited when my parents got married?". gpt-3.5 answers with the meaning "They considered you too young at that time, so they didn't invite you.", while gpt-4 answers accurately with "They got married before you were born".
You can also deploy this GPT server on the internet with some security configuration parameters as instructed. However, no matter how you do it, remember to use it for personal purposes only!
Hello, my name is Hoai - a developer who tells stories through writing ✍️ and creating products 🚀. With many years of programming experience, I have contributed to various products that bring value to users at my workplace as well as to myself. My hobbies include reading, writing, and researching... I created this blog with the mission of delivering quality articles to the readers of 2coffee.dev.Follow me through these channels LinkedIn, Facebook, Instagram, Telegram.
Comments (7)