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
@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"))

View File

@ -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

View File

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

View File

@ -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(