Last work before refactor
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user