From 03d1ea586c6a90b0bb9b0718e68b87af6da282b6 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Fri, 22 Nov 2024 10:51:41 -0800 Subject: [PATCH] Comment out the llm stuff since its turned off --- app/bot.py | 104 +++++++++++++++++++-------------------- app/cogs/server_utils.py | 4 +- app/cogs/tarkov.py | 1 - app/tarkov.py | 12 ----- 4 files changed, 53 insertions(+), 68 deletions(-) diff --git a/app/bot.py b/app/bot.py index cc23b6eb..d0a46d13 100755 --- a/app/bot.py +++ b/app/bot.py @@ -118,64 +118,64 @@ async def fix_social_media_links(ctx): return -@bot.event -async def on_message(ctx): - if str(bot.user.id) in ctx.content: - # if ctx.author.id == core_utils.my_id: - # pass - # elif ctx.guild.id not in core_utils.my_guilds: - # return +# @bot.event +# async def on_message(ctx): +# if str(bot.user.id) in ctx.content: +# # if ctx.author.id == core_utils.my_id: +# # pass +# # elif ctx.guild.id not in core_utils.my_guilds: +# # return - llm_rules = requests.get(core_utils.json_endpoint + "rules.json").json() +# llm_rules = requests.get(core_utils.json_endpoint + "rules.json").json() - if ctx.author.id in llm_rules["disallowed_users"]: - responses = [ - "You cant do that right now", - "You cant use this feature right now", - "You're on time out from this", - ] - await ctx.respond(random.choice(responses)) - return +# if ctx.author.id in llm_rules["disallowed_users"]: +# responses = [ +# "You cant do that right now", +# "You cant use this feature right now", +# "You're on time out from this", +# ] +# await ctx.respond(random.choice(responses)) +# return - url = f"http://{core_utils.ein_ip}:1337/v1/chat/completions" - instructions = llm_rules["prompt"] +# url = f"http://{core_utils.ein_ip}:1337/v1/chat/completions" +# instructions = llm_rules["prompt"] - payload = { - "messages": [ - { - "content": instructions, - "role": "system", - }, - { - "content": ctx.content.replace(str(bot.user.id), "").replace( - "<@> ", "" - ), - "role": "user", - }, - ], - "model": llm_rules["model"], - "stream": False, - "max_tokens": 4096, - "stop": llm_rules["stop_tokens"], - "frequency_penalty": 0, - "presence_penalty": 0, - "temperature": 0.7, - "top_p": 0.95, - } - headers = {"Content-Type": "application/json"} +# payload = { +# "messages": [ +# { +# "content": instructions, +# "role": "system", +# }, +# { +# "content": ctx.content.replace(str(bot.user.id), "").replace( +# "<@> ", "" +# ), +# "role": "user", +# }, +# ], +# "model": llm_rules["model"], +# "stream": False, +# "max_tokens": 4096, +# "stop": llm_rules["stop_tokens"], +# "frequency_penalty": 0, +# "presence_penalty": 0, +# "temperature": 0.7, +# "top_p": 0.95, +# } +# headers = {"Content-Type": "application/json"} - try: - await ctx.channel.trigger_typing() - response = requests.post(url, json=payload, headers=headers) - answer = response.json()["choices"][0]["message"]["content"] +# try: +# await ctx.channel.trigger_typing() +# response = requests.post(url, json=payload, headers=headers) +# answer = response.json()["choices"][0]["message"]["content"] - if len(answer) > 2000: - await ctx.reply(answer[:2000].replace("<|end_of_turn|>", "")) - await ctx.reply(answer[2000:].replace("<|end_of_turn|>", "")) - else: - await ctx.reply(answer.replace("<|end_of_turn|>", "")) - except KeyError: - await ctx.reply("Somethings wrong, maybe the LLM crashed") +# if len(answer) > 2000: +# await ctx.reply(answer[:2000].replace("<|end_of_turn|>", "")) +# await ctx.reply(answer[2000:].replace("<|end_of_turn|>", "")) +# else: +# await ctx.reply(answer.replace("<|end_of_turn|>", "")) +# except KeyError: +# await ctx.reply("Somethings wrong, maybe the LLM crashed") bot.run(os.getenv("discord_token")) diff --git a/app/cogs/server_utils.py b/app/cogs/server_utils.py index 104ae227..2bc8ac27 100755 --- a/app/cogs/server_utils.py +++ b/app/cogs/server_utils.py @@ -220,9 +220,7 @@ class ServerUtils(commands.Cog): # Check that the role/channel doesnt already exist # returns either a string or None, so we'll proceed on the None condition if discord.utils.find(lambda r: r.name == channel_role_name, ctx.guild.roles): - await ctx.send( - ":x: A role named `%s` already exists :x:" % channel_role_name - ) + await ctx.send(f":x: A role named `{channel_role_name}` already exists :x:") return # Create a role and assign it a random color diff --git a/app/cogs/tarkov.py b/app/cogs/tarkov.py index 5b3a6618..7413d268 100755 --- a/app/cogs/tarkov.py +++ b/app/cogs/tarkov.py @@ -5,7 +5,6 @@ import core_utils import discord import os import json -import random import requests import tarkov diff --git a/app/tarkov.py b/app/tarkov.py index 795d2edc..d17b459e 100755 --- a/app/tarkov.py +++ b/app/tarkov.py @@ -1,6 +1,5 @@ from bs4 import BeautifulSoup import requests -import random def request_wiki(url, heading): @@ -12,17 +11,6 @@ def request_wiki(url, heading): return [link.text for link in h2_heading.find_next("div").find_all("a")] -def allowed_level_roll(): - message = "None" - allowed = random.randint(0, 1) == 1 - if allowed: - message = "Allowed" - message += ", Trader level: " + random.choice( - [str(random.randint(1, 4)), "Any level"] - ) - return message - - def query_tarkov_api(query): headers = {"Content-Type": "application/json"} return requests.post(