From 19bb72ef1cf1c4f291fd858ca2a44cef785c301c Mon Sep 17 00:00:00 2001 From: Saifeddine ALOUI Date: Sun, 22 Oct 2023 13:48:17 +0200 Subject: [PATCH] updated attributes showing --- lollms/apps/discord_server/.gitignore | 1 + lollms/apps/discord_server/__init__.py | 36 +++++++++++++++++++++----- lollms/apps/discord_server/models_zoo | 1 + lollms/binding.py | 10 +++++-- 4 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 lollms/apps/discord_server/.gitignore create mode 160000 lollms/apps/discord_server/models_zoo diff --git a/lollms/apps/discord_server/.gitignore b/lollms/apps/discord_server/.gitignore new file mode 100644 index 00000000..91ca2e34 --- /dev/null +++ b/lollms/apps/discord_server/.gitignore @@ -0,0 +1 @@ +discord_config.yaml \ No newline at end of file diff --git a/lollms/apps/discord_server/__init__.py b/lollms/apps/discord_server/__init__.py index d702adf8..7c509798 100644 --- a/lollms/apps/discord_server/__init__.py +++ b/lollms/apps/discord_server/__init__.py @@ -1,27 +1,49 @@ import discord from discord.ext import commands from lollms.apps.console import Conversation +import yaml +from pathlib import Path -bot = commands.Bot(command_prefix='!') +config_path = Path(__file__).resolve().parent / 'discord_config.yaml' + +if not config_path.exists(): + bot_token = input("Please enter your bot token: ") + config = {'bot_token': bot_token} + with open(config_path, 'w') as config_file: + yaml.safe_dump(config, config_file) +else: + with open(config_path, 'r') as config_file: + config = yaml.safe_load(config_file) + bot_token = config['bot_token'] + +bot = commands.Bot(command_prefix='!', intents=discord.Intents.all()) class ChatBot(commands.Cog): def __init__(self, bot): self.bot = bot self.cv = Conversation() + self.context = {} @commands.command() async def chat(self, ctx, *, prompt): - full_discussion = "" + self.context[ctx.author.id] = f'{self.context.get(ctx.author.id, "")}:{prompt}\nlollms_chatbot:' def callback(text, type=None): - full_discussion += text + self.context[ctx.author.id] += text return True - self.cv.safe_generate(full_discussion, callback=callback) - await ctx.send(full_discussion) - + self.cv.safe_generate(self.context[ctx.author.id], callback=callback) + await ctx.send(self.context[ctx.author.id]) + @commands.command() + async def install(self, ctx): + response = "To install lollms, make sure you have installed the currently supported python version (consult the repository to verify what version is currently supported, but as of 10/22/2023, the version is 3.10).\nThen you can follow these steps:\n1. Open your command line interface.\n2. Navigate to the directory where you want to install lollms.\n3. Run the following command to clone the lollms repository: `git clone https://github.com/lollms/lollms.git`.\n4. Once the repository is cloned, navigate into the lollms directory.\n5. Run `pip install -r requirements.txt` to install the required dependencies.\n6. You can now use lollms by importing it in your Python code." + @commands.Cog.listener() + async def on_member_join(self, member): + channel = member.guild.system_channel + if channel is not None: + await channel.send(f'Welcome {member.mention} to the server! How can I assist you today?') @bot.event async def on_ready(): print(f'Logged in as {bot.user}') print('------') bot.add_cog(ChatBot(bot)) -bot.run('YOUR_BOT_TOKEN') +bot.run(bot_token) diff --git a/lollms/apps/discord_server/models_zoo b/lollms/apps/discord_server/models_zoo new file mode 160000 index 00000000..7737d1a3 --- /dev/null +++ b/lollms/apps/discord_server/models_zoo @@ -0,0 +1 @@ +Subproject commit 7737d1a3737467ff1b13e3824f54824a7b42be43 diff --git a/lollms/binding.py b/lollms/binding.py index 19846bcf..f1e8421c 100644 --- a/lollms/binding.py +++ b/lollms/binding.py @@ -120,8 +120,14 @@ def print_class_attributes(self, cls): if isinstance(attr, property) or isinstance(attr, type): continue value = getattr(cls, attr) - ASCIIColors.yellow("{}: {}".format(attr, value)) - + if attr!="tensor_file_map": + ASCIIColors.red(f"{attr}: ",end="") + ASCIIColors.yellow(f"{value}") + else: + ASCIIColors.red(f"{attr}: ") + for k in value.keys(): + ASCIIColors.yellow(f"{k}") + def get_parameter_info(self, cls): # Get the signature of the class sig = inspect.signature(cls)