B00TK1D / copilot-api

GitHub Copilot API
MIT License
123 stars 21 forks source link

does this still work? #1

Closed darkpandarts closed 6 months ago

darkpandarts commented 6 months ago

Hi,

Does this still work? Tried running it after authenticating successfully, but I'm getting empty replies. Do I need to have neovim & vim copilot plugin installed?

Cheers!

B00TK1D commented 6 months ago

@darkpandarts Unfortunately, Github just changed their API endpoints from https://copilot-proxy.githubusercontent.com to https://api.githubcopilot.com (source: https://github.blog/changelog/2024-01-18-copilot-january-18th-update/). I did some initial triage to see if I could easily migrate, but it appears their URL scheme also changed, so I will need to do more in-depth reverse engineering to match it. I'm a bit busy this week, but hopefully next week I can get it back up and working. (You don't need neovim or the copilot extension installed for this API to work by the way.)

B00TK1D commented 6 months ago

@darkpandarts It appears that Github actually hasn't fully migrated yet, and their old endpoints still work, so this still works for me. As per the readme, you do have to send POST requests with the prompt field set in order to receive responses. Are you still having issues?

darkpandarts commented 6 months ago

TBH, i think it's probably my syntax

darkpandarts commented 6 months ago

sorry man. it was me. got it working now.

import json

import requests

query_dict = {
    "prompt": "# write a fizzbuzz function\n\n",
    "language": "python",
}

print(json.dumps(query_dict))

resp = requests.post("http://localhost:6989/api", data=json.dumps(query_dict))
print("status_code:", resp.status_code)
print("json:", resp._content)

for _ in range(5):
    query_dict["prompt"] += resp._content.decode("utf-8")
    print("\nquery_dict:", query_dict)
    resp = requests.post("http://localhost:6989/api", data=json.dumps(query_dict))
    print("resp:", resp._content)

Do we terminate the adding to prompt loop when we get an empty response? Or is there another condition you check for?

Thanks very much for sorting this btw! :heart: