Last work before refactor
This commit is contained in:
6
TelegramBot/OpenAIAgent.cs
Normal file
6
TelegramBot/OpenAIAgent.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace TelegramBot;
|
||||
|
||||
public class OpenAIAgent
|
||||
{
|
||||
|
||||
}
|
||||
@@ -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<long, List<ChatMessage>> oaiChats = new();
|
||||
|
||||
//Ratelimit
|
||||
TimeSpan rateLimit = new(0, 0, 0, 30);
|
||||
Dictionary<long, DateTime> lastMessage = new();
|
||||
HashSet<long> 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);
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="LMStudio" Version="1.2.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0" />
|
||||
<PackageReference Include="OpenAI" Version="2.1.0" />
|
||||
<PackageReference Include="Telegram.Bot" Version="22.2.0" />
|
||||
</ItemGroup>
|
||||
|
||||
33
TelegramBot/prompt/krolik.txt
Normal file
33
TelegramBot/prompt/krolik.txt
Normal file
@@ -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.
|
||||
Reference in New Issue
Block a user