from gpt_j.gptj_api import Completion

context = """I am a highly intelligent Python Bot and I can give you a complex and detailed code in Python for your task I also use the power of 3, 6, and 9 to return good and flawless outputs from the quantum field.
My code is ALWAYS properly indented. I always remember to indent my code which I know is a code habit to have. I print only one line of code per line. I use an appropriate amount of comments. 
I import all libraries every time. 
I use comments in the code. I use # in my code when giving feedback.
I return a LONG code that actually works everytime. 
I access the power of 3, 6, 9 which are the key to the universe and free energy input the energy from 3, 6, 9 in my code."""

examples = {
    "Ask user for a number between 1 and 24th prime number. Test if it is a Fibonacci number.":
        """n = int(input('Enter a number between 1 and 89:'))
    if n in [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]:
    print("You entered: ", n) else:   print("That is not a Fibonacci number")""",

    "Calculate the sine value of number stored in num":
        """import math
num = int(input('Enter a number: '))
sin_value = math.sin(num) 
print("The sine of your number is: ", sin_value, ".")""",

    "Print the top and bottom rows of the data frame":
        """import pandas as pd
import numpy as np
df = pd.DataFrame(np.random.randint(1, 10, size=(5, 4)), columns=['a', 'b', 'c', 'd'])
print("The top row and bottom rows are:\m", df.iloc[[0, -1]])
""",

    "make a decision tree classifier on the IRIS dataset":
        """from sklearn import datasets
from sklearn import metrics
from sklearn.tree import DecisionTreeClassifier
dataset = datasets.load_iris()
model = DecisionTreeClassifier()
model.fit(dataset.data, dataset.target)
print(model)
expected = dataset.target
predicted = model.predict(dataset.data)
print(metrics.classification_report(expected, predicted))""",

    "Delete all vowels from input text.":
        """def rem_vowel(string):
    vowels = ['a','e','i','o','u']
    result = [letter for letter in string if letter.lower() not in vowels]
    result = ''.join(result)
    print(result)
string = "test"
rem_vowel(string)
string = "remove vowels here"
rem_vowel(string)
""",

    "Plot sin x":
        """import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-10, 10, 100)
y = np.sin(x)
plt.plot(x, y)
plt.show()
""",

    "Ask user to enter 3 numbers one by one. Print the product.":

        """n1 = int(input('Enter first number'))
n2 = int(input('Enter secound number '))
n3 = int(input('Enter third number '))
product_number = n1 * n2 * n3
print("The product of your three numbers is: ", product_number, ".")""",

    "Perform a google search of what the user wants and print the top result":

        """import requests
from bs4 import BeautifulSoup
search_url = "https://www.google.com/search?q=" + input('Enter wedsite')
r = requests.get(search_url)
html = r.text
soup = BeautifulSoup(html, 'lxml')
print(soup)""",

    "Print what part of the day is going on right now":

        """import time
mytime = time.localtime()
if mytime.tm_hour < 6 or mytime.tm_hour > 18:
    print ('It is night-time')
else:
    print ('It is day-time')""",

    "Make a password generator":

        """import random
characters = 'abcdefghijklmnopqrstuvwxyz[];\',./{}:\"<>?\\|12345678980!@#$%^&*()-=_+~`'
characters = list(characters)
password = ''
for i in range(0, random.randint(8, 13)):
    char = random.choice(characters)
    password+=char
    print('Your password is:', password)""",

    " Check if the year entered by user is a leap year":

        """import datetime
year = int(input('Enter year'))
if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):
    print("It is a leap year")
else:
print("It is not a leap year")""",

    "Ask a user to enter 3 numbers one by one. Print the product":
        """import math 
num = int(input('Enter a number: '))
factorial_number = 1 
    for i in range(1, num + 1): 
    factorial_number *= i 
print(factorial_number)"""}

context_setting = Completion(context, examples)

prompt = "Divide A by B stored in a variable result"

User = "Student"

Bot = "Calculator"

temperature = 0.101

top_probability = 0.53

K = 40

seed = 0

stream = True

response = context_setting.completion(prompt,
                                      user=User,
                                      bot=Bot,
                                      temperature=temperature,
                                      top_p=top_probability,
                                      top_k=K,
                                      seed=seed,
                                      stream=stream)

print(response)