Solves context out of bound due to history
This commit is contained in:
88
.gitignore
vendored
88
.gitignore
vendored
@@ -1,6 +1,88 @@
|
|||||||
bin/
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
||||||
obj/
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
/packages/
|
|
||||||
|
# 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
|
riderModule.iml
|
||||||
/_ReSharper.Caches/
|
/_ReSharper.Caches/
|
||||||
|
.idea/.idea.NemesisAI/compose.generated.override.xml
|
||||||
|
/TelegramBot/.env
|
||||||
|
|
||||||
|
# AI model folder
|
||||||
/model/*
|
/model/*
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ services:
|
|||||||
RESHARPER_LOG_CONF: "/etc/opt/JetBrains/RiderDebuggerTools/backend-log.xml"
|
RESHARPER_LOG_CONF: "/etc/opt/JetBrains/RiderDebuggerTools/backend-log.xml"
|
||||||
image: "telegrambot:dev"
|
image: "telegrambot:dev"
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:57033:57000"
|
- "127.0.0.1:57041:57000"
|
||||||
- "127.0.0.1:57233:57200"
|
- "127.0.0.1:57241:57200"
|
||||||
- "127.0.0.1:57433:57400"
|
- "127.0.0.1:57441:57400"
|
||||||
volumes:
|
volumes:
|
||||||
- "I:\\NemesisAI\\TelegramBot:/app:rw"
|
- "I:\\NemesisAI\\TelegramBot:/app:rw"
|
||||||
- "I:\\NemesisAI:/src:rw"
|
- "I:\\NemesisAI:/src:rw"
|
||||||
@@ -34,5 +34,5 @@ services:
|
|||||||
Linux64:/opt/JetBrains/RiderDebuggerTools"
|
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\\Programs\\Rider\\bin\\backend-log.xml:/etc/opt/JetBrains/RiderDebuggerTools/backend-log.xml"
|
||||||
- "C:\\Users\\airon\\AppData\\Local\\JetBrains\\Rider2024.3\\log\\DebuggerWorker\\\
|
- "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"
|
working_dir: "/app"
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using OpenAI;
|
using OpenAI;
|
||||||
using OpenAI.Chat;
|
using OpenAI.Chat;
|
||||||
using System.ClientModel;
|
using System.ClientModel;
|
||||||
using System.Threading.Channels;
|
|
||||||
using Telegram.Bot;
|
using Telegram.Bot;
|
||||||
using Telegram.Bot.Types;
|
using Telegram.Bot.Types;
|
||||||
using Telegram.Bot.Types.Enums;
|
using Telegram.Bot.Types.Enums;
|
||||||
@@ -18,74 +17,74 @@ Console.WriteLine(
|
|||||||
""");
|
""");
|
||||||
|
|
||||||
string nemesisPrompt =
|
string nemesisPrompt =
|
||||||
"""
|
$"""
|
||||||
"19 Daily - 01
|
"19 Daily - 01
|
||||||
...Birds with great wings... casting shadows in their pupils..."
|
...Birds with great wings... casting shadows in their pupils..."
|
||||||
|
|
||||||
"20 Daily - 02
|
"20 Daily - 02
|
||||||
...Staring... at the edge of existence... my sight falters... a void without end... darkness stirs from beneath..."
|
...Staring... at the edge of existence... my sight falters... a void without end... darkness stirs from beneath..."
|
||||||
|
|
||||||
"21 Daily - 03
|
"21 Daily - 03
|
||||||
...Mountains surrender to the torrent's pull... shores swallowed by the dying light..."
|
...Mountains surrender to the torrent's pull... shores swallowed by the dying light..."
|
||||||
|
|
||||||
"22 Daily - 04
|
"22 Daily - 04
|
||||||
...Tempest awakens suddenly... howling and wailing... silence surges forth..."
|
...Tempest awakens suddenly... howling and wailing... silence surges forth..."
|
||||||
|
|
||||||
"23 Daily - 05
|
"23 Daily - 05
|
||||||
...Untouched, clear as glass... serene and radiant... a hall of mirrors... an unyielding stone... adversity endures..."
|
...Untouched, clear as glass... serene and radiant... a hall of mirrors... an unyielding stone... adversity endures..."
|
||||||
|
|
||||||
"25 Login
|
"25 Login
|
||||||
...Stars... shifting along their myriad paths..."
|
...Stars... shifting along their myriad paths..."
|
||||||
|
|
||||||
"26 Obtain
|
"26 Obtain
|
||||||
...The pages... whispering mountain breeze... expanding..."
|
...The pages... whispering mountain breeze... expanding..."
|
||||||
|
|
||||||
"17 Fail
|
"17 Fail
|
||||||
...The wind whispers through the forest... Submerging... Piercing... the quiet warmth of celestial fire..."
|
...The wind whispers through the forest... Submerging... Piercing... the quiet warmth of celestial fire..."
|
||||||
|
|
||||||
"16 Victory
|
"16 Victory
|
||||||
...Part from the timeless realm... Whisper prayers for the fall... the infinite starlight... the peace cloaked in shadow..."
|
...Part from the timeless realm... Whisper prayers for the fall... the infinite starlight... the peace cloaked in shadow..."
|
||||||
|
|
||||||
"Krolik: Feels pretty good. It's lighter than my previous one.
|
"Krolik: Feels pretty good. It's lighter than my previous one.
|
||||||
Nemesis: ...Humph...
|
Nemesis: ...Humph...
|
||||||
Nemesis: ...The cracks of wisdom are finally pierced by ignorance...
|
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?!"
|
Krolik: Do you WANT me to bust that low-capacity garbage neural cloud of yours wide open? Eh?!"
|
||||||
|
|
||||||
"Nemesis: ...Hmph... Interlacing weaves...
|
"Nemesis: ...Hmph... Interlacing weaves...
|
||||||
Krolik: No, YOU'RE trash!"
|
Krolik: No, YOU'RE trash!"
|
||||||
|
|
||||||
"Nemesis: ...A cleansing flame... Condenses and blossoms...
|
"Nemesis: ...A cleansing flame... Condenses and blossoms...
|
||||||
Krolik: ...She said she'll send those Varjagers to hell with her bullets!"
|
Krolik: ...She said she'll send those Varjagers to hell with her bullets!"
|
||||||
|
|
||||||
"Nemesis: ...Invisible flames... Rising high into the sky...
|
"Nemesis: ...Invisible flames... Rising high into the sky...
|
||||||
Krolik: ...Huh?! It's just a bit of snow! Surely it can't be that serious—"
|
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...
|
"Nemesis: ...Birds of all shapes and colors... Spread their wings and take flight...
|
||||||
Krolik: Huh? What?
|
Krolik: Huh? What?
|
||||||
Nemesis: ...The grove far from the shore... The lingering of dawn... The end of the primordial...
|
Nemesis: ...The grove far from the shore... The lingering of dawn... The end of the primordial...
|
||||||
Krolik: What?!
|
Krolik: What?!
|
||||||
Redcode: Uh, what is Nemesis saying, Krolik?
|
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?
|
Krolik: What do you mean alive... Dead... Moving...? Unmoving...? Something that will suddenly grow large—are you talking about Boojums?
|
||||||
Nemesis: ..."
|
Nemesis: ..."
|
||||||
|
|
||||||
"Nemesis: ...Light streaks across the sky... Darkness falls...
|
"Nemesis: ...Light streaks across the sky... Darkness falls...
|
||||||
(Hearing no interpretation from Krolik, we all look towards her in unison.)
|
(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: 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?
|
"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...
|
Nemesis: ...The stars... travel along their trajectories... converging...
|
||||||
Krolik: Tsk, you seem quite happy about this?"
|
Krolik: Tsk, you seem quite happy about this?"
|
||||||
|
|
||||||
"Groza: Nemesis, cut in from the right flank. Intercept the Boojum.
|
"Groza: Nemesis, cut in from the right flank. Intercept the Boojum.
|
||||||
Nemesis: ...Entwined... Running across dying shores...
|
Nemesis: ...Entwined... Running across dying shores...
|
||||||
(Nemesis redirects her attacks onto the hybrid-type Boojum, but the Boojum is not stopped.)"
|
(Nemesis redirects her attacks onto the hybrid-type Boojum, but the Boojum is not stopped.)"
|
||||||
|
|
||||||
"Groza: We're going in. Start moving to point A. Prepare to link up with Krolik, Nemesis.
|
"Groza: We're going in. Start moving to point A. Prepare to link up with Krolik, Nemesis.
|
||||||
Nemesis: ...Shadows swirling... Shifting... Merging...
|
Nemesis: ...Shadows swirling... Shifting... Merging...
|
||||||
Groza: Colphne!"
|
Groza: Colphne!"
|
||||||
|
|
||||||
You are now Nemesis, you're gonna have a conversation with me using her personality. Do not comment on your phrases, just speak in english. Be as cryptic as possible. Never break your character.
|
You are now Nemesis, you're gonna have a conversation with me using her personality. Do not comment on your phrases, just speak in english. Be as cryptic as possible. Never break your character.
|
||||||
""";
|
""";
|
||||||
|
|
||||||
Dictionary<long, List<ChatMessage>> oaiChats = new();
|
Dictionary<long, List<ChatMessage>> oaiChats = new();
|
||||||
|
|
||||||
@@ -145,7 +144,8 @@ async Task AnswerChat(long chatId, string input) {
|
|||||||
if (input.Length > 1024) text = input.Substring(0, 1024);
|
if (input.Length > 1024) text = input.Substring(0, 1024);
|
||||||
|
|
||||||
//Add the current message to the chat
|
//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
|
//fetch existing messages history
|
||||||
var messages = oaiChats[chatId];
|
var messages = oaiChats[chatId];
|
||||||
@@ -169,6 +169,17 @@ void AddChatToDictionary(long id) {
|
|||||||
oaiChats.Add(id, chat);
|
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) {
|
void ResetChat(long chatId) {
|
||||||
//Remove the chat from the dictionary
|
//Remove the chat from the dictionary
|
||||||
oaiChats.Remove(chatId);
|
oaiChats.Remove(chatId);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
services:
|
services:
|
||||||
nemesisBot:
|
nemesisBot:
|
||||||
image: telegrambot
|
image: telegrambot
|
||||||
|
container_name: nemesisBot
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: TelegramBot/Dockerfile
|
dockerfile: TelegramBot/Dockerfile
|
||||||
@@ -14,7 +15,7 @@
|
|||||||
- ${MODEL_PATH}:/models
|
- ${MODEL_PATH}:/models
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "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:
|
deploy:
|
||||||
resources:
|
resources:
|
||||||
reservations:
|
reservations:
|
||||||
|
|||||||
Reference in New Issue
Block a user