diff --git a/LLama.Web/Models/LLamaOptions.cs b/LLama.Web/Common/LLamaOptions.cs similarity index 94% rename from LLama.Web/Models/LLamaOptions.cs rename to LLama.Web/Common/LLamaOptions.cs index 63e02942..1ac0d829 100644 --- a/LLama.Web/Models/LLamaOptions.cs +++ b/LLama.Web/Common/LLamaOptions.cs @@ -1,4 +1,4 @@ -namespace LLama.Web.Models +namespace LLama.Web.Common { public class LLamaOptions { diff --git a/LLama.Web/Models/ModelOptions.cs b/LLama.Web/Common/ModelOptions.cs similarity index 91% rename from LLama.Web/Models/ModelOptions.cs rename to LLama.Web/Common/ModelOptions.cs index a6328094..4f8f97e6 100644 --- a/LLama.Web/Models/ModelOptions.cs +++ b/LLama.Web/Common/ModelOptions.cs @@ -1,6 +1,6 @@ using LLama.Common; -namespace LLama.Web.Models +namespace LLama.Web.Common { public class ModelOptions : ModelParams { diff --git a/LLama.Web/Models/ParameterOptions.cs b/LLama.Web/Common/ParameterOptions.cs similarity index 83% rename from LLama.Web/Models/ParameterOptions.cs rename to LLama.Web/Common/ParameterOptions.cs index 23f45950..3cdd3701 100644 --- a/LLama.Web/Models/ParameterOptions.cs +++ b/LLama.Web/Common/ParameterOptions.cs @@ -1,6 +1,6 @@ using LLama.Common; -namespace LLama.Web.Models +namespace LLama.Web.Common { public class ParameterOptions : InferenceParams { diff --git a/LLama.Web/Models/PromptOptions.cs b/LLama.Web/Common/PromptOptions.cs similarity index 90% rename from LLama.Web/Models/PromptOptions.cs rename to LLama.Web/Common/PromptOptions.cs index 5ce1b60c..4e44a5d1 100644 --- a/LLama.Web/Models/PromptOptions.cs +++ b/LLama.Web/Common/PromptOptions.cs @@ -1,4 +1,4 @@ -namespace LLama.Web.Models +namespace LLama.Web.Common { public class PromptOptions { diff --git a/LLama.Web/Common/SessionConnectionStatus.cs b/LLama.Web/Common/SessionConnectionStatus.cs new file mode 100644 index 00000000..d0e1b3c8 --- /dev/null +++ b/LLama.Web/Common/SessionConnectionStatus.cs @@ -0,0 +1,9 @@ +namespace LLama.Web.Common +{ + public enum SessionConnectionStatus + { + Disconnected = 0, + Loaded = 4, + Connected = 10 + } +} diff --git a/LLama.Web/Hubs/ISessionClient.cs b/LLama.Web/Hubs/ISessionClient.cs index 49fc3e92..9e9dc0f1 100644 --- a/LLama.Web/Hubs/ISessionClient.cs +++ b/LLama.Web/Hubs/ISessionClient.cs @@ -1,10 +1,11 @@ -using LLama.Web.Models; +using LLama.Web.Common; +using LLama.Web.Models; namespace LLama.Web.Hubs { public interface ISessionClient { - Task OnStatus(string status, string data = null); + Task OnStatus(string connectionId, SessionConnectionStatus status); Task OnResponse(ResponseFragment fragment); Task OnError(string error); } diff --git a/LLama.Web/Hubs/InteractiveHub.cs b/LLama.Web/Hubs/InteractiveHub.cs index 502904ad..2bbdfd96 100644 --- a/LLama.Web/Hubs/InteractiveHub.cs +++ b/LLama.Web/Hubs/InteractiveHub.cs @@ -1,4 +1,5 @@ -using LLama.Web.Models; +using LLama.Web.Common; +using LLama.Web.Models; using LLama.Web.Services; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Options; @@ -24,7 +25,7 @@ namespace LLama.Web.Hubs { _logger.Log(LogLevel.Information, "OnConnectedAsync, Id: {0}", Context.ConnectionId); await base.OnConnectedAsync(); - await Clients.Caller.OnStatus("Connected", Context.ConnectionId); + await Clients.Caller.OnStatus(Context.ConnectionId, SessionConnectionStatus.Connected); } @@ -55,7 +56,7 @@ namespace LLama.Web.Hubs } _logger.Log(LogLevel.Information, "[OnLoadModel] - New model session added, Connection: {0}", Context.ConnectionId); - await Clients.Caller.OnStatus("Loaded", Context.ConnectionId); + await Clients.Caller.OnStatus(Context.ConnectionId, SessionConnectionStatus.Loaded); } diff --git a/LLama.Web/Models/ModelSession.cs b/LLama.Web/Models/ModelSession.cs index 00c32f50..3f58f05c 100644 --- a/LLama.Web/Models/ModelSession.cs +++ b/LLama.Web/Models/ModelSession.cs @@ -1,4 +1,5 @@ using LLama.Abstractions; +using LLama.Web.Common; namespace LLama.Web.Models { diff --git a/LLama.Web/Pages/Interactive.cshtml b/LLama.Web/Pages/Interactive.cshtml index ae9c66cb..001373ee 100644 --- a/LLama.Web/Pages/Interactive.cshtml +++ b/LLama.Web/Pages/Interactive.cshtml @@ -172,12 +172,12 @@ const chatInput = $("#input"); - const onStatus = (status, data) => { - if (status == "Connected") { + const onStatus = (connectionId, status) => { + connectionId = connectionId; + if (status == Enums.SessionConnectionStatus.Connected) { $("#socket").text("Connected").addClass("text-success"); - connectionId = data; } - else if (status == "Loaded") { + else if (status == Enums.SessionConnectionStatus.Loaded) { enableControls(); $("#session-details").html(Mustache.render(sessionDetailsTemplate, { model: getSelectedModel(), prompt: getSelectedPrompt(), parameter: getSelectedParameter() })); onInfo(`New model session successfully started`) diff --git a/LLama.Web/Pages/Interactive.cshtml.cs b/LLama.Web/Pages/Interactive.cshtml.cs index 3d0ea81b..c209a5b5 100644 --- a/LLama.Web/Pages/Interactive.cshtml.cs +++ b/LLama.Web/Pages/Interactive.cshtml.cs @@ -1,4 +1,5 @@ -using LLama.Web.Models; +using LLama.Web.Common; +using LLama.Web.Models; using LLama.Web.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; diff --git a/LLama.Web/Program.cs b/LLama.Web/Program.cs index 1eefd26a..303e9da0 100644 --- a/LLama.Web/Program.cs +++ b/LLama.Web/Program.cs @@ -1,5 +1,5 @@ +using LLama.Web.Common; using LLama.Web.Hubs; -using LLama.Web.Models; using LLama.Web.Services; namespace LLama.Web diff --git a/LLama.Web/Services/IModelSessionService.cs b/LLama.Web/Services/IModelSessionService.cs index 33c797e6..0642c9a3 100644 --- a/LLama.Web/Services/IModelSessionService.cs +++ b/LLama.Web/Services/IModelSessionService.cs @@ -1,4 +1,5 @@ using LLama.Abstractions; +using LLama.Web.Common; using LLama.Web.Models; namespace LLama.Web.Services diff --git a/LLama.Web/Services/ModelSessionService.cs b/LLama.Web/Services/ModelSessionService.cs index 5de0f316..ed3a9903 100644 --- a/LLama.Web/Services/ModelSessionService.cs +++ b/LLama.Web/Services/ModelSessionService.cs @@ -1,4 +1,5 @@ using LLama.Abstractions; +using LLama.Web.Common; using LLama.Web.Models; using System.Collections.Concurrent; diff --git a/LLama.Web/wwwroot/js/site.js b/LLama.Web/wwwroot/js/site.js index c583c08d..1fc916eb 100644 --- a/LLama.Web/wwwroot/js/site.js +++ b/LLama.Web/wwwroot/js/site.js @@ -29,4 +29,23 @@ const ajaxGetJsonAsync = (url, data) => { dataType: 'json', data: data }); -} \ No newline at end of file +} + + + + +const Enums = { + SessionConnectionStatus: Object.freeze({ + Disconnected: 0, + Loaded: 4, + Connected: 10 + }), + + GetName: (enumType, enumKey) => { + return Object.keys(enumType)[enumKey] + }, + + GetValue: (enumType, enumName) => { + return enumType[enumName]; + } +}; \ No newline at end of file