🧑🏻‍💻Code With Copilot
2024-5-18
| 2025-6-24
字数 0阅读时长 1 分钟
🤖
AI总结:
本项目旨在通过使用自有API服务替代官方的Github Copilot,实现更安全和高效的代码补全和聊天功能。其主要支持VScode和Jetbrains的IDE平台。项目的主要目标是使用自有的API(支持任意模型)代替chat功能,使用gpt-35-turbo-instruct作为代码补全模型,并且支持多种部署方式,包括Docker部署和个人平台搭建。同样的,通过cocopilot该项目还可以实现多人共用一个Github Copilot代码补全功能,并以此避免封号风险。
English Version
This project aims to provide a more secure and efficient code completion and chat functionality by replacing the official GitHub Copilot with a custom API service. It primarily supports the VSCode and JetBrains IDE platforms. The project's main objectives are to use a custom API (supporting arbitrary models) for the chat functionality, employ gpt-35-turbo-instruct as the code completion model, and offer multiple deployment methods, including Docker deployment and personal platform construction. Additionally, cocopilot enables multiple people to share a single GitHub Copilot code completion feature, thereby avoiding account suspension risks.
⚠️
由于Github Copilot已经开放给所有用户使用,此项目已不再维护。

零,项目介绍

本项目主要使用自己拥有模型的API,替代官方API以使用代码chat和补全的,认证使用cocopilot (LinuxDO论坛账户) 不存在封号风险。
该项目的代码补全模型必须是gpt-35-turbo-instruct,或者,根据Copilot新配置,可将补全模型替换为原版的Github Copilot(前提要在Cocopilot订阅),实测速度的确比之前的更快。
该项目对chat模型无要求。
我的配置config.json如下

json

//代码补全模型配置,默认模型gpt35turbo-instruct且无法修改 //如果使用Cocopilot则无需配置此选项 "codex_api_base": "https://api.deepseek.com/beta/v1", "codex_api_key": "sk-***", "code_instruct_model": "deepseek-coder", "codex_api_project": "", "codex_max_tokens": 4093, //聊天模型,无要求,国产海外都可以 "chat_api_base": "https://api.deepseek.com/v1", "chat_api_key": "sk-***", "chat_api_organization": "", "chat_api_project": "", "chat_model_default": "deepseek-coder", "chat_model_map": {} "chat_locale": "zh_CN", //主要用于鉴权认证 //填入地址:https://ip:port/auth_token/v1 "auth_token": ""
JSON

一,项目地址

Github项目地址:
override
linux-doUpdated Sep 10, 2025
源项目链接:Copilot开车平台
项目讨论地址:Linux Do论坛

二,搭载教程(二选一)

1,Docker部署(服务器搭建)

(1)构建docker
①在服务器构建docker
下载代码,并传到服务器中

shell

unzip override-master.zip cd ./override-master docker-compose build override-app
Shell
等待linux-do/override:latest的docker构建
如果需要更新,重新下载代码并在服务器构建docker。
②在github构建docker
neo 提供了在 github 端构建 docker 的流程
fork 仓库后,点击Action,里面有 docker 直接运行就可以了
然后直接从 ghcr.io/GITHUB-USERNAME/override:latest 中 docker pull 就好了
你也可以直接用我的 ghcr.io/es-v/override:latest
如果需要更新,在fork的仓库代码中点击 Sync fork 会自动更新并重新构建docker,此时重新拉取镜像即可。
(2)修改config.json配置

json

{ "bind": "0.0.0.0:8181", "proxy_url": "", "timeout": 600, "codex_api_base": "https://api.deepseek.com/beta/v1", "codex_api_key": "sk-", "codex_api_organization": "", "codex_api_project": "", "codex_max_tokens": 500, "code_instruct_model": "deepseek-coder", "chat_api_base": "https://api.deepseek.com/v1", "chat_api_key": "sk-", "chat_api_organization": "", "chat_api_project": "", "chat_max_tokens": 4096, "chat_model_default": "deepseek-coder", "chat_model_map": {}, "chat_locale": "zh_CN", "auth_token": "" }
JSON
(3)根据docker-compose.yml文件配置路径并运行
docker-compose.yml
linux-do

2,对应系统平台部署(个人平台搭建)

根据不同系统,在仓库地址下载对应的软件包
修改config.json配置

json

{ "bind": "127.0.0.1:8181", "proxy_url": "", "timeout": 600, "codex_api_base": "https://api.deepseek.com/beta/v1", "codex_api_key": "sk-", "codex_api_organization": "", "codex_api_project": "", "codex_max_tokens": 500, "code_instruct_model": "deepseek-coder", "chat_api_base": "https://api.deepseek.com/v1", "chat_api_key": "sk-", "chat_api_organization": "", "chat_api_project": "", "chat_max_tokens": 4096, "chat_model_default": "deepseek-coder", "chat_model_map": {}, "chat_locale": "zh_CN", "auth_token": "" }
JSON
点击软件启动(Windows下为exe文件,访问127.0.0.1:8181有显示即可)

