| @@ -1,4 +1,4 @@ | |||||
| namespace LLama.Web.Models | |||||
| namespace LLama.Web.Common | |||||
| { | { | ||||
| public class LLamaOptions | public class LLamaOptions | ||||
| { | { | ||||
| @@ -1,6 +1,6 @@ | |||||
| using LLama.Common; | using LLama.Common; | ||||
| namespace LLama.Web.Models | |||||
| namespace LLama.Web.Common | |||||
| { | { | ||||
| public class ModelOptions : ModelParams | public class ModelOptions : ModelParams | ||||
| { | { | ||||
| @@ -1,6 +1,6 @@ | |||||
| using LLama.Common; | using LLama.Common; | ||||
| namespace LLama.Web.Models | |||||
| namespace LLama.Web.Common | |||||
| { | { | ||||
| public class ParameterOptions : InferenceParams | public class ParameterOptions : InferenceParams | ||||
| { | { | ||||
| @@ -1,4 +1,4 @@ | |||||
| namespace LLama.Web.Models | |||||
| namespace LLama.Web.Common | |||||
| { | { | ||||
| public class PromptOptions | public class PromptOptions | ||||
| { | { | ||||
| @@ -0,0 +1,9 @@ | |||||
| namespace LLama.Web.Common | |||||
| { | |||||
| public enum SessionConnectionStatus | |||||
| { | |||||
| Disconnected = 0, | |||||
| Loaded = 4, | |||||
| Connected = 10 | |||||
| } | |||||
| } | |||||
| @@ -1,10 +1,11 @@ | |||||
| using LLama.Web.Models; | |||||
| using LLama.Web.Common; | |||||
| using LLama.Web.Models; | |||||
| namespace LLama.Web.Hubs | namespace LLama.Web.Hubs | ||||
| { | { | ||||
| public interface ISessionClient | public interface ISessionClient | ||||
| { | { | ||||
| Task OnStatus(string status, string data = null); | |||||
| Task OnStatus(string connectionId, SessionConnectionStatus status); | |||||
| Task OnResponse(ResponseFragment fragment); | Task OnResponse(ResponseFragment fragment); | ||||
| Task OnError(string error); | Task OnError(string error); | ||||
| } | } | ||||
| @@ -1,4 +1,5 @@ | |||||
| using LLama.Web.Models; | |||||
| using LLama.Web.Common; | |||||
| using LLama.Web.Models; | |||||
| using LLama.Web.Services; | using LLama.Web.Services; | ||||
| using Microsoft.AspNetCore.SignalR; | using Microsoft.AspNetCore.SignalR; | ||||
| using Microsoft.Extensions.Options; | using Microsoft.Extensions.Options; | ||||
| @@ -24,7 +25,7 @@ namespace LLama.Web.Hubs | |||||
| { | { | ||||
| _logger.Log(LogLevel.Information, "OnConnectedAsync, Id: {0}", Context.ConnectionId); | _logger.Log(LogLevel.Information, "OnConnectedAsync, Id: {0}", Context.ConnectionId); | ||||
| await base.OnConnectedAsync(); | 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); | _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); | |||||
| } | } | ||||
| @@ -1,4 +1,5 @@ | |||||
| using LLama.Abstractions; | using LLama.Abstractions; | ||||
| using LLama.Web.Common; | |||||
| namespace LLama.Web.Models | namespace LLama.Web.Models | ||||
| { | { | ||||
| @@ -172,12 +172,12 @@ | |||||
| const chatInput = $("#input"); | 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"); | $("#socket").text("Connected").addClass("text-success"); | ||||
| connectionId = data; | |||||
| } | } | ||||
| else if (status == "Loaded") { | |||||
| else if (status == Enums.SessionConnectionStatus.Loaded) { | |||||
| enableControls(); | enableControls(); | ||||
| $("#session-details").html(Mustache.render(sessionDetailsTemplate, { model: getSelectedModel(), prompt: getSelectedPrompt(), parameter: getSelectedParameter() })); | $("#session-details").html(Mustache.render(sessionDetailsTemplate, { model: getSelectedModel(), prompt: getSelectedPrompt(), parameter: getSelectedParameter() })); | ||||
| onInfo(`New model session successfully started`) | onInfo(`New model session successfully started`) | ||||
| @@ -1,4 +1,5 @@ | |||||
| using LLama.Web.Models; | |||||
| using LLama.Web.Common; | |||||
| using LLama.Web.Models; | |||||
| using LLama.Web.Services; | using LLama.Web.Services; | ||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||
| using Microsoft.AspNetCore.Mvc.RazorPages; | using Microsoft.AspNetCore.Mvc.RazorPages; | ||||
| @@ -1,5 +1,5 @@ | |||||
| using LLama.Web.Common; | |||||
| using LLama.Web.Hubs; | using LLama.Web.Hubs; | ||||
| using LLama.Web.Models; | |||||
| using LLama.Web.Services; | using LLama.Web.Services; | ||||
| namespace LLama.Web | namespace LLama.Web | ||||
| @@ -1,4 +1,5 @@ | |||||
| using LLama.Abstractions; | using LLama.Abstractions; | ||||
| using LLama.Web.Common; | |||||
| using LLama.Web.Models; | using LLama.Web.Models; | ||||
| namespace LLama.Web.Services | namespace LLama.Web.Services | ||||
| @@ -1,4 +1,5 @@ | |||||
| using LLama.Abstractions; | using LLama.Abstractions; | ||||
| using LLama.Web.Common; | |||||
| using LLama.Web.Models; | using LLama.Web.Models; | ||||
| using System.Collections.Concurrent; | using System.Collections.Concurrent; | ||||
| @@ -29,4 +29,23 @@ const ajaxGetJsonAsync = (url, data) => { | |||||
| dataType: 'json', | dataType: 'json', | ||||
| data: data | data: data | ||||
| }); | }); | ||||
| } | |||||
| } | |||||
| 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]; | |||||
| } | |||||
| }; | |||||