Trevor Getty | ad49b19 | 2024-10-09 19:13:52 +0100 | [diff] [blame] | 1 | # Hackathon Outcome: Generalising the chat-gpt-plugin |
| 2 | |
| 3 | A requirement has been raised by customers of Gerrit that they would love to have the functionality shown |
| 4 | by the current [chatgpt-code-review-gerrit-plugin](https://github.com/amarula/chatgpt-code-review-gerrit-plugin/), |
| 5 | without the need of sending important Intellectual Property, to a public service. |
| 6 | |
| 7 | As such during the hackathon it was accepted that it would be good to take the current chat-gpt gerrit plugin |
| 8 | and to create a more generic `ai-code-review` plugin that could be used with on-premise, private hosted or public AI services. |
| 9 | |
| 10 | The starting point of this was to create a fork of the current chatgpt plugin, in the gerritcodereview section |
| 11 | under [plugins/ai-code-review](https://gerrit-review.googlesource.com/admin/repos/plugins/ai-code-review). |
| 12 | |
| 13 | All classes that are not chatGPT specific, which is most of them, including the configuration |
| 14 | options where to be generally renamed. |
| 15 | |
| 16 | e.g. gptModel -> aiModel |
| 17 | gptToken -> aiToken |
| 18 | |
| 19 | A great benefit was that ollama has now extended their API with the OpenAPI specification so that they present |
| 20 | an endpoint which allows compatiblity with chatGPT OpenAPI specification for requests and responses. |
| 21 | |
| 22 | ## AIType Support |
| 23 | A new concept has been added to the plugin to allow the specification of different AITypes. |
| 24 | |
| 25 | As such a new configuration option called `aiType` can be specified as follows: |
| 26 | - CHATGPT (default if not specified) |
| 27 | - OLLAMA |
| 28 | - GENERIC |
| 29 | |
| 30 | ### OLLAMA |
| 31 | The ollama AI service, must be run against a model which supports the "tools" and "functions" extensions so that the |
| 32 | response object can be easily specified to return in the correct JSON schema by the prompt. Without this the default |
| 33 | is to return markdown json, which would require much more processing on the client side. |
| 34 | So make sure that the OLLAMA model you choose appears in this list: |
| 35 | [ollama models (tools-filter)](https://ollama.com/search?c=tools) |
| 36 | |
| 37 | ### GENERIC |
| 38 | The generic ai service ability has been added, to more easily test against a potentially new or not yet supported |
| 39 | endpoint. It does so by allowing you to specify the authorization header (key: `aiAuthHeaderName`), along with the |
| 40 | different API endpoint URI (key: `aiChatEndpoint`) which can be used for the code review. |
| 41 | e.g. instead of /v1/chat/completions it might be /api/chat |
| 42 | |
| 43 | |
| 44 | *[Trevor Getty, Software Architect / Cirata](../speakers.md#trevorgetty)* |