Skip to content

Proxy copilot api to openai's gpt-4 api

Notifications You must be signed in to change notification settings

llnbe/copilot2chat

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Proxying Copilot API to OpenAI's GPT-4 API

Usage

  1. Start the Server
export GHU_TOKEN=ghu_xxxx; ./copilot2chat
# or 
GHU_TOKEN="ghu_xxx" nohup ./copilot2chat &

Or

sh start.sh start # start the server then input the GHU_TOKEN manually
sh start.sh stop # stop the server
sh start.sh restart # restart the server

Using docker

docker run --name copilot2chat -dit -p 2088:2088 -e GHU_TOKEN=ghu_xxx ynlbq/copilot2chat:latest
  1. Server Usage

The server can be used in the same way as the OpenAI API, but the endpoint URL to use is http://127.0.0.1:2088/v1/chat/completions.

Example:

curl --location 'http://localhost:2088/v1/chat/completions' \
--header 'Content-Type: text/plain' \
--data '{
    "model": "gpt-4",
    "messages": [{
      "role": "user", "content": "write a proxy using rust language"
    }],
    "presence_penalty": 0,
    "stream": false,
    "temperature": 0.8,
    "top_p": 1
  }'

You can also use a third-party client, such as ChatGPT-Web or any other client.

Example:

docker run \
  --name chatgpt-web \
  -d \
  -p 3002:3002 \
  -e AUTH_SECRET_KEY=123456 \
  -e OPENAI_API_KEY='xxxx' \
  -e OPENAI_API_BASE_URL=http://127.0.0.1:2088 \
  -e OPENAI_API_MODEL=gpt-4 \
  chenzhaoyu94/chatgpt-web
  1. Embedding Interface Usage
curl --location 'http://localhost:2088/v1/embeddings' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer gho_xxx' \
--data '{
  "input":["Hi, I am smark"],
  "model":"text-embedding-ada-002"
  }'

How to Obtain a GHU_TOKEN?

Visit this link https://cocopilot.org/copilot/token, log in via GitHub, and then copy the token.

TODO

  • add embedding interface

About

Proxy copilot api to openai's gpt-4 api

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 89.3%
  • Shell 6.9%
  • Dockerfile 3.8%