Is there a tool like Github Copilot which has a (Python 3) API?

380 views Asked by At

Tools like Github Copilot can generate/complete code and/or comments while typing within an IDE. It looks like they are limited to this use case.

However, I actually want to something similar to the following in any Python program:

import coolcopilotpackage as cop

comment = cop.generate("print('Hello World!') #")

print(comment)

The output should be looking like: Prints the line 'Hello World!', completing the line of code that I started within the string given to cop.generate.

Is there any way of doing that?

2

There are 2 answers

2
kalexoudis On

If I understand correctly you are looking for an API giving you access to a generative AI. Maybe take a look at OpenAI's API, they have a lot of models you can use in your own projects to build your own tools.

0
B00TK1D On

I wrote an API that is able to do almost exactly what you're asking for: https://github.com/B00TK1D/copilot-api. It works as an HTTP API proxy instead of a native python module, but would be easily adaptable if you want.