yes
This commit is contained in:
parent
51e20ae01e
commit
0bc9a6ec82
5 changed files with 78 additions and 43 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,2 +1,5 @@
|
|||
.sekrit
|
||||
__pycache__
|
||||
bin/
|
||||
lib/
|
||||
pyvenv.cfg
|
||||
|
|
33
lulzbot.py
33
lulzbot.py
|
@ -1,3 +1,12 @@
|
|||
import datetime
|
||||
import discord
|
||||
from src.flan import flan_speak
|
||||
from src.cartman import cartman_speak
|
||||
from src.twitter import get_tweet
|
||||
from fortune import fortune
|
||||
import numpy as np
|
||||
|
||||
|
||||
motd = '''
|
||||
_ _ ____ ___ _
|
||||
| | _ _| | ___| __ ) / _ \| |_
|
||||
|
@ -5,6 +14,7 @@ motd ='''
|
|||
| |__| |_| | |___ / /| |_) | |_| | |_
|
||||
|_____\__,_|_____/___|____/ \___/ \__|
|
||||
'''
|
||||
|
||||
menu = '''```
|
||||
Commands:
|
||||
fortune: tell a fortune
|
||||
|
@ -18,39 +28,40 @@ Commands:
|
|||
Contribute!
|
||||
https://github.com/adoyle0/lulzbot```'''
|
||||
|
||||
import discord, datetime
|
||||
import numpy as np
|
||||
from fortune import fortune
|
||||
from src.twitter import get_tweet
|
||||
from src.cartman import cartman_speak
|
||||
from src.flan import flan_speak
|
||||
|
||||
chuck_quotes = open('data/chuck_quotes').read().split('\n%\n')
|
||||
ligma_list = open('data/ligma_list').read().split('\n')
|
||||
limericks = open('data/limericks').read().split('\n%\n')
|
||||
aclist = open('data/aclist').read().split('\n')
|
||||
|
||||
|
||||
def show_menu():
|
||||
return menu
|
||||
|
||||
|
||||
def musk():
|
||||
return get_tweet(44196397)
|
||||
|
||||
|
||||
def ligma():
|
||||
return np.random.choice(ligma_list)
|
||||
|
||||
|
||||
def limerick():
|
||||
return np.random.choice(limericks)
|
||||
|
||||
|
||||
def prost():
|
||||
return 'https://tenor.com/view/prost-christoph-waltz-django-bier-zum-wohle-gif-11041516'
|
||||
|
||||
def chuck():
|
||||
return np.random.choice(chuck_quotes)
|
||||
|
||||
|
||||
def ac():
|
||||
return np.random.choice(aclist)
|
||||
|
||||
|
||||
triggers = {'lulzbot': show_menu, # these need to be functions
|
||||
'musk': musk,
|
||||
'deez': ligma,
|
||||
|
@ -67,14 +78,18 @@ triggers = {'lulzbot': show_menu, # these need to be functions
|
|||
|
||||
TOKEN = open('.sekrit/discord_token').read()
|
||||
intents = discord.Intents.default()
|
||||
# intents.message_content = True
|
||||
client = discord.Client(activity=discord.Game(name='with myself'), intents=intents)
|
||||
intents.message_content = True
|
||||
client = discord.Client(activity=discord.Game(
|
||||
name='with myself'), intents=intents)
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print(motd+'\n'+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')+'\nLogged in as {0.user}'.format(client))
|
||||
print(motd+'\n'+datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') +
|
||||
'\nLogged in as {0.user}'.format(client))
|
||||
return
|
||||
|
||||
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
username = str(message.author).split('#')[0]
|
||||
|
|
6
requirements.txt
Normal file
6
requirements.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
discord
|
||||
numpy
|
||||
fortune-python
|
||||
tweepy
|
||||
transformers
|
||||
torch
|
7
run
Executable file
7
run
Executable file
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
source bin/activate &&
|
||||
pip install --upgrade pip &&
|
||||
pip install --upgrade -r requirements.txt &&
|
||||
clear &&
|
||||
python lulzbot.py
|
|
@ -1,21 +1,25 @@
|
|||
from transformers.models.auto.modeling_auto import AutoModelForCausalLM
|
||||
from transformers.models.auto.tokenization_auto import AutoTokenizer
|
||||
import requests
|
||||
import json
|
||||
|
||||
url = 'https://doordesk.net/chat'
|
||||
|
||||
|
||||
def cartman_respond(user_message):
|
||||
message = {'Message': user_message}
|
||||
response = requests.post(url, json.dumps(message))
|
||||
return response.json().get('Cartman')
|
||||
|
||||
from transformers.models.auto.modeling_auto import AutoModelForCausalLM
|
||||
from transformers.models.auto.tokenization_auto import AutoTokenizer
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-large")
|
||||
model = AutoModelForCausalLM.from_pretrained("../cartman/train/cartman/models/output-medium")
|
||||
tokenizer = AutoTokenizer.from_pretrained("microsoft/DialoGPT-medium")
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
"../cartman/train/cartman/models/output-medium-3ep")
|
||||
|
||||
|
||||
def cartman_speak(input_text):
|
||||
input_ids = tokenizer(input_text + tokenizer.eos_token, return_tensors="pt").input_ids
|
||||
input_ids = tokenizer(input_text + tokenizer.eos_token,
|
||||
return_tensors="pt").input_ids
|
||||
outputs = model.generate(
|
||||
input_ids,
|
||||
pad_token_id=tokenizer.eos_token_id,
|
||||
|
|
Loading…
Add table
Reference in a new issue