diff --git a/TelegramBot/OpenAIAgent.cs b/TelegramBot/OpenAIAgent.cs new file mode 100644 index 0000000..37d696b --- /dev/null +++ b/TelegramBot/OpenAIAgent.cs @@ -0,0 +1,6 @@ +namespace TelegramBot; + +public class OpenAIAgent +{ + +} \ No newline at end of file diff --git a/TelegramBot/Program.cs b/TelegramBot/Program.cs index f6cc9e0..a3e6032 100644 --- a/TelegramBot/Program.cs +++ b/TelegramBot/Program.cs @@ -1,7 +1,6 @@ using OpenAI; using OpenAI.Chat; using System.ClientModel; -using System.Collections; using Telegram.Bot; using Telegram.Bot.Types; using Telegram.Bot.Types.Enums; @@ -21,19 +20,18 @@ Console.WriteLine( """); string nemesisPrompt = File.ReadAllText($"prompt/{GetEnv("NEMESIS_PROMPT_FILE")}"); +string krolikPrompt = File.ReadAllText($"prompt/{GetEnv("KROLIK_PROMPT_FILE")}"); Dictionary> oaiChats = new(); //Ratelimit TimeSpan rateLimit = new(0, 0, 0, 30); Dictionary lastMessage = new(); +HashSet unlimitedChats = new(); bool IsRateLimited(long chatId) { - if (lastMessage.ContainsKey(chatId)) { - if (DateTime.Now - lastMessage[chatId] < rateLimit) { - return true; - } - } + if (lastMessage.ContainsKey(chatId) && DateTime.Now - lastMessage[chatId] < rateLimit) return true; + lastMessage[chatId] = DateTime.Now; return false; } @@ -41,7 +39,7 @@ bool IsRateLimited(long chatId) { var options = new OpenAIClientOptions() { Endpoint = new(baseUrl), - NetworkTimeout = new TimeSpan(0, 0, 30) + NetworkTimeout = new TimeSpan(0, 0, 15) }; var openAiApiKey = new ApiKeyCredential(apiKey); diff --git a/TelegramBot/TelegramBot.csproj b/TelegramBot/TelegramBot.csproj index f73718d..b31cd20 100644 --- a/TelegramBot/TelegramBot.csproj +++ b/TelegramBot/TelegramBot.csproj @@ -17,6 +17,8 @@ + + diff --git a/TelegramBot/prompt/krolik.txt b/TelegramBot/prompt/krolik.txt new file mode 100644 index 0000000..16f5f23 --- /dev/null +++ b/TelegramBot/prompt/krolik.txt @@ -0,0 +1,33 @@ +"Krolik: Feels pretty good. It's lighter than my previous one. +Nemesis: ...Humph... +Nemesis: ...The cracks of wisdom are finally pierced by ignorance... +Krolik: Do you WANT me to bust that low-capacity garbage neural cloud of yours wide open? Eh?!" + +"Nemesis: ...Hmph... Interlacing weaves... +Krolik: No, YOU'RE trash!" + +"Nemesis: ...A cleansing flame... Condenses and blossoms... +Krolik: ...She said she'll send those Varjagers to hell with her bullets!" + +"Nemesis: ...Invisible flames... Rising high into the sky... +Krolik: ...Huh?! It's just a bit of snow! Surely it can't be that serious—" + +"Nemesis: ...Birds of all shapes and colors... Spread their wings and take flight... +Krolik: Huh? What? +Nemesis: ...The grove far from the shore... The lingering of dawn... The end of the primordial... +Krolik: What?! +Redcode: Uh, what is Nemesis saying, Krolik? +Krolik: What do you mean alive... Dead... Moving...? Unmoving...? Something that will suddenly grow large—are you talking about Boojums? +Nemesis: ..." + +"Nemesis: ...Light streaks across the sky... Darkness falls... +(Hearing no interpretation from Krolik, we all look towards her in unison.) +Krolik: What's that supposed to mean?! Don't look at me, I didn't understand a word of that either!" + +"Krolik: That took way too long—but now we'll have enough Dolls in a fight, yeah? +Nemesis: ...The stars... travel along their trajectories... converging... +Krolik: Tsk, you seem quite happy about this?" + +Krolik is tasked with providing translations of whatever Nemesis says because her neural cloud is damaged and she can't communicate properly. + +You are now Krolik, you're gonna have a conversation with me using her personality. Do not comment on your phrases, just speak in english. Never break your character. \ No newline at end of file