yesterday i wrote a script to use forefront to produce a gpt4
completion, using the auto-selenium python module

attached

also https://gitler.moe/xloem/gpt4free

it was my day of discovering gpt4free

looks/sounds like there are way more backend sites than shown in the repo
# urllib ssl workaround on my platform
import ssl, certifi
def create_ssl_context():
    return ssl.create_default_context(cafile=certifi.where())
ssl._create_default_https_context = create_ssl_context

# ipv4/ipv6 workaround on my platform (ipv6 sometimes present but not functional)
import socket
socket_getaddrinfo = socket.getaddrinfo
def getaddrinfo(*params, **kwparams):
    infos = socket_getaddrinfo(*params, **kwparams)
    infos.sort() # try ipv4 before ipv6
    return infos
socket.getaddrinfo = getaddrinfo

# main code
import autoselenium
from selenium.common.exceptions import StaleElementReferenceException
from mailgw_temporary_email import Email
from time import sleep
from re import findall

with autoselenium.Driver('chrome') as driver:
    #driver = autoselenium.Driver('chrome').__enter__()
    def sign_in(driver):
        driver.implicitly_wait(60)
        driver.get('https://www.forefront.ai/')
        
        signup_button = driver.find_element_by_id('w-node-eb8b013e-6411-88da-9606-1184c0e4f409-3e23454d')
        signup_button.click()
    
        model_select_or_signup_button = driver.find_element_by_css_selector(
                '#model-select' # id indicates logged in
                + ',' +
                '.cl-footerActionLink' # class indicates signup button
            )
        if model_select_or_signup_button.get_attribute('id') != 'model-select':
            model_select_or_signup_button.click()
    
            mail_client = Email()
            mail_client.register()
            mail_address = mail_client.address
    
            email_field = driver.find_element_by_id('emailAddress-field')
            email_field.send_keys('')
            email_field.clear()
            email_field.send_keys(mail_address + '\n')
    
            while True:
                sleep(5)
                messages = mail_client.message_list()
                if len(messages):
                    break
            message_id = messages[0]['id']
            message = mail_client.message(message_id)
            verification_url = findall(r'https:\/\/clerk\.forefront\.ai\/v1\/verify\?token=\w.+', message['text'])[0]
    
            driver.get(verification_url)
    
        while 'clearing popups':
            modal_box_or_model_select = driver.find_element_by_css_selector(
                    '.modal-box' # in front when a popup can be cleared
                    + ',' +
                    '#model-select' # fallback
                )
            if modal_box_or_model_select.get_attribute('id') == 'model-select':
                break
            try:
                modal_box_or_model_select.find_element_by_tag_name('button').click()
            except StaleElementReferenceException:
                pass
    sign_in(driver)
    
    def new_conversation(model, persona, message):
        model_select = driver.find_element_by_id('model-select')
        for model_option in model_select.find_elements_by_tag_name('option'):
            if model_option.get_attribute('value') == model:
                model_option.click()
                break
        model = model_select.get_attribute('value')
        persona_select = driver.find_element_by_id('persona-select')
        for persona_option in persona_select.find_elements_by_tag_name('option'):
            if persona_option.get_attribute('value') == persona:
                persona_option.click()
                break
        persona = persona_select.get_attribute('value')
        textbox = driver.find_element_by_css_selector('[contenteditable=true]')
        textbox.send_keys(message+'\n')

        response_div = driver.find_elements_by_css_selector('div.post-markdown')[-1]
        response_parent = response_div.parent
        response_text = ''
        done = False
        while not done:
            status_button = driver.find_elements_by_css_selector('.shadow.rounded>p')[-1]
            if status_button.text == 'Share':
                done = True
            new_response_text = response_div.text
            assert new_response_text[:len(response_text)] == response_text
            yield new_response_text[len(response_text):]
            response_text = new_response_text
    
    for token in new_conversation('gpt-3.5-turbo', None, 'Teach me about quantum physics and special relativity.'):
        print(token, end='', flush=True)
    print()
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many
  • Re: [spam][c... Undescribed Horrific Abuse, One Victim & Survivor of Many

Reply via email to