Skip to content

Commit 7eab71d

Browse files
committed
remote mode for rollback
1 parent ab11fb9 commit 7eab71d

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

Llama.uplugin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"FileVersion": 3,
33
"Version": 1,
4-
"VersionName": "0.9.4",
4+
"VersionName": "0.9.5",
55
"FriendlyName": "Llama",
66
"Description": "Llama.cpp plugin for large language model (LLM) inference.",
77
"Category": "LLM",

Source/LlamaCore/Private/LlamaComponent.cpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,37 @@ void ULlamaComponent::ResetContextHistory(bool bKeepSystemPrompt)
156156

157157
void ULlamaComponent::RemoveLastAssistantReply()
158158
{
159-
LlamaNative->RemoveLastReply();
159+
if (ModelParams.bRemoteMode)
160+
{
161+
//modify state only
162+
int32 Count = ModelState.ChatHistory.History.Num();
163+
if (Count >0)
164+
{
165+
ModelState.ChatHistory.History.RemoveAt(Count - 1);
166+
}
167+
}
168+
else
169+
{
170+
LlamaNative->RemoveLastReply();
171+
}
160172
}
161173

162174
void ULlamaComponent::RemoveLastUserInput()
163175
{
164-
LlamaNative->RemoveLastUserInput();
176+
if (ModelParams.bRemoteMode)
177+
{
178+
//modify state only
179+
int32 Count = ModelState.ChatHistory.History.Num();
180+
if (Count > 1)
181+
{
182+
ModelState.ChatHistory.History.RemoveAt(Count - 1);
183+
ModelState.ChatHistory.History.RemoveAt(Count - 2);
184+
}
185+
}
186+
else
187+
{
188+
LlamaNative->RemoveLastUserInput();
189+
}
165190
}
166191

167192

Source/LlamaCore/Public/LlamaDataTypes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@ struct FLLMModelParams
236236
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LLM Model Params")
237237
bool bAutoLoadModelOnStartup = true;
238238

239+
//If true, all prompt inserts/rollbacks only modify modelstate and do not forward to llama component (see impersonation)
240+
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LLM Model Params")
241+
bool bRemoteMode = false;
242+
239243
//If not different than default empty, no template will be applied
240244
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "LLM Model Params")
241245
FJinjaChatTemplate CustomChatTemplate = "";

0 commit comments

Comments
 (0)