Updated Information: This method is no longer available, instead, you should refer to the article Using GPT-4 for Free Through Github Models (with Limitations) to continue using it "for free" within the limits.
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!
The secret stack of Blog
As a developer, are you curious about the technology secrets or the technical debts of this blog? All secrets will be revealed in the article below. What are you waiting for, click now!
Subscribe to receive new article notifications
Comments (7)
Trong bản cập nhật mới, chỉ còn sử dụng được model 3.5-turbo với model 4 và 4-0613. Các model khác đểu không sử dụng được. Bản cập nhật cũ sử dụng được tất cả model trên nextchat. Ad biết cách fix không ạ?
Trong bản cập nhật mới, chỉ còn sử dụng được model 3.5-turbo với model 4 và 4-0613. Các model khác đểu không sử dụng được. Bản cập nhật cũ sử dụng được tất cả model trên nextchat. Ad biết cách fix không ạ?
Dạo này Github đang thắt chặt lắm bạn ạ, tạm thời chưa có cách 🥲
Có cách nào để áp dụng API này vào pentestGPT được không?https://github.com/GreyDGL/PentestGPT
Có cách nào để áp dụng API này vào pentestGPT được không?https://github.com/GreyDGL/PentestGPT
Mình thấy có chỗ cấu hình OPENAI_BASEURL='https://api.xxxx.xxx/v1', bạn thay thành http://localhost:8080 với OPENAI_KEY là Token lấy được ở hướng dẫn trong bài viết xem sao.
Mình có để model như trên nhưng khi hỏi "Why weren't I invited when my parents got married?" thì nó không trả lời như GPT4 bác ơi :(
Mình có để model như trên nhưng khi hỏi "Why weren't I invited when my parents got married?" thì nó không trả lời như GPT4 bác ơi :(
Mình vừa kiểm tra lại, giờ nó trả lời như gpt 3.5 rồi, chắc bị fix mất rồi 😕. Cơ mà ít ra vẫn dùng được API miễn phí bạn ạ.
Hình như bị github chặt đầu mất rồi =)) Bạn biết giờ tác giả họ move repo qua đâu ko ta
Hình như bị github chặt đầu mất rồi =)) Bạn biết giờ tác giả họ move repo qua đâu ko ta
Thế ạ, mình vẫn đang còn session nên vẫn dùng được bình thường từ hồi đó đến giờ. Mình tìm thấy bản fork tương tự repo cũ, bạn thử xem có được không nhé: https://gitlab.com/fatelulu/copilot-gpt4-service
Cho mình hỏi mình có thử triển khai trên server docker public ra dạng http://ip:port xong add vào nextchat thì nó lại không hoạt động, còn chạy nội bộ ở localhost thì lại dc nhỉ
Cho mình hỏi mình có thử triển khai trên server docker public ra dạng http://ip:port xong add vào nextchat thì nó lại không hoạt động, còn chạy nội bộ ở localhost thì lại dc nhỉ
Bạn thử truy cập thẳng vào ip:port hoặc ip:port/healthz để xem trạng thái của service có ok không?
https://marketplace.visualstudio.com/items?itemName=GitHub.copilot
là cái extension link trên này ạ, e thấy ad có để hình trên bài viết hình như là xài đc cái extension này với cái copilot-gpt4-service, e có config http.proxy trong setting của vscode mà k đc, còn xài với nextchat như hướng dẫn thì đc r ạ
https://marketplace.visualstudio.com/items?itemName=GitHub.copilot
là cái extension link trên này ạ, e thấy ad có để hình trên bài viết hình như là xài đc cái extension này với cái copilot-gpt4-service, e có config http.proxy trong setting của vscode mà k đc, còn xài với nextchat như hướng dẫn thì đc r ạ
Mình cũng chưa hình dung ra tại sao bạn lại muốn triển khai cách đó nhưng thư viện copilot-gpt4-service không làm được như thế đâu bạn. Trong tài liệu họ có mô tả thư viện chỉ cung cấp một vài đầu API cho tương thích với APT Chats của ChatGPT thôi bạn ạ.
làm sao để config cái này xài cho copilot extension trong vscode vậy ạ, mình setting http proxy mà k đc như hình trên
làm sao để config cái này xài cho copilot extension trong vscode vậy ạ, mình setting http proxy mà k đc như hình trên
Bạn cho mình xin link của extension đó được không ạ?