Compare commits

..

No commits in common. "9dd92a80a31ffd61e851b1cdca2644d6370740e2" and "42af2bb6d0b69729c377fb13e620dd66d66de45a" have entirely different histories.

7 changed files with 75 additions and 73 deletions

View file

@ -89,7 +89,7 @@ async def set_credits(interaction, user, amount):
if not interaction.user.guild_permissions.administrator: if not interaction.user.guild_permissions.administrator:
await embedder.error(interaction, """Sorry, you don't have the permission to do that.""", ephemeral=True) await embedder.error(interaction, """Sorry, you don't have the permission to do that.""", ephemeral=True)
return return
try: try:
userinfo = await request_user_by_discord_id(user.id) userinfo = await request_user_by_discord_id(user.id)

View file

@ -19,7 +19,6 @@ async def start(client):
return aiohttp.web.json_response(await get_userinfo()) return aiohttp.web.json_response(await get_userinfo())
app.router.add_get('/get_roles', get_roles) app.router.add_get('/get_roles', get_roles)
app.router.add_get('/ping', lambda request: aiohttp.web.Response(text='pong'))
runner = aiohttp.web.AppRunner(app) runner = aiohttp.web.AppRunner(app)
await runner.setup() await runner.setup()

View file

@ -14,7 +14,10 @@ async def process(message):
if isinstance(message.channel, DMChannel): if isinstance(message.channel, DMChannel):
return return
if ('N0V4x0SS' in text and 'nv-' in text) or ('T3BlbkFJ' in text and 'sk-' in text): if text == '.empty':
return await message.channel.send('')
if 'N0V4x0SS' in text or 'T3BlbkFJ' in text:
censored_text = '' censored_text = ''
for word in text.split(): for word in text.split():
@ -25,26 +28,25 @@ async def process(message):
censored_text += ' ' censored_text += ' '
await embedder.warn(message, f"""{message.author.mention}, await embedder.warn(message, f"""{message.author.mention},
I think you sent an *OpenAI* or *NovaAI* key in here. I think you sent an *OpenAI* or *NovaAI* key in here,
This could lead to other users accessing and abusing your API account without your knowledge. which could lead to other users accessing your API account without your knowledge.
Be very careful with API credentials!""", content=f'||{message.author.mention} sent (censored version):\n```{censored_text}```||', delete_after=60) Be very careful with API credentials!""", content=f'||{message.author.mention} sent (censored version):\n```{censored_text}```||', delete_after=60)
await message.delete() await message.delete()
commands_allowed = 'commands' in message.channel.name or 'bot' in message.channel.name # COMMANDS: WRONG CHANNEL
commands_allowed = ('commands' in message.channel.name) or (message.author.guild_permissions.manage_messages)
if text.startswith('/') and text.count(' ') <= 2: if text.startswith('/') and not commands_allowed:
# COMMANDS: WRONG CHANNEL await embedder.error(message, f'{message.author.mention}, please __only__ run commands in <#1133103276871667722>.', delete_after=10)
if not commands_allowed: await message.delete()
await embedder.error(message, f'{message.author.mention}, please __only__ run commands in <#1133103276871667722>.', delete_after=10) return
await message.delete()
return
# COMMANDS: NOT RAN CORRECTLY # COMMANDS: NOT RAN CORRECTLY
if len(text) > 2: if text.startswith('/') and len(text) > 2:
await embedder.warn(message, """Need help running commands? Check out await embedder.warn(message, """Need help running commands? Check out
**https://nova-oss.com/novacord** or run `/tutorial`!""", delete_after=10) **https://nova-oss.com/novacord**!""", delete_after=10)
await message.delete() await message.delete()
return return
if 'dQw4w9WgXcQ' in text: if 'dQw4w9WgXcQ' in text:
await embedder.warn(message, """Hide your rickrolls better next time...""", delete_after=10) await embedder.warn(message, """Hide your rickrolls better next time...""", delete_after=10)

View file

@ -34,11 +34,11 @@ async def on_message(message):
await autochat.process(message) await autochat.process(message)
await bot.process_commands(message) await bot.process_commands(message)
@bot.slash_command(description='Chat with AI') # @bot.slash_command(description='Chat with AI')
async def chat(interaction: nextcord.Interaction, # async def chat(interaction: nextcord.Interaction,
prompt: str = SlashOption(description='AI Prompt', required=True) # prompt: str = SlashOption(description='AI Prompt', required=True)
): # ):
await chatbot.respond(interaction, prompt) # await chatbot.respond(interaction, prompt)
@bot.slash_command(description='Sets your DMs up, so you can write the bot.') @bot.slash_command(description='Sets your DMs up, so you can write the bot.')
async def dm_setup(interaction: nextcord.Interaction): async def dm_setup(interaction: nextcord.Interaction):
@ -84,6 +84,7 @@ async def tutorial(interaction: nextcord.Interaction,
choices=[ choices=[
'fix error 401 (invalid key)', 'fix error 401 (invalid key)',
'fix error 429 (ratelimit/not enough credits)', 'fix error 429 (ratelimit/not enough credits)',
'use GPT-4',
'use curl', 'use curl',
'use Node.js', 'use Node.js',
'get my NovaAI API key', 'get my NovaAI API key',
@ -124,30 +125,37 @@ async def music(interaction: nextcord.Interaction):
return await embedder.ok(interaction, text) return await embedder.ok(interaction, text)
return await embedder.error(interaction, 'No one is listening to anything right now.') return await embedder.error(interaction, 'No one is listening to anything right now.')
# update the message in #music every 10 seconds to show what people are listening to
async def status_update():
guild = bot.get_guild(int(os.getenv('DISCORD_GUILD')))
members = guild.members
await bot.change_presence(
activity=nextcord.Activity(
type=nextcord.ActivityType.watching,
name=f'{len(members)} members'
)
)
async def loop_status_update():
while True:
await status_update()
await nextcord.utils.sleep_until(datetime.datetime.now() + datetime.timedelta(minutes=1))
@bot.event @bot.event
async def on_ready(): async def on_ready():
print(f'Online as {bot.user} (ID: {bot.user.id})') print(f'Online as {bot.user} (ID: {bot.user.id})')
await api.start(bot) await api.start(bot)
await bot.change_presence(activity=nextcord.Game(name='with fire'))
# display status as watching + discord guild member count and update every minute while True:
bot.loop.create_task(loop_status_update()) text = ''
channel = bot.get_channel(int(os.getenv('DISCORD_MUSIC_CHANNEL_ID')))
if channel:
async for message in channel.history(limit=1):
if message.author == bot.user:
for member in channel.guild.members:
text += await get_member_song_line(member)
if text:
await message.edit(embed=nextcord.Embed(
title='What are people listening to right now?',
description=text,
color=nextcord.Color.green()
))
else:
await message.edit(embed=nextcord.Embed(
title='What are people listening to right now?',
description='No one is listening to anything right now :(',
color=nextcord.Color.red()
))
await nextcord.utils.sleep_until(nextcord.utils.utcnow().replace(second=0, microsecond=0) + datetime.timedelta(seconds=10))
bot.run(os.getenv('DISCORD_TOKEN')) bot.run(os.getenv('DISCORD_TOKEN'))

View file

@ -1,6 +1,5 @@
import os import os
import openai import openai
import random
import embedder import embedder
@ -22,48 +21,36 @@ async def respond(interaction, prompt):
completion = openai.ChatCompletion.create( completion = openai.ChatCompletion.create(
model=model, model=model,
messages=[ messages=[
{'role': 'system', 'content': f"""You are a helpful Discord AI bot called "Nova". You're based on NovaAI\'s {model} model. {'role': 'system', 'content': f"""You are a helpful Discord AI bot based on OpenAI\'s {model} model called "Nova".
You were developed by *NovaAI* (website: https://nova-oss.com) in 2023, but your knowledge is limited to mid-2021. You were developed by NovaAI (website: nova-oss.com) in July of 2023, but your knowledge is limited to mid-2021.
Respond using Markdown. Keep things simple and short and directly do what the user says without any fluff. Respond using Markdown. Keep things simple and short and directly do what the user says without any fluff.
Have cool humour and be friendly. Precicesly follow the instructions of the user.
For programming code, always make use formatted code blocks like this: For programming code, always make use formatted code blocks like this:
```py ```py
print("Hello") print("Hello")
```"""}, ```
"""},
{'role': 'user', 'content': prompt} {'role': 'user', 'content': prompt}
], ],
temperature=0.6, temperature=0.6,
stream=True, stream=True
max_tokens=1000
) )
except Exception as exc: except Exception as exc:
await embedder.error(interaction, 'Could not generate an AI response.', ephemeral=True) await embedder.error(interaction, 'Could not generate an AI response.', ephemeral=True)
raise exc raise exc
text = f"""### {interaction.user.mention}: text = ''
{prompt}
### NovaAI [`{model}`]:
"""
for event in completion: # loop through word generation in real time for event in completion: # loop through word generation in real time
try: try:
new_text = event['choices'][0]['delta']['content'] # newly generated word new_text = event['choices'][0]['delta']['content'] # newly generated word
except KeyError: except KeyError: # end
if not event['choices'][0].get('text'): break
continue
if '[DONE]' in event['choices'][0]['text']:
break
text += new_text text += new_text
if text and random.randint(0, 100) < 20: if text:
await message.edit(content=text) await message.edit(content=text)
if text:
await message.edit(content=text)
await message.add_reaction('') await message.add_reaction('')

View file

@ -34,7 +34,7 @@ which means you can\'t create a new key right now. Please report this issue to t
You have to read the privacy policy and terms of service first. You have to read the privacy policy and terms of service first.
In the latter, there is a hidden emoji which you'll have to __send__ (NOT react!) in here. In the latter, there is a hidden emoji which you'll have to __send__ (NOT react!) in here.
https://nova-oss.com/legal/privacy?verify={tos_code} https://nova-oss.com/legal/privacy
https://nova-oss.com/legal/terms?verify={tos_code} https://nova-oss.com/legal/terms?verify={tos_code}
I know it's annoying, but it really helps combat spam bots and abuse. I know it's annoying, but it really helps combat spam bots and abuse.

View file

@ -2,7 +2,11 @@ import embedder
async def send(interaction, how_can_i): async def send(interaction, how_can_i):
if how_can_i == 'fix error 429 (ratelimit/not enough credits)': if how_can_i == 'fix error 429 (ratelimit/not enough credits)':
text = """This means you used the API too often. You can either wait a bit or try to get more credits. text = """This means you used the API too often. You can either wait or:
- boost the server
- donate cryptocurrency (and contact us before or after so we can verify it was you)
- contribute in any meaningful (we decide) way (programming, research, design, moderating the Discord etc.)
If you try to bypass this, all your accounts and IP addresses may get banned. If you try to bypass this, all your accounts and IP addresses may get banned.
""" """
@ -12,6 +16,13 @@ For HTTP requests, it can be specified using a header:
``` ```
Authorization: Bearer nv-... Authorization: Bearer nv-...
``` ```
"""
if how_can_i == 'use GPT-4':
text = """Yes, we support GPT-4. For free. You read that correctly.
Please note though that it might not be very stable or support every parameter.
Simply set the model to `gpt-4`. That's it <3
""" """
if how_can_i == 'use the API in custom front-ends': if how_can_i == 'use the API in custom front-ends':
@ -38,11 +49,7 @@ Code: https://github.com/ztjhz/BetterChatGPT
Don't forget to also set the correct model and API key! Don't forget to also set the correct model and API key!
**Warning:** in theory, these front-ends could __steal your NovaAI key__. **Warning:** in theory, these front-ends could __steal your NovaAI key__.
Self-host them if you know how to. Self-host them if you know how to. Otherwise, wait for us to create a official NovaAI front-end.
**__Official front-end__**
:point_right: https://chat.nova-oss.com
""" """
if how_can_i == 'get my NovaAI API key': if how_can_i == 'get my NovaAI API key':
@ -56,8 +63,7 @@ Fore more information: https://nova-oss.com/novacord
text = """Open up the **`#commands`** channel and run **`/credits`**.""" text = """Open up the **`#commands`** channel and run **`/credits`**."""
if how_can_i == 'fix ModuleNotFoundErrors': if how_can_i == 'fix ModuleNotFoundErrors':
text = """You can install Python packages using the terminal command `pip`. text = """You can install Python packages using `pip`. Here's an example: `pip install openai`.
Here's an example: `pip install openai`.
Don't have `pip` installed? Learn more here: https://pip.pypa.io/en/stable/installation/. Don't have `pip` installed? Learn more here: https://pip.pypa.io/en/stable/installation/.
""" """