import gradio as gr from selenium import webdriver from selenium.common.exceptions import WebDriverException from selenium.webdriver.common.by import By from gradio_client import Client from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.chrome.options import Options def selenium(message): options = webdriver.ChromeOptions() options.add_argument('--headless') wd = webdriver.Chrome(options=options) text_input = WebDriverWait(driver, 15).until( EC.presence_of_element_located((By.XPATH, '/html/body/main/div/div/div[2]/div[1]/div/div[3]/div/div/div[2]/div[2]/div/div/span/div/div/div/div[1]/textarea')) ) text_input.send_keys(prompt) button_send = driver.find_element(By.XPATH, '/html/body/main/div/div/div[2]/div[1]/div/div[3]/div/div/div[2]/div[2]/div/div/span/div/div/div/div[3]/button').click() time.sleep(5) txtelements = driver.find_elements(By.XPATH, '/html/body/main/div/div/div[2]/div[1]/div/div[3]/div/div[1]/div/div[2]/div/div[1]/div[2]/div[2]/div[2]') #text_el = txtelements.text time.sleep(5) txtcode = "" #with open("datei.txt", "w") as f: #f.write(code) #response_code = {"result": code} #json.dump(response_code, open('code.json', 'w'), indent=4, sort_keys=True) for e in txtelements: txtcode += e.text #response_txt = {"result": txtcode} #print(code) print(txtcode) #json.dump(response_txt, open('text.json', 'w'), indent=4, sort_keys=True) #json.dump(response_code, open('code.json', 'w'), indent=4, sort_keys=True) return txtcode wd.quit() #erg ="\n".join(results) #return erg #erg=results[0] #return "\n".join(results) client = Client("Qwen/Qwen2.5-72B-Instruct") result = client.predict( query=f"erstelle ein json objekt für die vereine: \n{''.join(results)}", #query="wie hoch ist der kölner dom", history=[], system="You are Qwen, created by Alibaba Cloud. You are a helpful assistant.", api_name="/model_chat" ) result = result[1] result = result[0][1] result=gr.Markdown(result) return result iface = gr.Interface( fn=take_screenshots, inputs=[ gr.Textbox(label="Ort", value=""), ], outputs=gr.Textbox(), title="perplexity.ai", description="get answer from perplexity" ) iface.launch()