Skip to content

Instantly share code, notes, and snippets.

View fsndzomga's full-sized avatar

Franck Stéphane Ndzomga fsndzomga

View GitHub Profile
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")
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
const puppeteer = require('puppeteer');
// Custom delay function
function delay(time) {
return new Promise(function(resolve) {
setTimeout(resolve, time);
});
}
async function countHappyScribeJavaScript(url) {
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
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")
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):
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 = []
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)
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)
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