Found stuff that is wrong.
This commit is contained in:
parent
151146378b
commit
668d9e4734
2 changed files with 9 additions and 9 deletions
|
@ -90,15 +90,15 @@ public class ChatterBotService : IExecOnMessage
|
||||||
|
|
||||||
public string PrepareMessage(IUserMessage msg)
|
public string PrepareMessage(IUserMessage msg)
|
||||||
{
|
{
|
||||||
var nadekoId = _client.CurrentUser.Id;
|
var ellieId = _client.CurrentUser.Id;
|
||||||
var normalMention = $"<@{nadekoId}> ";
|
var normalMention = $"<@{ellieId}> ";
|
||||||
var nickMention = $"<@!{nadekoId}> ";
|
var nickMention = $"<@!{ellieId}> ";
|
||||||
string message;
|
string message;
|
||||||
if (msg.Content.StartsWith(normalMention, StringComparison.InvariantCulture))
|
if (msg.Content.StartsWith(normalMention, StringComparison.InvariantCulture))
|
||||||
message = msg.Content[normalMention.Length..].Trim();
|
message = msg.Content[normalMention.Length..].Trim();
|
||||||
else if (msg.Content.StartsWith(nickMention, StringComparison.InvariantCulture))
|
else if (msg.Content.StartsWith(nickMention, StringComparison.InvariantCulture))
|
||||||
message = msg.Content[nickMention.Length..].Trim();
|
message = msg.Content[nickMention.Length..].Trim();
|
||||||
else if (msg.ReferencedMessage?.Author.Id == nadekoId)
|
else if (msg.ReferencedMessage?.Author.Id == ellieId)
|
||||||
message = msg.Content;
|
message = msg.Content;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -15,7 +15,7 @@ public partial class OpenAiApiSession : IChatterBotSession
|
||||||
private readonly int _maxHistory;
|
private readonly int _maxHistory;
|
||||||
private readonly int _maxTokens;
|
private readonly int _maxTokens;
|
||||||
private readonly int _minTokens;
|
private readonly int _minTokens;
|
||||||
private readonly string _nadekoUsername;
|
private readonly string _ellieUsername;
|
||||||
private readonly GptEncoding _encoding;
|
private readonly GptEncoding _encoding;
|
||||||
private List<OpenAiApiMessage> messages = new();
|
private List<OpenAiApiMessage> messages = new();
|
||||||
private readonly IHttpClientFactory _httpFactory;
|
private readonly IHttpClientFactory _httpFactory;
|
||||||
|
@ -29,7 +29,7 @@ public partial class OpenAiApiSession : IChatterBotSession
|
||||||
int maxTokens,
|
int maxTokens,
|
||||||
int minTokens,
|
int minTokens,
|
||||||
string personality,
|
string personality,
|
||||||
string nadekoUsername,
|
string ellieUsername,
|
||||||
IHttpClientFactory factory)
|
IHttpClientFactory factory)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(url) || !Uri.TryCreate(url, UriKind.Absolute, out _))
|
if (string.IsNullOrWhiteSpace(url) || !Uri.TryCreate(url, UriKind.Absolute, out _))
|
||||||
|
@ -45,7 +45,7 @@ public partial class OpenAiApiSession : IChatterBotSession
|
||||||
_maxHistory = chatHistory;
|
_maxHistory = chatHistory;
|
||||||
_maxTokens = maxTokens;
|
_maxTokens = maxTokens;
|
||||||
_minTokens = minTokens;
|
_minTokens = minTokens;
|
||||||
_nadekoUsername = UsernameCleaner().Replace(nadekoUsername, "");
|
_ellieUsername = UsernameCleaner().Replace(ellieUsername, "");
|
||||||
_encoding = GptEncoding.GetEncodingForModel("gpt-4o");
|
_encoding = GptEncoding.GetEncodingForModel("gpt-4o");
|
||||||
if (!string.IsNullOrWhiteSpace(personality))
|
if (!string.IsNullOrWhiteSpace(personality))
|
||||||
{
|
{
|
||||||
|
@ -53,7 +53,7 @@ public partial class OpenAiApiSession : IChatterBotSession
|
||||||
{
|
{
|
||||||
Role = "system",
|
Role = "system",
|
||||||
Content = personality,
|
Content = personality,
|
||||||
Name = _nadekoUsername
|
Name = _ellieUsername
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ public partial class OpenAiApiSession : IChatterBotSession
|
||||||
{
|
{
|
||||||
Role = "assistant",
|
Role = "assistant",
|
||||||
Content = message,
|
Content = message,
|
||||||
Name = _nadekoUsername
|
Name = _ellieUsername
|
||||||
});
|
});
|
||||||
|
|
||||||
return new ThinkResult()
|
return new ThinkResult()
|
||||||
|
|
Loading…
Reference in a new issue