mirror of
https://github.com/ParisNeo/lollms.git
synced 2024-12-18 20:27:58 +00:00
discord bot is ready
This commit is contained in:
parent
e08bb1f052
commit
c1b94f4215
@ -8,30 +8,7 @@ from pathlib import Path
|
||||
from ascii_colors import ASCIIColors
|
||||
from safe_store import TextVectorizer, GenericDataLoader, VisualizationMethod, VectorizationMethod
|
||||
|
||||
current_path = Path(__file__).resolve().parent
|
||||
config_path = current_path / 'discord_config.yaml'
|
||||
data_folder = current_path / "data"
|
||||
data_folder.mkdir(parents=True, exist_ok=True)
|
||||
text_vectorzer = TextVectorizer(
|
||||
database_path=data_folder / "db.json",
|
||||
vectorization_method=VectorizationMethod.TFIDF_VECTORIZER,
|
||||
save_db=True
|
||||
)
|
||||
files = [f for f in data_folder.iterdir() if f.suffix in [".txt", ".md", ".pdf"]]
|
||||
for f in files:
|
||||
txt = GenericDataLoader.read_file(f)
|
||||
text_vectorzer.add_document(f, txt, 512, 128, False)
|
||||
text_vectorzer.index()
|
||||
|
||||
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']
|
||||
contexts={}
|
||||
|
||||
client = commands.Bot(command_prefix='!', intents=discord.Intents.all())
|
||||
|
||||
@ -39,6 +16,34 @@ lollms_paths = LollmsPaths.find_paths(force_local=False, tool_prefix="lollms_dis
|
||||
config = LOLLMSConfig.autoload(lollms_paths)
|
||||
lollms_app = LollmsApplication("lollms_bot", config=config, lollms_paths=lollms_paths)
|
||||
|
||||
current_path = Path(__file__).resolve().parent
|
||||
root_config_path = lollms_app.lollms_paths.personal_configuration_path / "discord_bot"
|
||||
root_config_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
root_data_path = lollms_app.lollms_paths.personal_data_path / "discord_bot"
|
||||
root_data_path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
config_path = root_config_path / 'config.yaml'
|
||||
text_vectorzer = TextVectorizer(
|
||||
database_path=root_data_path / "db.json",
|
||||
vectorization_method=VectorizationMethod.TFIDF_VECTORIZER,
|
||||
save_db=True
|
||||
)
|
||||
files = [f for f in root_data_path.iterdir() if f.suffix in [".txt", ".md", ".pdf"]]
|
||||
for f in files:
|
||||
txt = GenericDataLoader.read_file(f)
|
||||
text_vectorzer.add_document(f, txt, 512, 128, False)
|
||||
text_vectorzer.index()
|
||||
|
||||
if not config_path.exists():
|
||||
bot_token = input("Please enter your bot token: ")
|
||||
config = {'bot_token': bot_token, "summoning_word":"!lollms"}
|
||||
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']
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
@ -55,17 +60,19 @@ async def on_member_join(member):
|
||||
async def on_message(message):
|
||||
if message.author == client.user:
|
||||
return
|
||||
if message.content.startswith('!lollms'):
|
||||
prompt = message.content[6:]
|
||||
if message.content.startswith(config["summoning_word"]):
|
||||
prompt = message.content[len(config["summoning_word"]):]
|
||||
print("Chatting")
|
||||
docs, _ = text_vectorzer.recover_text(prompt,3)
|
||||
docs = '\n'.join(docs)
|
||||
try:
|
||||
docs, _ = text_vectorzer.recover_text(prompt,3)
|
||||
docs = "!#>Documentation:\n"+'\n'.join(docs)
|
||||
except:
|
||||
docs=""
|
||||
context = f"""!#>instruction:
|
||||
{lollms_app.personality.personality_conditioning}
|
||||
!#>Informations:
|
||||
Current model:{lollms_app.config.model_name}
|
||||
Current personality:{lollms_app.personality.name}
|
||||
!#>Documentation:
|
||||
{docs}
|
||||
!#>{message.author.id}: {prompt}
|
||||
!#>{lollms_app.personality.ai_message_prefix}: """
|
@ -158,7 +158,7 @@ Participating personalities:
|
||||
|
||||
def main():
|
||||
# Create the argument parser
|
||||
parser = argparse.ArgumentParser(description='App Description')
|
||||
parser = argparse.ArgumentParser(description='The lollms-settings app is used to configure multiple aspects of the lollms project. Lollms is a multi bindings LLM service that serves multiple LLM models that can generate text out of a prompt.')
|
||||
|
||||
# Add the configuration path argument
|
||||
parser.add_argument('--configuration_path', default=None,
|
||||
@ -170,7 +170,7 @@ def main():
|
||||
parser.add_argument('--default_cfg_path', type=str, default=None, help='Reset all installation status')
|
||||
|
||||
|
||||
parser.add_argument('--tool_prefix', type=str, default="lollms_server_", help='A prefix to define what tool is being used (default lollms_server)')
|
||||
parser.add_argument('--tool_prefix', type=str, default="lollms_server_", help='A prefix to define what tool is being used (default lollms_server_)\nlollms applications prefixes:\n lollms server: lollms_server_\nlollms-elf: lollms_elf_\nlollms-webui: ""\nlollms-discord-bot: lollms_discord_')
|
||||
parser.add_argument('--set_personal_folder_path', type=str, default=None, help='Forces installing and selecting a specific binding')
|
||||
parser.add_argument('--install_binding', type=str, default=None, help='Forces installing and selecting a specific binding')
|
||||
parser.add_argument('--install_model', type=str, default=None, help='Forces installing and selecting a specific model')
|
||||
|
3
setup.py
3
setup.py
@ -26,7 +26,7 @@ def get_all_files(path):
|
||||
|
||||
setuptools.setup(
|
||||
name="lollms",
|
||||
version="5.9.5",
|
||||
version="6.0.0",
|
||||
author="Saifeddine ALOUI",
|
||||
author_email="aloui.saifeddine@gmail.com",
|
||||
description="A python library for AI personality definition",
|
||||
@ -42,6 +42,7 @@ setuptools.setup(
|
||||
'lollms-server = lollms.apps.server:main',
|
||||
'lollms-console = lollms.apps.console:main',
|
||||
'lollms-settings = lollms.apps.settings:main',
|
||||
'lollms-discord = lollms.apps.discord_bot:main',
|
||||
'lollms-playground = lollms.apps.playground:main'
|
||||
],
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user