From 499ec23bf4a9ba29ea302f32bfb4b75b7529cb51 Mon Sep 17 00:00:00 2001 From: Grant Linville Date: Wed, 8 May 2024 22:24:19 -0400 Subject: [PATCH] chore: update sentiments example Signed-off-by: Grant Linville --- .../{sentiments/tweet.gpt => sentiments.gpt} | 15 ++++-------- examples/sentiments/README.md | 22 ----------------- examples/sentiments/main.py | 24 ------------------- examples/sentiments/requirements.txt | 1 - 4 files changed, 4 insertions(+), 58 deletions(-) rename examples/{sentiments/tweet.gpt => sentiments.gpt} (53%) delete mode 100644 examples/sentiments/README.md delete mode 100644 examples/sentiments/main.py delete mode 100644 examples/sentiments/requirements.txt diff --git a/examples/sentiments/tweet.gpt b/examples/sentiments.gpt similarity index 53% rename from examples/sentiments/tweet.gpt rename to examples/sentiments.gpt index 5a25acf2..ab62c76a 100644 --- a/examples/sentiments/tweet.gpt +++ b/examples/sentiments.gpt @@ -1,18 +1,11 @@ -tools: sys.write, get-tweet-text, sentiments +tools: github.com/gptscript-ai/browser, sentiments description: get the sentiments expressed in a tweet args: url: URL of the tweet to analyze Perform the actions in the following order: -Get the text of the tweet referenced by "${url} and save it in the file content.txt -Next analyze the sentiments expressed in this file - ---- -name: get-tweet-text -description: get text content of a tweet -args: url: url towards a tweet - -#!python3 main.py "$url" +Get the text of the tweet referenced by $url. +Then, analyze the sentiments expressed in this tweet. --- name: sentiments @@ -21,4 +14,4 @@ args: content: any string You are a program designed to assess the sentiments expressed by a writer in a text. -Do not give too many details, just the overall sentiments that is expressed in "${content}" \ No newline at end of file +Do not give too many details, just the overall sentiments that is expressed in "${content}" diff --git a/examples/sentiments/README.md b/examples/sentiments/README.md deleted file mode 100644 index 8db7cb29..00000000 --- a/examples/sentiments/README.md +++ /dev/null @@ -1,22 +0,0 @@ -# Tweet sentiments analysis - -This example takes a tweet's URL and analyse the sentiments of the text - -## Run the Example - -```bash -# Create a Python venv -python3 -m venv venv - -# Source it -source venv/bin/activate - -# Install the packages -pip install -r requirements.txt - -# Set your OpenAI key -export OPENAI_API_KEY=your-api-key - -# Run the example -gptscript tweet.gpt --url https://x.com/ibuildthecloud/status/1765748793998467179 -``` diff --git a/examples/sentiments/main.py b/examples/sentiments/main.py deleted file mode 100644 index 5b01dbda..00000000 --- a/examples/sentiments/main.py +++ /dev/null @@ -1,24 +0,0 @@ -import sys -from selenium import webdriver -from selenium.webdriver.common.by import By -from selenium.webdriver.support.ui import WebDriverWait -from selenium.webdriver.support import expected_conditions as EC - -# Get url -url = sys.argv[1] - -# Setup WebDriver options -options = webdriver.ChromeOptions() -options.add_argument("--headless") -options.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36") -driver = webdriver.Chrome(options=options) - -# Navigate to the page and get field -driver.get(url) -try: - element = WebDriverWait(driver, 50).until( - EC.presence_of_element_located((By.CSS_SELECTOR, "div[data-testid='tweetText'] > span")) - ) - print(element.text) -finally: - driver.quit() diff --git a/examples/sentiments/requirements.txt b/examples/sentiments/requirements.txt deleted file mode 100644 index 80c2c892..00000000 --- a/examples/sentiments/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -selenium==4.18.1 \ No newline at end of file