Skip to content

Commit

Permalink
updated attributes showing
Browse files Browse the repository at this point in the history
  • Loading branch information
ParisNeo committed Oct 22, 2023
1 parent 30e5c79 commit 19bb72e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
1 change: 1 addition & 0 deletions lollms/apps/discord_server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
discord_config.yaml
36 changes: 29 additions & 7 deletions lollms/apps/discord_server/__init__.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions lollms/apps/discord_server/models_zoo
Submodule models_zoo added at 7737d1
10 changes: 8 additions & 2 deletions lollms/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 19bb72e

Please sign in to comment.