Creating Homework AI Bot Cause You're Too Lazy To Do It

Поделиться
HTML-код
  • Опубликовано: 15 окт 2024
  • Creating Homework AI Bot Cause You're Too Lazy To Do It

Комментарии • 1

  • @PracticalCoding.
    @PracticalCoding.  Год назад

    from pptx import Presentation
    from bardapi import Bard
    import re, time
    from pptx.util import Pt
    token = 'Your Token'
    bard = Bard(token=token)
    slideNum = int(input("Number of slides: "))
    def slide():
    slidesPPTX = slideNum
    prs = Presentation()
    for x in range(slideNum):
    topic = input('Topic #' + str(x+1) + ': ')
    adv = input('Additional options: ')
    response = bard.get_answer(
    'Write about ' + str(topic) + '. ' + str(adv) +'. Dont write anything else.'
    )

    print(response['content'])
    lines = response['content'].split('.')
    lines = response['content'].split('
    ')
    nlines = [x for x in lines if x]
    if len(nlines) > 1:
    del nlines[-2:]
    print(nlines)
    regex = r"\d+\.?[0-9\*]*"
    bullet_slide_layout = prs.slide_layouts[1]
    slide = prs.slides.add_slide(bullet_slide_layout)
    shapes = slide.shapes
    title_shape = shapes.title
    body_shape = shapes.placeholders[1]
    tf = body_shape.text_frame
    p = tf.add_paragraph()
    nlines[0] = nlines[0].replace('*','')
    nlines[0] = nlines[0].replace('
    ', '')
    print(nlines[0])
    p.text = nlines[0]
    del nlines[0]
    p.font.bold = True
    p.font.size = Pt(28)
    for line in nlines:
    linewithout = line.replace('*','')
    linewithout = linewithout.replace('
    ', '')
    p = tf.add_paragraph()
    p.text = linewithout
    p.font.size = Pt(18)
    if re.match(regex, line):
    #print(f'Linia "{line}" zawiera liczby.')
    p.level = 1
    title_shape.text = topic
    prs.save('z.pptx')
    slide()
    time.sleep(5)