2025-01-07 22:59:01 -05:00
|
|
|
import discord
|
2025-01-08 19:46:07 -05:00
|
|
|
from model_manager import ModelManager
|
2025-01-07 22:59:01 -05:00
|
|
|
import os
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
2025-01-08 19:46:07 -05:00
|
|
|
# Load environment variables
|
2025-01-07 22:59:01 -05:00
|
|
|
load_dotenv()
|
|
|
|
|
2025-01-08 19:46:07 -05:00
|
|
|
# Discord bot setup
|
2025-01-07 22:59:01 -05:00
|
|
|
intents = discord.Intents.default()
|
|
|
|
intents.messages = True
|
|
|
|
intents.message_content = True
|
|
|
|
client = discord.Client(intents=intents)
|
|
|
|
|
2025-01-08 19:46:07 -05:00
|
|
|
# Initialize the ModelManager
|
|
|
|
USE_CUSTOM_MODEL = True
|
|
|
|
OLLAMA_URL = None # Set to your Ollama endpoint if needed
|
|
|
|
model_manager = ModelManager(use_custom_model=USE_CUSTOM_MODEL, ollama_url=OLLAMA_URL)
|
2025-01-07 22:59:01 -05:00
|
|
|
|
|
|
|
@client.event
|
|
|
|
async def on_ready():
|
2025-01-08 19:46:07 -05:00
|
|
|
print(f"Logged in as {client.user}")
|
2025-01-07 22:59:01 -05:00
|
|
|
|
|
|
|
@client.event
|
|
|
|
async def on_message(message):
|
|
|
|
if message.author == client.user:
|
|
|
|
return
|
|
|
|
|
2025-01-08 19:46:07 -05:00
|
|
|
# Generate response
|
|
|
|
user_input = message.content
|
|
|
|
bot_response = model_manager.generate_response(user_input)
|
|
|
|
|
|
|
|
await message.channel.send(bot_response)
|
2025-01-07 22:59:01 -05:00
|
|
|
|
2025-01-08 19:46:07 -05:00
|
|
|
client.run(os.getenv("DISCORD_TOKEN"))
|