三,Cocopilot(可选)

0,解释

若已经有代码补全模型,且能正常使用可忽略。
Cocopilot本质为多人共享一个Github Copilot权限,且通过服务器中转让GIthub认为只有你一人在使用,从而降低了多人共用被Github识别封锁账户Copilot权限。
此教程为在Github上拥有Github Copilot权限的人将其权限分享出来,若没有权限则直接查看(4,上车(无Github订阅))。

1,前提条件

前提:在Github上拥有Github Copilot权限
notion image

2,开一辆新车

(1)获取ghu_token
Cocopilot中获取token,进入Dashboard 或者NewCar填入上述获得的token
notion image
(2)添加用户
Dashboard查看用户ID:4****************5,填入成员0~9中
(3)更改选项
建议设置
建议设置

3,私人代理(可选,推荐)

代理的本质是将客户端的请求先中转到自有服务端中,再由此发往Github Copilot服务器,其目的是使Github服务端检测到仅有一个IP(自有服务器)使用此服务请求,进而降低了多个IP同时请求Github Copilot服务器造成Github认为你多人共用从而封锁账户权限的风险。
如若不部署此代理,会用始皇的服务器IP自行代理。
(1)个人服务器搭建SOCKS5
填入私人代理格式:socks5://user:passwd@domain.com:port
(2)安装 tinyproxy 配置
安装命令(Ubuntu)

shell

#!/bin/bash sudo apt update sudo apt install -y tinyproxy FILE="/etc/tinyproxy/tinyproxy.conf" ENTRY="Allow 129.146.102.66/32" if grep -q "$ENTRY" "$FILE"; then echo "Entry already exists in $FILE" else echo "$ENTRY" | sudo tee -a "$FILE" > /dev/null echo "Entry added to $FILE" fi sudo sed -i "s/#DisableViaHeader Yes/DisableViaHeader Yes/g" "$FILE" sudo chown -R tinyproxy:tinyproxy /var/log/tinyproxy sudo systemctl restart tinyproxy
Shell
脚本作用是安装 tinyproxy 配置 ip 白名单然后启动。 配置后放行8888端口。
填入私人代理格式:http://ip:port

4,上车(无Github订阅)

Dashboard查看用户ID:4****************5,让别人将你的用户ID填入上述的成员0~9中,此时进入Cocopilot会看见如下信息,则表明你能够使用Cocopilot。

plain

我所在车: 车名: Cocopilot1 开车人: 4**********************************d 订阅类型: free_educational 订阅状态: 正常 开始时间: 不限 结束时间: 不限 完全代理: 是 禁用对话: 否 车辆状态: 车有效
Plain text

四,使用教程:

1,前提条件

LinuxDo论坛账户:用于过认证

2,VSCode配置

  1. 下载Github Copilot插件
  1. 右键插件 → 扩展设置 → 在settings.json中编辑
  1. 代码粘贴如仓库所示。

json

