From b8bdb95acb7fe1f2af1a45569808131f21f8fc2a Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Mon, 8 Apr 2024 13:44:45 -0700 Subject: [PATCH] Turn gpt back on --- app/bot.py | 72 ++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/app/bot.py b/app/bot.py index f6a786cf..1ed0c0bc 100755 --- a/app/bot.py +++ b/app/bot.py @@ -151,47 +151,43 @@ async def fix_social_media_links(ctx): return -# @bot.event -# async def on_message(ctx): -# if str(bot.user.id) in ctx.content: +@bot.event +async def on_message(ctx): + if str(bot.user.id) in ctx.content: -# url = "http://192.168.1.52:1337/v1/chat/completions" -# bot_prompt = ( -# "You are a helpful assistant. You will answer questions conciesely" -# "and as detailed as possible. You are based out of the United states in California." -# ) + url = "http://192.168.1.52:1337/v1/chat/completions" + bot_prompt = ( + "You are a helpful assistant. You will answer questions conciesely" + "and as detailed as possible. You are based out of the United states in California." + ) -# payload = { -# "messages": [ -# { -# "content": bot_prompt, -# "role": "system", -# }, -# { -# "content": ctx.content.replace(str(bot.user.id), "").replace( -# "<@> ", "" -# ), -# "role": "user", -# }, -# ], -# "model": "openchat-3.5-7b", -# "stream": False, -# "max_tokens": 4096, -# "stop": ["hello"], -# "frequency_penalty": 0, -# "presence_penalty": 0, -# "temperature": 0.7, -# "top_p": 0.95, -# } -# headers = {"Content-Type": "application/json"} + payload = { + "messages": [ + { + "content": bot_prompt, + "role": "system", + }, + { + "content": ctx.content.replace(str(bot.user.id), "").replace( + "<@> ", "" + ), + "role": "user", + }, + ], + "model": "openchat-3.5-7b", + "stream": False, + "max_tokens": 4096, + "stop": ["hello"], + "frequency_penalty": 0, + "presence_penalty": 0, + "temperature": 0.7, + "top_p": 0.95, + } + headers = {"Content-Type": "application/json"} -# response = requests.post(url, json=payload, headers=headers) - -# await ctx.reply( -# response.json()["choices"][0]["message"]["content"].replace( -# "<|end_of_turn|>", "" -# ) -# ) + response = requests.post(url, json=payload, headers=headers) + answer = response.json()["choices"][0]["message"]["content"] + await ctx.reply(answer.replace("<|end_of_turn|>", "")) bot.run(os.getenv("discord_token"))