mirror of
https://github.com/Myxelium/Lunaris2.0.git
synced 2026-04-13 08:00:37 +00:00
Compare commits
1 Commits
0.1.16
...
Improve-ch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f08d89f322 |
@@ -12,9 +12,11 @@ namespace Lunaris2.Handler.ChatCommand
|
|||||||
{
|
{
|
||||||
private readonly OllamaApiClient _ollama;
|
private readonly OllamaApiClient _ollama;
|
||||||
private readonly Dictionary<ulong, Chat?> _chatContexts = new();
|
private readonly Dictionary<ulong, Chat?> _chatContexts = new();
|
||||||
|
private readonly ChatSettings _chatSettings;
|
||||||
|
|
||||||
public ChatHandler(IOptions<ChatSettings> chatSettings)
|
public ChatHandler(IOptions<ChatSettings> chatSettings)
|
||||||
{
|
{
|
||||||
|
_chatSettings = chatSettings.Value;
|
||||||
var uri = new Uri(chatSettings.Value.Url);
|
var uri = new Uri(chatSettings.Value.Url);
|
||||||
|
|
||||||
_ollama = new OllamaApiClient(uri)
|
_ollama = new OllamaApiClient(uri)
|
||||||
@@ -29,6 +31,10 @@ namespace Lunaris2.Handler.ChatCommand
|
|||||||
_chatContexts.TryAdd(channelId, null);
|
_chatContexts.TryAdd(channelId, null);
|
||||||
|
|
||||||
var userMessage = command.FilteredMessage;
|
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();
|
using var setTyping = command.Message.Channel.EnterTypingState();
|
||||||
|
|
||||||
|
|||||||
@@ -4,4 +4,11 @@ public class ChatSettings
|
|||||||
{
|
{
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
public string Model { 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="Discord.Net.Rest" Version="3.13.1" />
|
||||||
<PackageReference Include="MediatR" Version="12.2.0" />
|
<PackageReference Include="MediatR" Version="12.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.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.Configuration.Json" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ public class Program
|
|||||||
.AddJsonFile("appsettings.json")
|
.AddJsonFile("appsettings.json")
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
services.AddSingleton(client)
|
services
|
||||||
|
.AddSingleton(client)
|
||||||
.AddSingleton(commands)
|
.AddSingleton(commands)
|
||||||
.AddMediatR(configuration => configuration.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()))
|
.AddMediatR(configuration => configuration.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly()))
|
||||||
.AddSingleton<DiscordEventListener>()
|
.AddSingleton<DiscordEventListener>()
|
||||||
|
|||||||
@@ -11,7 +11,13 @@
|
|||||||
"LavaLinkHostname": "127.0.0.1",
|
"LavaLinkHostname": "127.0.0.1",
|
||||||
"LavaLinkPort": 2333,
|
"LavaLinkPort": 2333,
|
||||||
"LLM": {
|
"LLM": {
|
||||||
"Url": "http://192.168.50.54:11434",
|
"Url": "http://localhost:7869",
|
||||||
"Model": "gemma"
|
"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"
|
- "2333:2333"
|
||||||
|
|
||||||
ollama:
|
ollama:
|
||||||
volumes:
|
image: ollama/ollama:latest
|
||||||
- ollama:/root/.ollama
|
|
||||||
# comment below to not expose Ollama API outside the container stack
|
|
||||||
ports:
|
ports:
|
||||||
- 11434:11434
|
- 7869:11434
|
||||||
|
volumes:
|
||||||
|
- .:/code
|
||||||
|
- ./ollama/ollama:/root/.ollama
|
||||||
container_name: ollama
|
container_name: ollama
|
||||||
pull_policy: always
|
pull_policy: always
|
||||||
tty: true
|
tty: true
|
||||||
restart: unless-stopped
|
restart: always
|
||||||
image: ollama/ollama:latest
|
environment:
|
||||||
|
- OLLAMA_KEEP_ALIVE=24h
|
||||||
|
- OLLAMA_HOST=0.0.0.0
|
||||||
|
networks:
|
||||||
|
- ollama-docker
|
||||||
|
|
||||||
ollama-webui:
|
ollama-webui:
|
||||||
build:
|
image: ghcr.io/open-webui/open-webui:main
|
||||||
context: .
|
|
||||||
args:
|
|
||||||
OLLAMA_API_BASE_URL: '/ollama/api'
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
image: ollama-webui:latest
|
|
||||||
container_name: ollama-webui
|
container_name: ollama-webui
|
||||||
|
volumes:
|
||||||
|
- ./ollama/ollama-webui:/app/backend/data
|
||||||
depends_on:
|
depends_on:
|
||||||
- ollama
|
- ollama
|
||||||
ports:
|
ports:
|
||||||
- 3000:8080
|
- 8080:8080
|
||||||
environment:
|
environment: # https://docs.openwebui.com/getting-started/env-configuration#default_models
|
||||||
- "OLLAMA_API_BASE_URL=http://ollama:11434/api"
|
- 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:
|
extra_hosts:
|
||||||
- host.docker.internal:host-gateway
|
- host.docker.internal:host-gateway
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
networks:
|
||||||
|
- ollama-docker
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
ollama: {}
|
ollama: {}
|
||||||
@@ -61,4 +70,6 @@ volumes:
|
|||||||
networks:
|
networks:
|
||||||
# create a lavalink network you can add other containers to, to give them access to Lavalink
|
# create a lavalink network you can add other containers to, to give them access to Lavalink
|
||||||
lavalink:
|
lavalink:
|
||||||
name: lavalink
|
name: lavalink
|
||||||
|
ollama-docker:
|
||||||
|
external: false
|
||||||
@@ -1 +1,3 @@
|
|||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
|
read -p "Press enter to continue"
|
||||||
|
|||||||
Reference in New Issue
Block a user