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_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' \
chatgtp_ShowDebug='false' \
onevent_Enabled='false' \
onevent_Count=0 \
chatgpt_ChatHistoryTimeout='15' \

View file

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

View file

@ -309,9 +309,12 @@ namespace SecondBotEvents.Services
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;
}
}
@ -413,7 +416,10 @@ namespace SecondBotEvents.Services
}
catch (Exception ex)
{
LogFormater.Warn("An error occurred: " + ex.Message);
if (myConfig.GetShowDebug() == true)
{
LogFormater.Warn("An error occurred:" + ex.Message);
}
}
}