mirror of
https://github.com/Myxelium/Lunaris2.0.git
synced 2026-04-09 06:09:39 +00:00
Improve chat
This commit is contained in:
@@ -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)
|
||||
@@ -30,6 +32,10 @@ namespace Lunaris2.Handler.ChatCommand
|
||||
|
||||
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();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(userMessage))
|
||||
|
||||
@@ -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:"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,34 +26,43 @@ services:
|
||||
- "2333:2333"
|
||||
|
||||
ollama:
|
||||
volumes:
|
||||
- ollama:/root/.ollama
|
||||
# comment below to not expose Ollama API outside the container stack
|
||||
image: ollama/ollama:latest
|
||||
ports:
|
||||
- 11434:11434
|
||||
- 7869:11434
|
||||
volumes:
|
||||
- .:/code
|
||||
- ./ollama/ollama:/root/.ollama
|
||||
container_name: ollama
|
||||
pull_policy: always
|
||||
tty: true
|
||||
restart: unless-stopped
|
||||
image: ollama/ollama:latest
|
||||
restart: always
|
||||
environment:
|
||||
- OLLAMA_KEEP_ALIVE=24h
|
||||
- OLLAMA_HOST=0.0.0.0
|
||||
networks:
|
||||
- ollama-docker
|
||||
|
||||
ollama-webui:
|
||||
build:
|
||||
context: .
|
||||
args:
|
||||
OLLAMA_API_BASE_URL: '/ollama/api'
|
||||
dockerfile: Dockerfile
|
||||
image: ollama-webui:latest
|
||||
image: ghcr.io/open-webui/open-webui:main
|
||||
container_name: ollama-webui
|
||||
volumes:
|
||||
- ./ollama/ollama-webui:/app/backend/data
|
||||
depends_on:
|
||||
- ollama
|
||||
ports:
|
||||
- 3000:8080
|
||||
environment:
|
||||
- "OLLAMA_API_BASE_URL=http://ollama:11434/api"
|
||||
- 8080:8080
|
||||
environment: # https://docs.openwebui.com/getting-started/env-configuration#default_models
|
||||
- OLLAMA_BASE_URLS=http://host.docker.internal:7869 #comma separated ollama hosts
|
||||
- ENV=dev
|
||||
- WEBUI_AUTH=False
|
||||
- WEBUI_NAME=valiantlynx AI
|
||||
- WEBUI_URL=http://localhost:8080
|
||||
- WEBUI_SECRET_KEY=t0p-s3cr3t
|
||||
extra_hosts:
|
||||
- host.docker.internal:host-gateway
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- ollama-docker
|
||||
|
||||
volumes:
|
||||
ollama: {}
|
||||
@@ -62,3 +71,5 @@ networks:
|
||||
# create a lavalink network you can add other containers to, to give them access to Lavalink
|
||||
lavalink:
|
||||
name: lavalink
|
||||
ollama-docker:
|
||||
external: false
|
||||
@@ -1 +1,3 @@
|
||||
docker compose up -d
|
||||
|
||||
read -p "Press enter to continue"
|
||||
|
||||
Reference in New Issue
Block a user