Slight chat/play refactor, add roll command
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use log::{error, debug, warn};
|
||||
use log::{error, trace, warn};
|
||||
|
||||
use serenity::model::Permissions;
|
||||
use serenity::model::channel::Message;
|
||||
@@ -9,7 +9,7 @@ use crate::bot::messages::{QueryFilters, QueryMessage};
|
||||
use crate::bot::oai::{ChatCompletionMessage, ChatCompletionRequest, GPTRole, OAI};
|
||||
|
||||
pub async fn generate_response(ctx: &Context, msg: &Message, oai: &OAI) {
|
||||
debug!("Generating response for message: {}", msg.content);
|
||||
trace!("Generating response for message: {}", msg.content);
|
||||
|
||||
let guild_id = msg.guild_id.unwrap();
|
||||
let channel_id = msg.channel_id;
|
||||
@@ -90,7 +90,7 @@ pub async fn generate_response(ctx: &Context, msg: &Message, oai: &OAI) {
|
||||
// Get the OAI response and store message/response into the database
|
||||
let response = match oai.chat_completion(request).await {
|
||||
Ok(r) => {
|
||||
debug!("Processing response received from OpenAI");
|
||||
trace!("Processing response received from OpenAI");
|
||||
if !r.choices.is_empty() {
|
||||
let res = r.choices[0].message.content.clone();
|
||||
if let Err(err) = QueryMessage::insert(QueryMessage {
|
||||
@@ -118,7 +118,7 @@ pub async fn generate_response(ctx: &Context, msg: &Message, oai: &OAI) {
|
||||
"There was an error processing your message. Please try again later.".to_string()
|
||||
}
|
||||
};
|
||||
debug!("Writing response: \"{}\"", response);
|
||||
trace!("Writing response: \"{}\"", response);
|
||||
|
||||
typing.stop();
|
||||
if let Err(why) = response_channel.say(&ctx.http, response).await {
|
||||
@@ -142,7 +142,6 @@ pub async fn generate_response(ctx: &Context, msg: &Message, oai: &OAI) {
|
||||
}
|
||||
|
||||
async fn generate_thread_name(oai: &OAI, s: &str, max_chars: usize) -> String {
|
||||
println!("HERE: {}", s);
|
||||
let message = ChatCompletionMessage {
|
||||
role: GPTRole::User,
|
||||
content: format!("---\n{}\n---\nSummarize the message above into a concise Discord thread title", s)
|
||||
|
||||
Reference in New Issue
Block a user