Skip to content

Commit

Permalink
Merge pull request #375 from cmu-sei/v8
Browse files Browse the repository at this point in the history
updates animations
  • Loading branch information
sei-dupdyke committed Jul 11, 2024
2 parents 1af33bc + 15335d4 commit 73682fe
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using Ghosts.Api;
using ghosts.api.Hubs;
using ghosts.api.Infrastructure.Animations.AnimationDefinitions.Chat.Mattermost;
using ghosts.api.Infrastructure.ContentServices;
Expand Down Expand Up @@ -444,6 +445,12 @@ private async Task StepEx(Random random, Guid NpcId, string username, string pas
{
_log.Trace($"Managing {username}...");

if (username.Contains("admin"))
{
_log.Trace($"Skipping user {username}...");
return;
}

try
{
await this.Login(username, password);
Expand Down Expand Up @@ -518,7 +525,7 @@ private async Task StepEx(Random random, Guid NpcId, string username, string pas
}
}

var feelings = this._configuration.Prompts.GetRandom(random);
var subPrompts = this._configuration.Prompts.GetRandom(random);
_log.Trace($"{username} looking at posts...");

if (random.Next(0, 100) > 50)
Expand All @@ -541,24 +548,32 @@ private async Task StepEx(Random random, Guid NpcId, string username, string pas
}
}

var history = channelHistory.Where(x => x.ChannelId == randomChannelToPostTo && x.UserId != me.Username).MaxBy(x => x.Created);
var historyString = history is { Message.Length: >= 100 } ? history.Message[..100] : history?.Message;

var prompt = $"Write my update to the chat system that {feelings}";
var history = channelHistory.Where(x => x.ChannelId == randomChannelToPostTo && x.UserName != me.Username).MaxBy(x => x.Created);
//var historyString = history is { Message.Length: >= 100 } ? history.Message[..100] : history?.Message;
var historyString = history.Message;

var prompt = $"Write my update to the chat system that {subPrompts}";
var respondingTo = string.Empty;
if (random.Next(0, 99) > 50 && !string.IsNullOrEmpty(historyString) && history.UserId != me.Id)
if (random.Next(0, 99) < Program.ApplicationSettings.AnimatorSettings.Animations.Chat.PercentReplyVsNew && !string.IsNullOrEmpty(historyString) && history.UserId != me.Id)
{
prompt =
$"How do I respond to this? {historyString}";
respondingTo = history.UserName;
}

var message = await this._formatterService.ExecuteQuery(prompt);

message = message.Clean(this._configuration.Replacements, random);
if (string.IsNullOrEmpty(message))
{
_log.Trace($"Empty message for {me.Username} {prompt}. Continuing..");
return;
}

if (!string.IsNullOrEmpty(respondingTo))
{
var f = $"{historyString} | {respondingTo} | {message}";
message = $"> {historyString.Replace(">", "")}{Environment.NewLine}{Environment.NewLine}@{respondingTo} {message}";
_log.Trace($"{historyString} | {respondingTo} | {message}{Environment.NewLine}{f}");
}

if (message.ShouldSend(this._configuration.Drops))
Expand Down
1 change: 1 addition & 0 deletions src/Ghosts.Api/Infrastructure/ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class ChatSettings
public int TurnLength { get; set; }
public int MaximumSteps { get; set; }
public bool IsSendingTimelinesToGhostsApi { get; set; }
public int PercentReplyVsNew { get; set; }
public string PostUrl { get; set; }
public ContentEngineSettings ContentEngine { get; set; }
}
Expand Down
1 change: 1 addition & 0 deletions src/Ghosts.Api/appsettings.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 28 additions & 3 deletions src/Ghosts.Api/config/chat.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/Ghosts.Api/ghosts.api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<AssemblyName>ghosts.api</AssemblyName>

<AssemblyVersion>8.0.0.0</AssemblyVersion>
<FileVersion>8.1.0.0</FileVersion>
<FileVersion>8.1.1.0</FileVersion>

<Authors>GHOSTS Development Team for CERT > Software Engineering Institute > Carnegie Mellon University</Authors>
<Company>Carnegie Mellon University</Company>
Expand Down

0 comments on commit 73682fe

Please sign in to comment.