Skip to content

Commit 56d4217

Browse files
author
Tomasz Juszczak
committed
Fixed parameter resolving
1 parent 4fa112e commit 56d4217

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

Slack-GPT-Socket/GptApi/GptClientResolver.cs

+7-8
Original file line numberDiff line numberDiff line change
@@ -181,22 +181,21 @@ private static void TrimInputFromParameter(GptRequest input, ParameterEventArgs
181181
// update last index to check if we've reached the end of the parameters
182182
var paramNameIndex = input.Prompt.IndexOf(args.Name, StringComparison.InvariantCultureIgnoreCase);
183183

184-
int paramEndIndex;
185184
string searchString;
186185
// Determine if the parameter has a value, because if it doesn't we don't want to remove it from the prompt!
187186
if (args.HasValue)
188187
{
189-
paramEndIndex = paramNameIndex + args.Name.Length + args.Value.Length + 2;
190-
searchString = args.Name + " " + args.ValueRaw + " ";
188+
// Find last index of this value args.ValueRaw
189+
var paramValueIndex = input.Prompt.IndexOf(args.ValueRaw, StringComparison.InvariantCultureIgnoreCase) + args.ValueRaw.Length + 1;
190+
lastIndex = paramValueIndex;
191+
input.Prompt = input.Prompt.Substring(paramValueIndex, input.Prompt.Length - paramValueIndex).Trim();
192+
return;
191193
}
192194
else
193195
{
194-
paramEndIndex = paramNameIndex + args.Name.Length + 2;
196+
lastIndex = paramNameIndex + args.Name.Length + 2;
195197
searchString = args.Name + " ";
198+
input.Prompt = input.Prompt.Replace(searchString, "").Trim();
196199
}
197-
198-
// Update last index to check if we've reached the end of the parameters
199-
lastIndex = paramEndIndex;
200-
input.Prompt = input.Prompt.Replace(searchString, "").Trim();
201200
}
202201
}

0 commit comments

Comments
 (0)