minosvasilias / godot-copilot

AI-assisted development for the Godot engine.
MIT License
201 stars 13 forks source link
ai copilot godot

Godot Copilot

Godot Copilot logo and shader designed and written by GPT-4

AI-assisted development for the Godot engine.

Compatible with 4.x and 3.x.

What does this do?

Godot Copilot uses OpenAI APIs (other models/providers may be supported in the future) to retrieve AI-generated code completions.

After installing the plugin, simply press the selected keyboard shortcut to generate code in the code editor at the current caret position, directly within the engine!

How do i install this?

Afterwards, enable the addon in the project settings, and enter your OpenAI API key in the Copilot tab located on the right-hand dock.

Use the selected keyboard shortcut within the code editor to request completions.

How much will this cost me?

Godot Copilot currently supports three different models:

Therefore, turbo is cheapest.

For each request, Copilot will attempt to send your entire current script to the model, up to a maximum length, after which the code will be trimmed.

Being a good engineer that doesn't work in 5k-line spaghetti-scripts pays. Literally!

Comprehensive example data on cost per month/day/hour for each model is appreciated! Please open an issue if you are willing to contribute!

Completion interface? Chat interface?

OpenAI uses different API interfaces for different models.

How well does this work?

GDScript is underrepresented in OpenAI's training data!

Do not expect performance matching that of popular languages such as Python or Javascript. This will not replace you... yet!

It is however perfectly capable of writing useful functions, generating pre-populated objects, and completing all the tedious code you don't want to write yourself.

One significant complication affecting performance is the changes introduced in Godot 4.0. The training data of all supported models largely cuts off in September 2021. This means some of the new syntax was included, some not, and the models know a combination of GDScript 1 and 2.

Godot Copilot automatically injects zero-shot explanations of some of the most important GDScript changes in the prompts! This helps model performance quite significantly, but doesn't resolve all issues. Expect some varying performance when it comes to concepts such as Callable or hallucinated Python methods.

Why no autocomplete?

A couple reasons:

Testing has shown targeted completions on shortcut presses to be much more reliable and efficient.

Autocomplete may be an optional setting in the future if above issues can be sufficiently addressed.

Does this share sensitive data?

Your code will be sent to OpenAIs API endpoints. Since March 1st 2023, OpenAI states it will no longer use data sent via their APIs in future training runs.

Does this work with 3.x?

Yes! Please switch to the 3.x branch for the appropriate version of this addon.

Why should i use this over Github Copilot?

Do use Github Copilot when suitable!

This does offer code completions directly within the Godot editor, which is the main usecase.

When using OpenAIs APIs, Godot Copilot may also be more expensive than GitHub Copilot, depending on your model choice and usage.

Can i use my existing GitHub Copilot subscription?

Yes, this is now supported. (for the 4.x version of this plugin only, for now)

However, use at your own risk!

GitHub Copilot usage outside of the indended scope may lead to account suspensions. This plugin makes sure to mirror authentic VsCode plugin requests, including session handling and authentication, but please be aware of the GitHub Copilot terms of service before using.

To extract your existing GitHub Copilot token for use with Godot Copilot, please follow the instructions in the copilot-gpt4-service repo here: Obtaining Copilot Token.

You may then select the gpt-4-github-copilot model after installing this plugin.

Can this do anything other than code completion?

I have run experiments with further automation capabilities, such as populating and modifying the active scene. Such features may be added in the future.

Other interesting usecases may be using embeddings to more accurately model cross-script functionality for your codebase, or using generative models for texture, sprite or 3D asset creation.

Please feel free to open issues requesting features or changes.