"github.copilot.advanced": { //代码补全使用自有模型配置 "debug.overrideProxyUrl": "http://127.0.0.1:8181", //代码补全使用Github Copilot模型配置 "debug.overrideProxyUrl": "https://cocopilot.org", //代码补全使用自有模型配置 "debug.overrideCAPIUrl": "http://127.0.0.1:8181"/v1, //代码补全使用Github Copilot模型配置 "debug.overrideCAPIUrl": "https://cocopilot.org/v1", //chat功能使用自自有模型配置 "debug.chatOverrideProxyUrl": "http://127.0.0.1:8181/v1/chat/completions", "authProvider": "github-enterprise" }, "github-enterprise.uri": "https://cocopilot.org", //开启clash verge后设置代理,否则会出现网络问题 "http.proxy": "http://127.0.0.1:7897/",
JSON

3,JetBrains系列使用Cocopilot配置

  1. 下载支持Github Copilot版本的JetBrains软件
  1. 在Jetbrains软件的 Settings -> Plugins -> 搜索并安装 GitHub Copilot(或通过浏览器下载GitHub Copilot插件
  1. 在 Settings -> Languages & Frameworks -> GitHub Copilot -> Authentication Provider: 填入cocopilot.org
    1. 图片来源:Cocopilot
      图片来源:Cocopilot
  1. (1)通过Github Copilot使用Cocopilot
①登录Cocopilot,确定自己拥有Github Copilot权限。同时在页面底部选择手动 Token 之后的内容 ccu_************************YpMlzqqC复制该Token。

plain

我所在车: 车名: Cocopilot1 开车人: 4**********************************c5 订阅类型: free_educational 订阅状态: 正常 开始时间: 不限 结束时间: 不限 完全代理: 是 禁用对话: 否 车辆状态: 车有效
Plain text
②下载该文件,解压后,如果使用Linux或Mac系统,选择cocopilot.sh文件,如果使用Windows系统,选择cocopilot.bat 文件进行修改。将底部的 oauth_token 的参数ghu_ThisIsARealFreeCopilotKeyByCoCopilot 修改为上述的手动 Token ,即ccu_************************YpMlzqqC随后保存并关闭,以管理员身份运行该脚本。
(2)通过自定义API使用Cocopilot
未确认配置,此教程暂时无法使用,请参考其他教程
①在ja-netfilter/plugin-env下载发行版本,放入 plugins-jetbrains 文件夹。然后在 config-jetbrains 目录新建 env.conf 文件。
②以下是一个替代 CoCopilot 脚本的 env.conf 配置:

javascript

[ENV] PREFIX,AGENT_DEBUG_OVERRIDE_CAPI_URL=https://cocopilot.org PREFIX,AGENT_DEBUG_OVERRIDE_PROXY_URL=https://cocopilot.org PREFIX,GITHUB_COPILOT_OVERRIDE_CAPI_URL=https://cocopilot.org PREFIX,GITHUB_COPILOT_OVERRIDE_PROXY_URL=https://cocopilot.org
JavaScript

五,部署成功日志(以VSCode为例)

1,Github Copilot Chat 日志

plain

2024-05-18T15:52:14.332Z [INFO] [chat] copilot token chat_enabled: true 2024-05-18T15:52:14.332Z [INFO] [auth] Got Copilot token for user 2024-05-18T16:06:02.704Z [INFO] [chat fetch] engine http://127.0.0.1:8181/v1/chat 2024-05-18T16:06:02.704Z [INFO] [chat fetch] modelMaxTokenWindow 4096 2024-05-18T16:06:02.704Z [INFO] [chat fetch] chat model gpt-4 2024-05-18T16:06:05.355Z [INFO] [chat fetch] request.response: [http://127.0.0.1:8181/v1/chat/completions], took 2650 ms 2024-05-18T16:06:09.964Z [INFO] [streamMessages] message 0 returned. finish reason: [stop] 2024-05-18T16:06:09.966Z [INFO] [streamChoices] request done: headerRequestId: [] model deployment ID: [] 2024-05-18T16:06:11.435Z [INFO] [chat fetch] engine http://127.0.0.1:8181/v1/chat 2024-05-18T16:06:11.435Z [INFO] [chat fetch] modelMaxTokenWindow 8192 2024-05-18T16:06:11.435Z [INFO] [chat fetch] chat model gpt-3.5 2024-05-18T16:06:11.772Z [INFO] [chat fetch] request.response: [http://127.0.0.1:8181/v1/chat/completions], took 337 ms 2024-05-18T16:06:11.773Z [INFO] [chat fetch] Request ID for failed request: ,8246bc12-f2bc-4185-8282-76632f2a6df2
Plain text

2,Github Copilot 日志(自有模型)

plain

2024-05-19 00:13:09.943 [info] [fetcher] Using Helix fetcher, Electron fetcher is not available. 2024-05-19 00:13:09.943 [info] [code-referencing] Public code references are enabled. 2024-05-19 00:13:09.944 [info] [auth] Sucessfully authenticated 2024-05-19 00:13:32.823 [info] [fetchCompletions] request.response: [http://127.0.0.1:8181/v1/engines/copilot-codex/completions] took 3015 ms 2024-05-19 00:13:32.826 [info] [streamChoices] solution 0 returned. finish reason: [stop] 2024-05-19 00:13:32.827 [info] [streamChoices] request done: headerRequestId: [] model deployment ID: []
Plain text

3,Github Copilot 日志(Copilot配置车)

plain

2024-05-21 22:07:29.149 [info] [streamChoices] solution 0 returned. finish reason: [stop] 2024-05-21 22:07:29.153 [info] [streamChoices] request done: headerRequestId: [] model deployment ID: [] 2024-05-21 22:07:30.869 [info] [code-referencing] Calling Match 2024-05-21 22:23:09.872 [info] [fetcher] Using Helix fetcher, Electron fetcher is not available. 2024-05-21 22:23:09.872 [info] [code-referencing] Public code references are enabled. 2024-05-21 22:07:04.967 [info] [streamChoices] solution 0 returned. finish reason: [stop] 2024-05-21 22:07:04.976 [info] [streamChoices] request done: headerRequestId: [] model deployment ID: [] 2024-05-21 22:07:14.563 [info] [fetchCompletions] request.response: [https://cocopilot.org/v1/engines/copilot-codex/completions] took 2424 ms
Plain text
查看copilot插件的日志,与上述进行对比。注意路径问题,如果路径不对可以在插件中修改。

参考教程

(PS:本质还是始皇的教程,我只是将各个内容结合了一下行个方便。)
  • 工具
  • AI
  • SMTP on Serv00AI Search
    Loading...