Skip to content

Integrate ChatGPT #809

@Zabuzard

Description

@Zabuzard

Motivation

We want to integrate OpenAI's ChatGPT into TJ-Bot for various things, for example:

  • as slash command for users /chatgpt ...
  • to identify questions asked in #chit_chat (to then tell them to move to #questions instead)
  • to format code (as substitute for our FormatCodeAction)

and possibly more.

Overview

The scope for this feature is to do the first step and add a proof-of-concept into TJ-Bot. That includes:

  • API integration itself (either via an existing Java library or by using the REST API directly)
  • a simple /chatgpt slash command to try it out
  • config entry for the API key
  • feature has to be able to disable itself if:
    • API key is invalid/garbage/empty
    • API responds with errors (for example bc we exceeded the quota)

We already created an account on https://platform.openai.com/ and have an API key for development/testing purposes - which will be made available to whoever implements this.

Model

We want the ChatGPT integration to use a simple and cheap model. For example:

gpt-3.5-turbo | $0.002 / 1K tokens

Using the chat-completion model.

Links

It seems that there is an official Java API: https://github.com/TheoKanning/openai-java

Relevant classes would be here: https://github.com/TheoKanning/openai-java/tree/main/api/src/main/java/com/theokanning/openai/completion/chat

Seems to look something like:

ChatCompletionRequest chatCompletionRequest = ChatCompletionRequest.builder()
  .model("gpt-3.5-turbo")
  .messages(chatMessages)
  .frequencyPenalty(.5)
  .temperature(.7)
  .maxTokens(4000)
  .build();

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions