add option to show debug messages for AI chat

This commit is contained in:
Madpeter 2024-10-01 19:29:52 +01:00
parent 2d13cca7b3
commit 28a743ebc0
3 changed files with 16 additions and 3 deletions

View file

@ -117,6 +117,7 @@ ENV basic_Username='' \
chatgpt_ChatHistoryMessages='5' \ chatgpt_ChatHistoryMessages='5' \
chatgpt_ChatPrompt='respond as if you are a horse that knows its going to the glue factory and you are upset about this fact' \ chatgpt_ChatPrompt='respond as if you are a horse that knows its going to the glue factory and you are upset about this fact' \
chatgpt_Provider='openai' \ chatgpt_Provider='openai' \
chatgtp_ShowDebug='false' \
onevent_Enabled='false' \ onevent_Enabled='false' \
onevent_Count=0 \ onevent_Count=0 \
chatgpt_ChatHistoryTimeout='15' \ chatgpt_ChatHistoryTimeout='15' \

View file

@ -25,9 +25,15 @@ namespace SecondBotEvents.Config
settings.Add("ChatHistoryMessages"); settings.Add("ChatHistoryMessages");
settings.Add("ChatPrompt"); settings.Add("ChatPrompt");
settings.Add("ChatHistoryTimeout"); settings.Add("ChatHistoryTimeout");
settings.Add("ShowDebug");
settings.Add("Provider"); settings.Add("Provider");
} }
public bool GetShowDebug()
{
return ReadSettingAsBool("ShowDebug", false);
}
public int GetChatHistoryTimeout() public int GetChatHistoryTimeout()
{ {
return ReadSettingAsInt("ChatHistoryTimeout", 15); return ReadSettingAsInt("ChatHistoryTimeout", 15);

View file

@ -309,9 +309,12 @@ namespace SecondBotEvents.Services
else if (role == "assistant") messages.Add(ChatMessage.FromAssistant(thismessage)); else if (role == "assistant") messages.Add(ChatMessage.FromAssistant(thismessage));
} }
} }
catch catch (Exception ex)
{ {
//LogFormater.Warn("error building AI request:" + ex.Message); if (myConfig.GetShowDebug() == true)
{
LogFormater.Warn("error building AI request:" + ex.Message);
}
return; return;
} }
} }
@ -413,7 +416,10 @@ namespace SecondBotEvents.Services
} }
catch (Exception ex) catch (Exception ex)
{ {
LogFormater.Warn("An error occurred: " + ex.Message); if (myConfig.GetShowDebug() == true)
{
LogFormater.Warn("An error occurred:" + ex.Message);
}
} }
} }