This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import boto3 | |
newline, bold, unbold = "\n", "\033[1m", "\033[0m" | |
endpoint_name = "name_of_your_endpoint" | |
def query_endpoint(payload): | |
client = boto3.client("runtime.sagemaker", region_name="us-east-1") | |
response = client.invoke_endpoint( | |
EndpointName=endpoint_name, InferenceComponentName='huggingface-llm-mistral-7b-20240210-171055', ContentType="application/json", Body=json.dumps(payload).encode("utf-8") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'watir' | |
require 'webdrivers' | |
def count_happy_scribe_ruby(url) | |
browser = Watir::Browser.new :chrome, headless: true | |
browser.goto(url) | |
browser.execute_script("window.scrollTo(0, document.body.scrollHeight)") | |
sleep(10) # Wait a bit more for content to load |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
// Custom delay function | |
function delay(time) { | |
return new Promise(function(resolve) { | |
setTimeout(resolve, time); | |
}); | |
} | |
async function countHappyScribeJavaScript(url) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.chrome.service import Service | |
from webdriver_manager.chrome import ChromeDriverManager | |
import time | |
def count_happy_scribe_selenium(url): | |
# Set up Chrome options | |
chrome_options = webdriver.ChromeOptions() | |
chrome_options.add_argument("--headless") # Run Chrome in headless mode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import os | |
import requests | |
from dotenv import load_dotenv | |
from PIL import Image, ImageOps | |
# Load environment variables | |
load_dotenv() | |
api_key = os.getenv("STABILITY_API_KEY") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import os | |
import requests | |
from dotenv import load_dotenv | |
from PIL import Image, ImageOps | |
# Load environment variables | |
load_dotenv() | |
def calculate_best_fit_dimension(original_width, original_height, target_dimensions): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ragatouille import RAGPretrainedModel | |
from ragatouille.utils import get_wikipedia_page | |
topics = ["Barack_Obama", "Nelson_Mandela", "king"] | |
RAG = RAGPretrainedModel.from_pretrained("colbert-ir/colbertv2.0") | |
my_documents = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from yahooquery import Ticker | |
import dspy | |
from config import OPENAI_API_KEY, SERPAPI_API_KEY | |
llm = dspy.OpenAI(model='gpt-3.5-turbo',api_key=OPENAI_API_KEY, max_tokens=2000) | |
dspy.settings.configure(lm=llm) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dspy.evaluate.evaluate import Evaluate | |
evaluator = Evaluate(devset=devset, num_threads=1, display_progress=True, display_table=10) | |
evaluator(compiled_lie_detector, metric=answer_exact_match) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dspy.teleprompt import BootstrapFewShot | |
from dspy.evaluate import answer_exact_match | |
text = "Barack Obama was not President of the USA" | |
# define the fact as input to the lie detector | |
trainset = [x.with_inputs('fact') for x in few_shot_examples] | |
# define the signature to be used in by the lie detector module | |
# for the evaluation, you need to define an answer field |