2023-08-19 13:25:47 +00:00
|
|
|
using BotSharp.Plugin.LLamaSharp.Settings;
|
2023-06-27 19:17:53 +00:00
|
|
|
using LLama;
|
2023-06-27 23:36:50 +00:00
|
|
|
using LLama.Common;
|
|
|
|
|
|
2023-06-27 19:17:53 +00:00
|
|
|
namespace BotSharp.Core.Plugins.LLamaSharp;
|
|
|
|
|
|
|
|
|
|
public class LlamaAiModel
|
|
|
|
|
{
|
|
|
|
|
private readonly LlamaSharpSettings _settings;
|
2023-06-27 23:36:50 +00:00
|
|
|
public LlamaSharpSettings Settings => _settings;
|
2023-06-27 19:17:53 +00:00
|
|
|
|
|
|
|
|
LLamaModel _model;
|
|
|
|
|
|
|
|
|
|
public LLamaModel Model => _model;
|
|
|
|
|
|
|
|
|
|
public LlamaAiModel(LlamaSharpSettings settings)
|
|
|
|
|
{
|
|
|
|
|
_settings = settings;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void LoadModel()
|
|
|
|
|
{
|
|
|
|
|
if (_model != null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-27 23:36:50 +00:00
|
|
|
_model = new LLamaModel(new ModelParams(_settings.ModelPath,
|
|
|
|
|
contextSize: _settings.MaxContextLength,
|
|
|
|
|
gpuLayerCount: _settings.NumberOfGpuLayer));
|
2023-06-27 19:17:53 +00:00
|
|
|
}
|
|
|
|
|
}
|