Commit 3230e6f
authored
Use builtin OpenAI plugin. Adds tool support. (#18)
* Use builtin OpenAI plugin. Adds tool support.
The GitHub Copilot completions (`/chat/completions`) API is based on the
OpenAI API regardless of whether the backend model is an OpenAI one or
not. This means we can greatly simplify the GitHub Copilot plugin by
using the builtin OpenAI plugin (`llm.default_plugins.openai_models`)
for everything except for the Copilot device-based authentication.
In addition to the significant simplification and code reduction, one
key benefit of this approach is that we automatically get additional
functionality that is implemented by the openai_models plugin such as
tool calling, async, schema/structured output, etc. We should also get
any future OpenAI plugin functionality automatically (or with minimal
changes).
Tests have been updated to remove most of the completion tests since
this should now be covered by tests in OpenAI plugin itself. Minor
updates were needed to the authentication and the CLI tests to get them
to work simplified code base.
Finally, the fetch_models_data top-level function (wraps
_fetch_models_data) has been memoized so that the model data is cached
after the first call.
* tests: add mock model data to 3 tests.
Make sure the model data comes from the mocked data and not accidentally
from an actual connection to GitHub Copilot. This updates these tests:
test_prompt, test_model_variants, test_options.
* Add Dockerfile and test script for isolated testing.
Add a Dockerfile that packages up the code and tests so that they can be
executed in an isolated environment. This avoids environmental
contamination such as auth config/keys may impact certain code paths
succeed when they otherwise shouldn't.
Example usage:
docker build -t llm-github-copilot-test .
docker run -it llm-github-copilot-test
* Cleanup _GithubCopilot class inheritance.
The _GithubCopilot class was inheriting from openai_models.Chat. The
derived classes are where the actual inheritance/mixin should happen.
The extra inherit seemed to be harmless for now but could cause problems
in the future since it could mix Chat and AsyncChat functionality by
accident.1 parent 5b99b3c commit 3230e6f
File tree
6 files changed
+166
-777
lines changed- tests
6 files changed
+166
-777
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
0 commit comments