Browse Source

Fix up issues found during testing

tags/v0.6.0
sa_ddam213 2 years ago
parent
commit
a8a498dc12
8 changed files with 15 additions and 12 deletions
  1. +1
    -1
      LLama.Web/Extensions.cs
  2. +1
    -1
      LLama.Web/Hubs/SessionConnectionHub.cs
  3. +1
    -1
      LLama.Web/Pages/Shared/_ChatTemplates.cshtml
  4. +0
    -1
      LLama.Web/Pages/Shared/_Parameters.cshtml
  5. +2
    -0
      LLama.Web/Program.cs
  6. +4
    -3
      LLama.Web/Services/ModelService.cs
  7. +3
    -3
      LLama.Web/appsettings.json
  8. +3
    -2
      LLama.Web/wwwroot/js/sessionConnectionChat.js

+ 1
- 1
LLama.Web/Extensions.cs View File

@@ -33,7 +33,7 @@ namespace LLama.Web
/// <returns>Combined list with duplicates removed</returns> /// <returns>Combined list with duplicates removed</returns>
private static List<string> CombineCSV(List<string> list, string csv) private static List<string> CombineCSV(List<string> list, string csv)
{ {
var results = list?.Count == 0
var results = list is null || list.Count == 0
? CommaSeperatedToList(csv) ? CommaSeperatedToList(csv)
: CommaSeperatedToList(csv).Concat(list); : CommaSeperatedToList(csv).Concat(list);
return results return results


+ 1
- 1
LLama.Web/Hubs/SessionConnectionHub.cs View File

@@ -37,7 +37,7 @@ namespace LLama.Web.Hubs




[HubMethodName("LoadModel")] [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); _logger.Log(LogLevel.Information, "[OnLoadModel] - Load new model, Connection: {0}", Context.ConnectionId);
await _modelSessionService.CloseAsync(Context.ConnectionId); await _modelSessionService.CloseAsync(Context.ConnectionId);


+ 1
- 1
LLama.Web/Pages/Shared/_ChatTemplates.cshtml View File

@@ -25,7 +25,7 @@
<div class="m-2 me-4"> <div class="m-2 me-4">
<img src="~/image/robot.png" width="60"/> <img src="~/image/robot.png" width="60"/>
</div> </div>
<div id="{{id}}" class="d-flex flex-column flex-fill justify-content-between">
<div id="{{uniqueId}}" class="d-flex flex-column flex-fill justify-content-between">
<span class="content"><img src="~/image/loading.gif" width="30" /></span> <span class="content"><img src="~/image/loading.gif" width="30" /></span>
<div class="d-flex justify-content-end"> <div class="d-flex justify-content-end">
<div class="d-flex flex-column align-items-end"> <div class="d-flex flex-column align-items-end">


+ 0
- 1
LLama.Web/Pages/Shared/_Parameters.cshtml View File

@@ -1,7 +1,6 @@
@page @page
@using LLama.Common; @using LLama.Common;
@model LLama.Abstractions.IInferenceParams @model LLama.Abstractions.IInferenceParams
}


<div class="d-flex flex-row gap-3"> <div class="d-flex flex-row gap-3">
<div class="d-flex flex-column mb-2"> <div class="d-flex flex-column mb-2">


+ 2
- 0
LLama.Web/Program.cs View File

@@ -14,6 +14,8 @@ namespace LLama.Web
// Add services to the container. // Add services to the container.
builder.Services.AddRazorPages(); builder.Services.AddRazorPages();
builder.Services.AddSignalR(); builder.Services.AddSignalR();
builder.Logging.ClearProviders();
builder.Services.AddLogging((loggingBuilder) => loggingBuilder.SetMinimumLevel(LogLevel.Trace).AddConsole());


// Load InteractiveOptions // Load InteractiveOptions
builder.Services.AddOptions<LLamaOptions>() builder.Services.AddOptions<LLamaOptions>()


+ 4
- 3
LLama.Web/Services/ModelService.cs View File

@@ -1,6 +1,7 @@
using LLama.Web.Async; using LLama.Web.Async;
using LLama.Web.Common; using LLama.Web.Common;
using LLama.Web.Models; using LLama.Web.Models;
using Microsoft.Extensions.Options;
using System.Collections.Concurrent; using System.Collections.Concurrent;


namespace LLama.Web.Services namespace LLama.Web.Services
@@ -11,10 +12,10 @@ namespace LLama.Web.Services
/// </summary> /// </summary>
public class ModelService : IModelService public class ModelService : IModelService
{ {
private readonly ILogger _llamaLogger;
private readonly AsyncLock _modelLock; private readonly AsyncLock _modelLock;
private readonly AsyncLock _contextLock; private readonly AsyncLock _contextLock;
private readonly LLamaOptions _configuration; private readonly LLamaOptions _configuration;
private readonly ILogger<ModelService> _llamaLogger;
private readonly ConcurrentDictionary<string, LLamaModel> _modelInstances; private readonly ConcurrentDictionary<string, LLamaModel> _modelInstances;




@@ -23,12 +24,12 @@ namespace LLama.Web.Services
/// </summary> /// </summary>
/// <param name="logger">The logger.</param> /// <param name="logger">The logger.</param>
/// <param name="options">The options.</param> /// <param name="options">The options.</param>
public ModelService(LLamaOptions configuration, ILogger llamaLogger)
public ModelService(IOptions<LLamaOptions> configuration, ILogger<ModelService> llamaLogger)
{ {
_llamaLogger = llamaLogger; _llamaLogger = llamaLogger;
_modelLock = new AsyncLock(); _modelLock = new AsyncLock();
_contextLock = new AsyncLock(); _contextLock = new AsyncLock();
_configuration = configuration;
_configuration = configuration.Value;
_modelInstances = new ConcurrentDictionary<string, LLamaModel>(); _modelInstances = new ConcurrentDictionary<string, LLamaModel>();
} }




+ 3
- 3
LLama.Web/appsettings.json View File

@@ -7,12 +7,12 @@
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"LLamaOptions": { "LLamaOptions": {
"ModelLoadType": "Single",
"ModelLoadType": 0,
"Models": [ "Models": [
{ {
"Name": "WizardLM-7B",
"Name": "LLama2-7b-Chat",
"MaxInstances": 20, "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, "ContextSize": 2048,
"BatchSize": 2048, "BatchSize": 2048,
"Threads": 4, "Threads": 4,


+ 3
- 2
LLama.Web/wwwroot/js/sessionConnectionChat.js View File

@@ -43,8 +43,8 @@ const createConnectionSessionChat = () => {
return; return;


if (response.tokenType == Enums.TokenType.Begin) { 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}`); responseContainer = $(`#${uniqueId}`);
responseContent = responseContainer.find(".content"); responseContent = responseContainer.find(".content");
responseFirstToken = true; responseFirstToken = true;
@@ -102,6 +102,7 @@ const createConnectionSessionChat = () => {
} }


const unloadModel = async () => { const unloadModel = async () => {
await cancelPrompt();
disableControls(); disableControls();
enablePromptControls(); enablePromptControls();
$("#load").removeAttr("disabled"); $("#load").removeAttr("disabled");


Loading…
Cancel
Save