Comment out the llm stuff since its turned off

This commit is contained in:
Luke Robles 2024-11-22 10:51:41 -08:00
parent 9df94546bd
commit 03d1ea586c
4 changed files with 53 additions and 68 deletions

View File

@ -118,64 +118,64 @@ async def fix_social_media_links(ctx):
return return
@bot.event # @bot.event
async def on_message(ctx): # async def on_message(ctx):
if str(bot.user.id) in ctx.content: # if str(bot.user.id) in ctx.content:
# if ctx.author.id == core_utils.my_id: # # if ctx.author.id == core_utils.my_id:
# pass # # pass
# elif ctx.guild.id not in core_utils.my_guilds: # # elif ctx.guild.id not in core_utils.my_guilds:
# return # # 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"]: # if ctx.author.id in llm_rules["disallowed_users"]:
responses = [ # responses = [
"You cant do that right now", # "You cant do that right now",
"You cant use this feature right now", # "You cant use this feature right now",
"You're on time out from this", # "You're on time out from this",
] # ]
await ctx.respond(random.choice(responses)) # await ctx.respond(random.choice(responses))
return # return
url = f"http://{core_utils.ein_ip}:1337/v1/chat/completions" # url = f"http://{core_utils.ein_ip}:1337/v1/chat/completions"
instructions = llm_rules["prompt"] # instructions = llm_rules["prompt"]
payload = { # payload = {
"messages": [ # "messages": [
{ # {
"content": instructions, # "content": instructions,
"role": "system", # "role": "system",
}, # },
{ # {
"content": ctx.content.replace(str(bot.user.id), "").replace( # "content": ctx.content.replace(str(bot.user.id), "").replace(
"<@> ", "" # "<@> ", ""
), # ),
"role": "user", # "role": "user",
}, # },
], # ],
"model": llm_rules["model"], # "model": llm_rules["model"],
"stream": False, # "stream": False,
"max_tokens": 4096, # "max_tokens": 4096,
"stop": llm_rules["stop_tokens"], # "stop": llm_rules["stop_tokens"],
"frequency_penalty": 0, # "frequency_penalty": 0,
"presence_penalty": 0, # "presence_penalty": 0,
"temperature": 0.7, # "temperature": 0.7,
"top_p": 0.95, # "top_p": 0.95,
} # }
headers = {"Content-Type": "application/json"} # headers = {"Content-Type": "application/json"}
try: # try:
await ctx.channel.trigger_typing() # await ctx.channel.trigger_typing()
response = requests.post(url, json=payload, headers=headers) # response = requests.post(url, json=payload, headers=headers)
answer = response.json()["choices"][0]["message"]["content"] # answer = response.json()["choices"][0]["message"]["content"]
if len(answer) > 2000: # if len(answer) > 2000:
await ctx.reply(answer[:2000].replace("<|end_of_turn|>", "")) # await ctx.reply(answer[:2000].replace("<|end_of_turn|>", ""))
await ctx.reply(answer[2000:].replace("<|end_of_turn|>", "")) # await ctx.reply(answer[2000:].replace("<|end_of_turn|>", ""))
else: # else:
await ctx.reply(answer.replace("<|end_of_turn|>", "")) # await ctx.reply(answer.replace("<|end_of_turn|>", ""))
except KeyError: # except KeyError:
await ctx.reply("Somethings wrong, maybe the LLM crashed") # await ctx.reply("Somethings wrong, maybe the LLM crashed")
bot.run(os.getenv("discord_token")) bot.run(os.getenv("discord_token"))

View File

@ -220,9 +220,7 @@ class ServerUtils(commands.Cog):
# Check that the role/channel doesnt already exist # Check that the role/channel doesnt already exist
# returns either a string or None, so we'll proceed on the None condition # 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): if discord.utils.find(lambda r: r.name == channel_role_name, ctx.guild.roles):
await ctx.send( await ctx.send(f":x: A role named `{channel_role_name}` already exists :x:")
":x: A role named `%s` already exists :x:" % channel_role_name
)
return return
# Create a role and assign it a random color # Create a role and assign it a random color

View File

@ -5,7 +5,6 @@ import core_utils
import discord import discord
import os import os
import json import json
import random
import requests import requests
import tarkov import tarkov

View File

@ -1,6 +1,5 @@
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import requests import requests
import random
def request_wiki(url, heading): 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")] 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): def query_tarkov_api(query):
headers = {"Content-Type": "application/json"} headers = {"Content-Type": "application/json"}
return requests.post( return requests.post(