diff --git a/LLama.Web/Extensions.cs b/LLama.Web/Extensions.cs index 99f745dd..ee8d7f7f 100644 --- a/LLama.Web/Extensions.cs +++ b/LLama.Web/Extensions.cs @@ -33,7 +33,7 @@ namespace LLama.Web /// Combined list with duplicates removed private static List CombineCSV(List list, string csv) { - var results = list?.Count == 0 + var results = list is null || list.Count == 0 ? CommaSeperatedToList(csv) : CommaSeperatedToList(csv).Concat(list); return results diff --git a/LLama.Web/Hubs/SessionConnectionHub.cs b/LLama.Web/Hubs/SessionConnectionHub.cs index 24457683..966ec8a4 100644 --- a/LLama.Web/Hubs/SessionConnectionHub.cs +++ b/LLama.Web/Hubs/SessionConnectionHub.cs @@ -37,7 +37,7 @@ namespace LLama.Web.Hubs [HubMethodName("LoadModel")] - public async Task OnLoadModel(ISessionConfig sessionConfig, InferenceOptions inferenceConfig) + public async Task OnLoadModel(SessionConfig sessionConfig, InferenceOptions inferenceConfig) { _logger.Log(LogLevel.Information, "[OnLoadModel] - Load new model, Connection: {0}", Context.ConnectionId); await _modelSessionService.CloseAsync(Context.ConnectionId); diff --git a/LLama.Web/Pages/Shared/_ChatTemplates.cshtml b/LLama.Web/Pages/Shared/_ChatTemplates.cshtml index cd768f1f..624f5859 100644 --- a/LLama.Web/Pages/Shared/_ChatTemplates.cshtml +++ b/LLama.Web/Pages/Shared/_ChatTemplates.cshtml @@ -25,7 +25,7 @@
-
+
diff --git a/LLama.Web/Pages/Shared/_Parameters.cshtml b/LLama.Web/Pages/Shared/_Parameters.cshtml index d6e476c4..76f3e321 100644 --- a/LLama.Web/Pages/Shared/_Parameters.cshtml +++ b/LLama.Web/Pages/Shared/_Parameters.cshtml @@ -1,7 +1,6 @@ @page @using LLama.Common; @model LLama.Abstractions.IInferenceParams -}
diff --git a/LLama.Web/Program.cs b/LLama.Web/Program.cs index 7c4583d2..193090d0 100644 --- a/LLama.Web/Program.cs +++ b/LLama.Web/Program.cs @@ -14,6 +14,8 @@ namespace LLama.Web // Add services to the container. builder.Services.AddRazorPages(); builder.Services.AddSignalR(); + builder.Logging.ClearProviders(); + builder.Services.AddLogging((loggingBuilder) => loggingBuilder.SetMinimumLevel(LogLevel.Trace).AddConsole()); // Load InteractiveOptions builder.Services.AddOptions() diff --git a/LLama.Web/Services/ModelService.cs b/LLama.Web/Services/ModelService.cs index dfb34bb6..3634f6ab 100644 --- a/LLama.Web/Services/ModelService.cs +++ b/LLama.Web/Services/ModelService.cs @@ -1,6 +1,7 @@ using LLama.Web.Async; using LLama.Web.Common; using LLama.Web.Models; +using Microsoft.Extensions.Options; using System.Collections.Concurrent; namespace LLama.Web.Services @@ -11,10 +12,10 @@ namespace LLama.Web.Services /// public class ModelService : IModelService { - private readonly ILogger _llamaLogger; private readonly AsyncLock _modelLock; private readonly AsyncLock _contextLock; private readonly LLamaOptions _configuration; + private readonly ILogger _llamaLogger; private readonly ConcurrentDictionary _modelInstances; @@ -23,12 +24,12 @@ namespace LLama.Web.Services /// /// The logger. /// The options. - public ModelService(LLamaOptions configuration, ILogger llamaLogger) + public ModelService(IOptions configuration, ILogger llamaLogger) { _llamaLogger = llamaLogger; _modelLock = new AsyncLock(); _contextLock = new AsyncLock(); - _configuration = configuration; + _configuration = configuration.Value; _modelInstances = new ConcurrentDictionary(); } diff --git a/LLama.Web/appsettings.json b/LLama.Web/appsettings.json index 6231b882..82d62b1a 100644 --- a/LLama.Web/appsettings.json +++ b/LLama.Web/appsettings.json @@ -7,12 +7,12 @@ }, "AllowedHosts": "*", "LLamaOptions": { - "ModelLoadType": "Single", + "ModelLoadType": 0, "Models": [ { - "Name": "WizardLM-7B", + "Name": "LLama2-7b-Chat", "MaxInstances": 20, - "ModelPath": "D:\\Repositories\\AI\\Models\\wizardLM-7B.ggmlv3.q4_0.bin", + "ModelPath": "..\\LLama.Unittest\\Models\\llama-2-7b-chat.Q4_0.gguf", "ContextSize": 2048, "BatchSize": 2048, "Threads": 4, diff --git a/LLama.Web/wwwroot/js/sessionConnectionChat.js b/LLama.Web/wwwroot/js/sessionConnectionChat.js index 719c44ac..24821150 100644 --- a/LLama.Web/wwwroot/js/sessionConnectionChat.js +++ b/LLama.Web/wwwroot/js/sessionConnectionChat.js @@ -43,8 +43,8 @@ const createConnectionSessionChat = () => { return; if (response.tokenType == Enums.TokenType.Begin) { - const uniqueId = randomString(); - outputContainer.append(Mustache.render(outputBotTemplate, { id: uniqueId, ...response })); + let uniqueId = randomString(); + outputContainer.append(Mustache.render(outputBotTemplate, { uniqueId: uniqueId, ...response })); responseContainer = $(`#${uniqueId}`); responseContent = responseContainer.find(".content"); responseFirstToken = true; @@ -102,6 +102,7 @@ const createConnectionSessionChat = () => { } const unloadModel = async () => { + await cancelPrompt(); disableControls(); enablePromptControls(); $("#load").removeAttr("disabled");