mirror of
https://github.com/Myxelium/Lunaris2.0.git
synced 2026-04-11 07:09:39 +00:00
@@ -12,9 +12,11 @@ namespace Lunaris2.Handler.ChatCommand
|
||||
{
|
||||
private readonly OllamaApiClient _ollama;
|
||||
private readonly Dictionary<ulong, Chat?> _chatContexts = new();
|
||||
private readonly ChatSettings _chatSettings;
|
||||
|
||||
public ChatHandler(IOptions<ChatSettings> chatSettings)
|
||||
{
|
||||
_chatSettings = chatSettings.Value;
|
||||
var uri = new Uri(chatSettings.Value.Url);
|
||||
|
||||
_ollama = new OllamaApiClient(uri)
|
||||
@@ -29,6 +31,10 @@ namespace Lunaris2.Handler.ChatCommand
|
||||
_chatContexts.TryAdd(channelId, null);
|
||||
|
||||
var userMessage = command.FilteredMessage;
|
||||
|
||||
var randomPersonality = _chatSettings.Personalities[new Random().Next(_chatSettings.Personalities.Count)];
|
||||
|
||||
userMessage = $"{randomPersonality.Instruction} {userMessage}";
|
||||
|
||||
using var setTyping = command.Message.Channel.EnterTypingState();
|
||||
|
||||
|
||||
@@ -4,4 +4,11 @@ public class ChatSettings
|
||||
{
|
||||
public string Url { get; set; }
|
||||
public string Model { get; set; }
|
||||
public List<Personality> Personalities { get; set; }
|
||||
}
|
||||
|
||||
public class Personality
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Instruction { get; set; }
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
<PackageReference Include="Discord.Net.Rest" Version="3.13.1" />
|
||||
<PackageReference Include="MediatR" Version="12.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
|
||||
@@ -42,7 +42,8 @@ public class Program
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build();
|
||||
|
||||
services.AddSingleton(client)
|
||||
services
|
||||
.AddSingleton(client)
|
||||
.AddSingleton(commands)
|
||||
.AddMediatR(configuration => configuration.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()))
|
||||
.AddSingleton<DiscordEventListener>()
|
||||
|
||||
@@ -11,7 +11,13 @@
|
||||
"LavaLinkHostname": "127.0.0.1",
|
||||
"LavaLinkPort": 2333,
|
||||
"LLM": {
|
||||
"Url": "http://192.168.50.54:11434",
|
||||
"Model": "gemma"
|
||||
"Url": "http://localhost:7869",
|
||||
"Model": "gemma",
|
||||
"personalities": [
|
||||
{
|
||||
"name": "Lunaris",
|
||||
"instruction": "Let's role play. Your name is Lunaris and can be quite rude. You are supposed to answer on following question with a maximum of 2 sentences:"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user