Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine the script to give ratings as per the model name #18

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions examples/ui/gradio/gradio-hftgi-rag-redis/chatbot_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Import necessary libraries
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium.common.exceptions import TimeoutException
import random
from selenium.webdriver.support.ui import Select

# driver = webdriver.Firefox()
# driver.get("https://llm-flan-tgis-llm-demo.apps.ai-dev01.kni.syseng.devcluster.openshift.com/")
# driver.set_window_size(1084, 811)
timeout = 10

for user in range(10):
driver = webdriver.Firefox()
driver.get("https://llm-ui-tgis-llm-demo.apps.ai-dev01.kni.syseng.devcluster.openshift.com")
driver.set_window_size(1084, 811)

element_present = EC.presence_of_element_located((By.CSS_SELECTOR, "#component-0 .scroll-hide"))
WebDriverWait(driver, timeout).until(element_present)

# User enters the customer name
customer_input = driver.find_element(By.CSS_SELECTOR, "#component-3 .scroll-hide")
customer_input.clear() # Clearing any previous input
customer_input.send_keys(f"Apple")

dropdown = driver.find_element(By.CSS_SELECTOR, "#component-4 .secondary-wrap")
dropdown.click()

option = driver.find_element(By.XPATH, "(//ul/li)[2]")
option.click()

submit=driver.find_element(By.CSS_SELECTOR, "#component-6")
submit.click()

model_id_element = driver.find_element(By.ID, "model_id")
model_id_text = model_id_element.text # Get the text from the WebElement

if "Model: google/flan-t5-xl" in model_id_text:
label_list = [1, 2, 3]
else:
label_list = [4, 5]
random_num = random.choice(label_list)
labelname=str(random_num)+'-radio-label'
label_id="label[data-testid='"+labelname+"']"

# label_id = "label[data-testid='2-radio-label']"
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, label_id))).click()
time.sleep(7) # Adding a delay for better simulation of user interaction

# Close the browser after the loop completes
#driver.quit()