-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
446 add chatgpt integration #447
Conversation
jottinger
commented
Feb 5, 2024
- Adding chatgpt library and access command
- Removing extraneous debug messages
- Adding rate limiting into the chatgpt operation
…the key isn't populated
@Inject | ||
constructor(val javabotConfig: JavabotConfig) { | ||
companion object { | ||
private var limiter: BotRateLimiter? = null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not just initialize here?
} | ||
|
||
fun sendPromptToChatGPT(prompt: String): String? { | ||
return if (javabotConfig.chatGptKey().isNotEmpty() && acquire(javabotConfig)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add the key check to the limiter. no key? no acquire. over the limit? no acquire. maybe make the limiter a singleton injection at that point.
constructor(bot: Javabot, adminDao: AdminDao, var chatGPTDao: ChatGPTDao) : | ||
BotOperation(bot, adminDao) { | ||
override fun handleMessage(event: Message): List<Message> { | ||
val responses = arrayListOf<Message>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mutableListOf()
is more idiomatic, fwiw
val message = event.value | ||
if (message.lowercase(Locale.getDefault()).startsWith("gpt ")) { | ||
val uuid= UUID.randomUUID() | ||
val query = message.substring("gpt ".length).trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.substringAfter("gpt ")
protected lateinit var config: JavabotConfig | ||
|
||
@Test | ||
fun testSwallow() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i had to read the body of this message to reframe this method name in my head. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is failing on formatting checks
* Adding chatgpt library and access command * Removing extraneous debug messages * Adding rate limiting into the chatgpt operation * Adding more explicit logging for chatgpt tests so they don't fail if the key isn't populated * Fixing PR comments * Changing ChatGPTDao to a singleton so the configuration and usage is cleaner * Applying IDEA formatting for chatgpt operation * spotless apply, such win * I don't know what kotlin version isn't being used properly here but screw it, add is enough