mirror of
https://github.com/Myxelium/Lunaris2.0.git
synced 2026-04-13 16:10:36 +00:00
Compare commits
20 Commits
1713131731
...
0.1.6
| Author | SHA1 | Date | |
|---|---|---|---|
| d72676c7e0 | |||
| b30d47e351 | |||
| 3ce0df7eaf | |||
| e88e67f913 | |||
| 5053553182 | |||
| 327ccc9675 | |||
| cbc99c2773 | |||
| d56215f685 | |||
| 967bee923a | |||
| f8e6854569 | |||
| 03150a3d04 | |||
| 32b6e09336 | |||
| e3df4505fe | |||
| 3daf18e053 | |||
| 54c5c68ba6 | |||
| e16ff9cfaf | |||
| a1d20fd732 | |||
| 3d7655a902 | |||
| 8ddcf31da7 | |||
| 80a7c19b20 |
33
.github/workflows/dotnet.yml
vendored
33
.github/workflows/dotnet.yml
vendored
@@ -7,10 +7,13 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: windows-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0 # required for github-action-get-previous-tag
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v1
|
||||
@@ -27,15 +30,19 @@ jobs:
|
||||
run: dotnet publish ./Bot/Lunaris2.csproj --configuration Release --output ./out
|
||||
|
||||
- name: Zip the build
|
||||
run: 7z a -tzip ./out/Bot.zip ./out/*
|
||||
run: 7z a -tzip ./out/Lunaris.zip ./out/*
|
||||
|
||||
- name: Get the tag name
|
||||
id: get_tag
|
||||
run: echo "::set-output name=tag::${GITHUB_REF#refs/tags/}"
|
||||
- name: Get previous tag
|
||||
id: previoustag
|
||||
uses: 'WyriHaximus/github-action-get-previous-tag@v1'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
run: echo "::set-output name=version::$(date +%s).${{ github.run_id }}"
|
||||
- name: Get next minor version
|
||||
id: semver
|
||||
uses: 'WyriHaximus/github-action-next-semvers@v1'
|
||||
with:
|
||||
version: ${{ steps.previoustag.outputs.tag }}
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
@@ -43,8 +50,8 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
||||
with:
|
||||
tag_name: ${{ steps.get_version.outputs.version }}
|
||||
release_name: Release v${{ steps.get_version.outputs.version }}
|
||||
tag_name: ${{ steps.semver.outputs.patch }}
|
||||
release_name: Release ${{ steps.semver.outputs.patch }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
@@ -55,6 +62,6 @@ jobs:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./out/Bot.zip
|
||||
asset_name: Bot.zip
|
||||
asset_path: ./out/Lunaris.zip
|
||||
asset_name: Lunaris.zip
|
||||
asset_content_type: application/zip
|
||||
|
||||
68
Bot/Handler/ChatCommand/ChatHandler.cs
Normal file
68
Bot/Handler/ChatCommand/ChatHandler.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System.Text;
|
||||
using Discord.WebSocket;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Options;
|
||||
using OllamaSharp;
|
||||
|
||||
namespace Lunaris2.Handler.ChatCommand
|
||||
{
|
||||
public record ChatCommand(SocketMessage Message, string FilteredMessage) : IRequest;
|
||||
|
||||
public class ChatHandler : IRequestHandler<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)
|
||||
{
|
||||
SelectedModel = chatSettings.Value.Model
|
||||
};
|
||||
}
|
||||
|
||||
public async Task Handle(ChatCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
var channelId = command.Message.Channel.Id;
|
||||
_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();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(userMessage))
|
||||
{
|
||||
await command.Message.Channel.SendMessageAsync("Am I expected to read your mind?");
|
||||
setTyping.Dispose();
|
||||
return;
|
||||
}
|
||||
|
||||
var response = await GenerateResponse(userMessage, channelId, cancellationToken);
|
||||
await command.Message.Channel.SendMessageAsync(response);
|
||||
|
||||
setTyping.Dispose();
|
||||
}
|
||||
|
||||
private async Task<string> GenerateResponse(string userMessage, ulong channelId, CancellationToken cancellationToken)
|
||||
{
|
||||
var response = new StringBuilder();
|
||||
|
||||
if (_chatContexts[channelId] == null)
|
||||
{
|
||||
_chatContexts[channelId] = _ollama.Chat(stream => response.Append(stream.Message?.Content ?? ""));
|
||||
}
|
||||
|
||||
await _chatContexts[channelId].Send(userMessage, cancellationToken);
|
||||
|
||||
return response.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
14
Bot/Handler/ChatCommand/ChatSettings.cs
Normal file
14
Bot/Handler/ChatCommand/ChatSettings.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Lunaris2.Handler.ChatCommand;
|
||||
|
||||
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; }
|
||||
}
|
||||
8
Bot/Handler/ChatCommand/readme.md
Normal file
8
Bot/Handler/ChatCommand/readme.md
Normal file
@@ -0,0 +1,8 @@
|
||||
## Ollama - Large Language Model Chat - Handler
|
||||
|
||||
This handler "owns" the logic for accessing the ollama api, which runs the transformer model.
|
||||
|
||||
> How to get started with a local chat bot see: [Run LLMs Locally using Ollama](https://marccodess.medium.com/run-llms-locally-using-ollama-8f04dd9b14f9)
|
||||
|
||||
Assuming you are on the same network as the Ollama server you should configure it to be accessible to other machines on the network, however this is only required if you aren't running it from localhost relative to the bot.
|
||||
See: [How do I configure Ollama server?](https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-configure-ollama-server)
|
||||
@@ -1,34 +1,37 @@
|
||||
using Lunaris2.Handler.GoodByeCommand;
|
||||
using Lunaris2.Handler.MusicPlayer.JoinCommand;
|
||||
using Lunaris2.Handler.MusicPlayer.PlayCommand;
|
||||
using Lunaris2.Handler.MusicPlayer.SkipCommand;
|
||||
using System.Text.RegularExpressions;
|
||||
using Discord.WebSocket;
|
||||
using Lunaris2.Notification;
|
||||
using Lunaris2.SlashCommand;
|
||||
using MediatR;
|
||||
|
||||
namespace Lunaris2.Handler;
|
||||
|
||||
public class MessageReceivedHandler(ISender mediator) : INotificationHandler<MessageReceivedNotification>
|
||||
public class MessageReceivedHandler : INotificationHandler<MessageReceivedNotification>
|
||||
{
|
||||
private readonly DiscordSocketClient _client;
|
||||
private readonly ISender _mediatir;
|
||||
|
||||
public MessageReceivedHandler(DiscordSocketClient client, ISender mediatir)
|
||||
{
|
||||
_client = client;
|
||||
_mediatir = mediatir;
|
||||
}
|
||||
|
||||
public async Task Handle(MessageReceivedNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
switch (notification.Message.CommandName)
|
||||
await BotMentioned(notification, cancellationToken);
|
||||
}
|
||||
|
||||
private async Task BotMentioned(MessageReceivedNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
case Command.Hello.Name:
|
||||
await mediator.Send(new HelloCommand.HelloCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
case Command.Goodbye.Name:
|
||||
await mediator.Send(new GoodbyeCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
case Command.Join.Name:
|
||||
await mediator.Send(new JoinCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
case Command.Play.Name:
|
||||
await mediator.Send(new PlayCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
case Command.Skip.Name:
|
||||
await mediator.Send(new SkipCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
if (notification.Message.MentionedUsers.Any(user => user.Id == _client.CurrentUser.Id))
|
||||
{
|
||||
// The bot was mentioned
|
||||
const string pattern = "<.*?>";
|
||||
const string replacement = "";
|
||||
var regex = new Regex(pattern);
|
||||
var messageContent = regex.Replace(notification.Message.Content, replacement);
|
||||
|
||||
await _mediatir.Send(new ChatCommand.ChatCommand(notification.Message, messageContent), cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
```mermaid
|
||||
flowchart LR
|
||||
flowchart TD
|
||||
PlayHandler --> EnsureConnected
|
||||
EnsureConnected --> GetPlayer
|
||||
GetPlayer --> SearchAsync
|
||||
@@ -8,6 +8,8 @@ flowchart LR
|
||||
PlayTrack --> NowPlayingEmbed
|
||||
```
|
||||
|
||||
## Steps in the code
|
||||
|
||||
| Name | Description |
|
||||
|--|--|
|
||||
| PlayHandler | Holds the logic for playing songs |
|
||||
@@ -18,3 +20,16 @@ flowchart LR
|
||||
| PlayTrack | Plays the song |
|
||||
|
||||
There is also OnTrackEnd, when it get called an attempt is made to play the next song in queue.
|
||||
|
||||
## Short explaination for some of the variables used:
|
||||
|
||||
| Variable | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| `_lavaNode` | `LavaNode` | An instance of the `LavaNode` class, used to interact with the LavaLink server for playing music in Discord voice channels. |
|
||||
| `_client` | `DiscordSocketClient` | An instance of the `DiscordSocketClient` class, used to interact with the Discord API for sending messages, joining voice channels, etc. |
|
||||
| `_musicEmbed` | `MusicEmbed` | An instance of a custom `MusicEmbed` class, used to create and send embed messages related to the music player's current status. |
|
||||
| `context` | `SocketSlashCommand` | An instance of the `SocketSlashCommand` class, representing a slash command received from Discord. Used to get information about the command and to respond to it. |
|
||||
| `player` | `LavaPlayer` | An instance of the `LavaPlayer` class, representing a music player connected to a specific voice channel. Used to play, pause, skip, and queue tracks. |
|
||||
| `guildMessageIds` | `Dictionary<ulong, List<ulong>>` | A dictionary that maps guild IDs to lists of message IDs. Used to keep track of messages sent by the bot in each guild, allowing the bot to delete its old messages when it sends new ones. |
|
||||
| `songName` | `string` | A string that represents the name or URL of a song to play. Used to search for and queue tracks. |
|
||||
| `searchResponse` | `SearchResponse` | An instance of the `SearchResponse` class, representing the result of a search for tracks. Used to get the tracks that were found and queue them in the player. |
|
||||
|
||||
34
Bot/Handler/SlashCommandReceivedHandler.cs
Normal file
34
Bot/Handler/SlashCommandReceivedHandler.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Lunaris2.Handler.GoodByeCommand;
|
||||
using Lunaris2.Handler.MusicPlayer.JoinCommand;
|
||||
using Lunaris2.Handler.MusicPlayer.PlayCommand;
|
||||
using Lunaris2.Handler.MusicPlayer.SkipCommand;
|
||||
using Lunaris2.Notification;
|
||||
using Lunaris2.SlashCommand;
|
||||
using MediatR;
|
||||
|
||||
namespace Lunaris2.Handler;
|
||||
|
||||
public class SlashCommandReceivedHandler(ISender mediator) : INotificationHandler<SlashCommandReceivedNotification>
|
||||
{
|
||||
public async Task Handle(SlashCommandReceivedNotification notification, CancellationToken cancellationToken)
|
||||
{
|
||||
switch (notification.Message.CommandName)
|
||||
{
|
||||
case Command.Hello.Name:
|
||||
await mediator.Send(new HelloCommand.HelloCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
case Command.Goodbye.Name:
|
||||
await mediator.Send(new GoodbyeCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
case Command.Join.Name:
|
||||
await mediator.Send(new JoinCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
case Command.Play.Name:
|
||||
await mediator.Send(new PlayCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
case Command.Skip.Name:
|
||||
await mediator.Send(new SkipCommand(notification.Message), cancellationToken);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,9 +16,11 @@
|
||||
<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" />
|
||||
<PackageReference Include="OllamaSharp" Version="1.1.10" />
|
||||
<PackageReference Include="Victoria" Version="6.0.23.324" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -19,13 +19,19 @@ public class DiscordEventListener(DiscordSocketClient client, IServiceScopeFacto
|
||||
|
||||
public async Task StartAsync()
|
||||
{
|
||||
client.SlashCommandExecuted += OnMessageReceivedAsync;
|
||||
client.SlashCommandExecuted += OnSlashCommandRecievedAsync;
|
||||
client.MessageReceived += OnMessageReceivedAsync;
|
||||
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task OnMessageReceivedAsync(SocketSlashCommand arg)
|
||||
private async Task OnMessageReceivedAsync(SocketMessage arg)
|
||||
{
|
||||
await Mediator.Publish(new MessageReceivedNotification(arg), _cancellationToken);
|
||||
}
|
||||
|
||||
private async Task OnSlashCommandRecievedAsync(SocketSlashCommand arg)
|
||||
{
|
||||
await Mediator.Publish(new SlashCommandReceivedNotification(arg), _cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using MediatR;
|
||||
|
||||
namespace Lunaris2.Notification;
|
||||
|
||||
public class MessageReceivedNotification(SocketSlashCommand message) : INotification
|
||||
public class MessageReceivedNotification(SocketMessage message) : INotification
|
||||
{
|
||||
public SocketSlashCommand Message { get; } = message ?? throw new ArgumentNullException(nameof(message));
|
||||
public SocketMessage Message { get; } = message ?? throw new ArgumentNullException(nameof(message));
|
||||
}
|
||||
9
Bot/Notification/SlashCommandReceivedNotification.cs
Normal file
9
Bot/Notification/SlashCommandReceivedNotification.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Discord.WebSocket;
|
||||
using MediatR;
|
||||
|
||||
namespace Lunaris2.Notification;
|
||||
|
||||
public class SlashCommandReceivedNotification(SocketSlashCommand message) : INotification
|
||||
{
|
||||
public SocketSlashCommand Message { get; } = message ?? throw new ArgumentNullException(nameof(message));
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using Discord;
|
||||
using Discord.Commands;
|
||||
using Discord.Interactions;
|
||||
using Discord.WebSocket;
|
||||
using Lunaris2.Handler.ChatCommand;
|
||||
using Lunaris2.Handler.MusicPlayer;
|
||||
using Lunaris2.Notification;
|
||||
using Lunaris2.SlashCommand;
|
||||
@@ -41,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>()
|
||||
@@ -54,7 +56,9 @@ public class Program
|
||||
nodeConfiguration.Authorization = configuration["LavaLinkPassword"];
|
||||
})
|
||||
.AddSingleton<LavaNode>()
|
||||
.AddSingleton<MusicEmbed>();
|
||||
.AddSingleton<MusicEmbed>()
|
||||
.AddSingleton<ChatSettings>()
|
||||
.Configure<ChatSettings>(configuration.GetSection("LLM"));
|
||||
|
||||
client.Ready += () => Client_Ready(client);
|
||||
client.Log += Log;
|
||||
|
||||
@@ -2,9 +2,14 @@
|
||||
```mermaid
|
||||
flowchart TD
|
||||
Program[Program] -->|Register| EventListener
|
||||
EventListener[DiscordEventListener] --> A
|
||||
EventListener[DiscordEventListener] --> A[MessageReceivedHandler]
|
||||
|
||||
A[MessageReceivedHandler] -->|Message| C{Send to correct command by
|
||||
EventListener[DiscordEventListener] --> A2[SlashCommandReceivedHandler]
|
||||
|
||||
A --> |Message| f{If bot is mentioned}
|
||||
f --> |ChatCommand| v[ChatHandler]
|
||||
|
||||
A2[SlashCommandReceivedHandler] -->|Message| C{Send to correct command by
|
||||
looking at commandName}
|
||||
|
||||
C -->|JoinCommand| D[JoinHandler]
|
||||
@@ -12,9 +17,33 @@ flowchart TD
|
||||
C -->|HelloCommand| F[HelloHandler]
|
||||
C -->|GoodbyeCommand| G[GoodbyeHandler]
|
||||
```
|
||||
|
||||
Program registers an event listener ```DiscordEventListener``` which publish a message :
|
||||
|
||||
```c#
|
||||
await Mediator.Publish(new MessageReceivedNotification(arg), _cancellationToken);
|
||||
```
|
||||
|
||||
|Name| Description |
|
||||
|--|--|
|
||||
| SlashCommandReceivedHandler | Handles commands using ``/`` from any Discord Guild/Server. |
|
||||
| MessageReceivedHandler| Listens to **all** messages. |
|
||||
|
||||
## Handler integrations
|
||||
```mermaid
|
||||
flowchart TD
|
||||
D[JoinHandler] --> Disc[Discord Api]
|
||||
E[PlayHandler] --> Disc[Discord Api]
|
||||
F[HelloHandler] --> Disc[Discord Api]
|
||||
G[GoodbyeHandler] --> Disc[Discord Api]
|
||||
v[ChatHandler] --> Disc[Discord Api]
|
||||
v --> o[Ollama Server]
|
||||
o --> v
|
||||
E --> Lava[Lavalink]
|
||||
```
|
||||
|Name| Description |
|
||||
|--|--|
|
||||
| JoinHandler| Handles the logic for **just** joining a voice channel. |
|
||||
| PlayHandler| Handles the logic for joining and playing music in a voice channel. |
|
||||
| HelloHandler| Responds with Hello. (Dummy handler, will be removed)|
|
||||
| GoodbyeHandler| Responds with Goodbye. (Dummy handler, will be removed)|
|
||||
| ChatHandler| Handles the logic for LLM chat with user. |
|
||||
|
||||
@@ -9,5 +9,15 @@
|
||||
"Token": "discordToken",
|
||||
"LavaLinkPassword": "youshallnotpass",
|
||||
"LavaLinkHostname": "127.0.0.1",
|
||||
"LavaLinkPort": 2333
|
||||
"LavaLinkPort": 2333,
|
||||
"LLM": {
|
||||
"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:"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
10
README.md
10
README.md
@@ -7,6 +7,7 @@ Lunaris2 is a Discord bot designed to play music in your server's voice channels
|
||||
- Play music from YouTube directly in your Discord server.
|
||||
- Skip tracks, pause, and resume playback.
|
||||
- Queue system to line up your favorite tracks.
|
||||
- Local LLM (AI chatbot) that answers on @mentions in Discord chat. See more about it below.
|
||||
|
||||
## Setup
|
||||
|
||||
@@ -17,6 +18,11 @@ Lunaris2 is a Discord bot designed to play music in your server's voice channels
|
||||
5. Make sure you got docker installed. And run the file ``start-services.sh``, make sure you got git-bash installed.
|
||||
6. Now you can start the project and run the application.
|
||||
|
||||
## LLM
|
||||
Lunaris supports AI chat using a large language model, this is done by hosting the LLM locally, in this case Docker will set it up for you when you run the start-services script.
|
||||
|
||||
The LLM is run using Ollama see more about Ollama [here](https://ollama.com/). Running LLM locally requires much resources from your system, minimum requirements is at least 8GB of ram. If your don't have enought ram, select a LLM model in the [appsettings file](https://github.com/Myxelium/Lunaris2.0/blob/master/Bot/appsettings.json#L15) that requires less of your system.
|
||||
|
||||
## Usage
|
||||
|
||||
- `/play <song>`: Plays the specified song in the voice channel you're currently in.
|
||||
@@ -25,7 +31,3 @@ Lunaris2 is a Discord bot designed to play music in your server's voice channels
|
||||
## Contributing
|
||||
|
||||
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](https://choosealicense.com/licenses/mit/)
|
||||
|
||||
@@ -24,7 +24,52 @@ services:
|
||||
ports:
|
||||
# you only need this if you want to make your lavalink accessible from outside of containers
|
||||
- "2333:2333"
|
||||
|
||||
ollama:
|
||||
image: ollama/ollama:latest
|
||||
ports:
|
||||
- 7869:11434
|
||||
volumes:
|
||||
- .:/code
|
||||
- ./ollama/ollama:/root/.ollama
|
||||
container_name: ollama
|
||||
pull_policy: always
|
||||
tty: true
|
||||
restart: always
|
||||
environment:
|
||||
- OLLAMA_KEEP_ALIVE=24h
|
||||
- OLLAMA_HOST=0.0.0.0
|
||||
networks:
|
||||
- ollama-docker
|
||||
|
||||
ollama-webui:
|
||||
image: ghcr.io/open-webui/open-webui:main
|
||||
container_name: ollama-webui
|
||||
volumes:
|
||||
- ./ollama/ollama-webui:/app/backend/data
|
||||
depends_on:
|
||||
- ollama
|
||||
ports:
|
||||
- 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: {}
|
||||
|
||||
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