Skip to content

Commit

Permalink
Deleted unnecessary comments
Browse files Browse the repository at this point in the history
  • Loading branch information
penenadpi committed Jun 25, 2023
1 parent 80a640e commit 3811ad8
Showing 1 changed file with 12 additions and 39 deletions.
51 changes: 12 additions & 39 deletions bots/nenad/joke_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,6 @@ def __getitem__(self, item):
"""
class Bot:
def __init__(self):
"""
self.joke_generator = pipeline('text-generation', model='gpt2')
self.joke_prefixes = [
"My best joke is: "
]
"""
self.name = 'Nenad'

self.device = 'cpu'
if torch.cuda.is_available():
self.device = 'cuda'

self.tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
self.model = GPT2LMHeadModel.from_pretrained('gpt2')
self.model = self.model.to(self.device)
self.utils = Utils()
"""
def tell_joke(self):
# Use the GPT-2 model to generate a joke
Expand All @@ -104,6 +87,18 @@ def rate_joke(self, joke):
rating = (polarity + 1) * 5 # convert polarity from [-1, 1] to [0, 10]
return rating
"""

self.name = 'Nenad'

self.device = 'cpu'
if torch.cuda.is_available():
self.device = 'cuda'

self.tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
self.model = GPT2LMHeadModel.from_pretrained('gpt2')
self.model = self.model.to(self.device)
self.utils = Utils()


#Checks if any comibnation of tokens which make the forbidden word are present in the new sequence after adding token
def check_forbidden(self, f_sequence, current_sequence):
Expand Down Expand Up @@ -369,28 +364,6 @@ def load_state(self, models_folder="trained_models", weights_file="gpt2_joker_0.
self.model.load_state_dict(torch.load(model_path))


import pytest
#from joke_bot import Bot

"""
@pytest.fixture
def bot():
return Bot()
def test_tell_joke(bot):
joke = bot.tell_joke()
assert isinstance(joke, str), "Joke is not a string."
assert len(joke) > 50, "Joke length is not within the correct range."
def test_rate_joke(bot):
joke = "Why was the computer cold at the office? Because it left its Windows open."
rating = bot.rate_joke(joke)
assert isinstance(rating, (int, float)), "Rating is not a number."
assert 0 <= rating <= 10, "Rating is not within the correct range."
"""


if __name__ == "__main__":
bot_nenad = Bot()

Expand Down

0 comments on commit 3811ad8

Please sign in to comment.