Solves context out of bound due to history
This commit is contained in:
88
.gitignore
vendored
88
.gitignore
vendored
@@ -1,6 +1,88 @@
|
||||
bin/
|
||||
obj/
|
||||
/packages/
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||
|
||||
# User-specific stuff
|
||||
.idea/**/workspace.xml
|
||||
.idea/**/tasks.xml
|
||||
.idea/**/usage.statistics.xml
|
||||
.idea/**/dictionaries
|
||||
.idea/**/shelf
|
||||
|
||||
# AWS User-specific
|
||||
.idea/**/aws.xml
|
||||
|
||||
# Generated files
|
||||
.idea/**/contentModel.xml
|
||||
|
||||
# Sensitive or high-churn files
|
||||
.idea/**/dataSources/
|
||||
.idea/**/dataSources.ids
|
||||
.idea/**/dataSources.local.xml
|
||||
.idea/**/sqlDataSources.xml
|
||||
.idea/**/dynamic.xml
|
||||
.idea/**/uiDesigner.xml
|
||||
.idea/**/dbnavigator.xml
|
||||
|
||||
# Gradle
|
||||
.idea/**/gradle.xml
|
||||
.idea/**/libraries
|
||||
|
||||
# Gradle and Maven with auto-import
|
||||
# When using Gradle or Maven with auto-import, you should exclude module files,
|
||||
# since they will be recreated, and may cause churn. Uncomment if using
|
||||
# auto-import.
|
||||
# .idea/artifacts
|
||||
# .idea/compiler.xml
|
||||
# .idea/jarRepositories.xml
|
||||
# .idea/modules.xml
|
||||
# .idea/*.iml
|
||||
# .idea/modules
|
||||
# *.iml
|
||||
# *.ipr
|
||||
|
||||
# CMake
|
||||
cmake-build-*/
|
||||
|
||||
# Mongo Explorer plugin
|
||||
.idea/**/mongoSettings.xml
|
||||
|
||||
# File-based project format
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Cursive Clojure plugin
|
||||
.idea/replstate.xml
|
||||
|
||||
# SonarLint plugin
|
||||
.idea/sonarlint/
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
# Editor-based Rest Client
|
||||
.idea/httpRequests
|
||||
|
||||
# Android studio 3.1+ serialized cache file
|
||||
.idea/caches/build_file_checksums.ser
|
||||
|
||||
**/[Bb]in/
|
||||
**/[Oo]bj/
|
||||
riderModule.iml
|
||||
/_ReSharper.Caches/
|
||||
.idea/.idea.NemesisAI/compose.generated.override.xml
|
||||
/TelegramBot/.env
|
||||
|
||||
# AI model folder
|
||||
/model/*
|
||||
|
||||
|
||||
@@ -23,9 +23,9 @@ services:
|
||||
RESHARPER_LOG_CONF: "/etc/opt/JetBrains/RiderDebuggerTools/backend-log.xml"
|
||||
image: "telegrambot:dev"
|
||||
ports:
|
||||
- "127.0.0.1:57033:57000"
|
||||
- "127.0.0.1:57233:57200"
|
||||
- "127.0.0.1:57433:57400"
|
||||
- "127.0.0.1:57041:57000"
|
||||
- "127.0.0.1:57241:57200"
|
||||
- "127.0.0.1:57441:57400"
|
||||
volumes:
|
||||
- "I:\\NemesisAI\\TelegramBot:/app:rw"
|
||||
- "I:\\NemesisAI:/src:rw"
|
||||
@@ -34,5 +34,5 @@ services:
|
||||
Linux64:/opt/JetBrains/RiderDebuggerTools"
|
||||
- "C:\\Users\\airon\\AppData\\Local\\Programs\\Rider\\bin\\backend-log.xml:/etc/opt/JetBrains/RiderDebuggerTools/backend-log.xml"
|
||||
- "C:\\Users\\airon\\AppData\\Local\\JetBrains\\Rider2024.3\\log\\DebuggerWorker\\\
|
||||
JetBrains.Debugger.Worker.2024_12_26_03_21_12:/var/opt/JetBrains/RiderDebuggerTools:rw"
|
||||
JetBrains.Debugger.Worker.2024_12_26_04_20_00:/var/opt/JetBrains/RiderDebuggerTools:rw"
|
||||
working_dir: "/app"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using OpenAI;
|
||||
using OpenAI.Chat;
|
||||
using System.ClientModel;
|
||||
using System.Threading.Channels;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Types;
|
||||
using Telegram.Bot.Types.Enums;
|
||||
@@ -18,7 +17,7 @@ Console.WriteLine(
|
||||
""");
|
||||
|
||||
string nemesisPrompt =
|
||||
"""
|
||||
$"""
|
||||
"19 Daily - 01
|
||||
...Birds with great wings... casting shadows in their pupils..."
|
||||
|
||||
@@ -145,7 +144,8 @@ async Task AnswerChat(long chatId, string input) {
|
||||
if (input.Length > 1024) text = input.Substring(0, 1024);
|
||||
|
||||
//Add the current message to the chat
|
||||
oaiChats[chatId].Add(new UserChatMessage(text));
|
||||
//oaiChats[chatId].Add(new UserChatMessage(text));
|
||||
ChatMessageRotate(chatId, new UserChatMessage(text));
|
||||
|
||||
//fetch existing messages history
|
||||
var messages = oaiChats[chatId];
|
||||
@@ -169,6 +169,17 @@ void AddChatToDictionary(long id) {
|
||||
oaiChats.Add(id, chat);
|
||||
}
|
||||
|
||||
void ChatMessageRotate(long chatId, ChatMessage message){
|
||||
//Remove the first message from the chat if the chat has more than 5 couples of messages (0 is our prompt)
|
||||
if (oaiChats[chatId].Count > 10) {
|
||||
oaiChats[chatId].RemoveAt(1);
|
||||
oaiChats[chatId].RemoveAt(2);
|
||||
}
|
||||
|
||||
//Add the new message to the chat
|
||||
oaiChats[chatId].Add(message);
|
||||
}
|
||||
|
||||
void ResetChat(long chatId) {
|
||||
//Remove the chat from the dictionary
|
||||
oaiChats.Remove(chatId);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
services:
|
||||
nemesisBot:
|
||||
image: telegrambot
|
||||
container_name: nemesisBot
|
||||
build:
|
||||
context: .
|
||||
dockerfile: TelegramBot/Dockerfile
|
||||
@@ -14,7 +15,7 @@
|
||||
- ${MODEL_PATH}:/models
|
||||
ports:
|
||||
- "80:80"
|
||||
command: -m /models/${MODEL_NAME} --port 80 --host 0.0.0.0 -n 128 -c 2048 --no-mmap -ngl 50 -fa -np 4 --keep 810
|
||||
command: -m /models/${MODEL_NAME} --port 80 --host 0.0.0.0 -n 128 -c 4096 --no-mmap -ngl 50 -fa -np 4
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
|
||||
Reference in New Issue
Block a user