Skip to content

Instantly share code, notes, and snippets.

View kordless's full-sized avatar
🦥
sloth mode

Коrd Campbell kordless

🦥
sloth mode
View GitHub Profile
@kordless
kordless / README.md
Created December 1, 2023 22:08
PDF File Splitter

To run the Python script for splitting a PDF into segments of just under 25MB each, you'll need to follow these steps:

Prerequisites

Python Installation: Ensure that Python is installed on your system. If not, you can download and install it from python.org.

PyPDF2 Library: The script uses the PyPDF2 library. You can install it using pip, Python's package installer. If pip is not already installed, it comes bundled with Python 3.4 and later versions.

Installation Steps

Open Terminal or Command Prompt: On Windows, you can open Command Prompt by searching for cmd in the Start menu.

@kordless
kordless / config.py
Last active August 15, 2023 15:30
Instructor Embeddings w/FeatureBase
# tokens from https://cloud.featurebase.com/configuration/api-keys
featurebase_token = "<token>"
# featurebase ($300 free credit on signup)
# https://query.featurebase.com/v2/databases/bc355-t-t-t-362c1416/query/sql (but remove /query/sql)
featurebase_endpoint = "https://query.featurebase.com/v2/databases/<uuid-only-no-query-sql>"
@kordless
kordless / README.md
Last active January 1, 2024 11:19
Example of using OpenAI functions in completions with Python decorators.

Example of using OpenAI functions in completions with Python decorators

This example illustrates a way to utilize a function dynamically while querying an OpenAI GPT model. It uses the newly released functions support in the completion endpoints OpenAI provides.

The general concept is based on using a decorator to extract information from a function so it can be presented to the language model for use, and then pass the result of that function back to the completion endpoint for language augmentation.

In general, a wide variety of functions can be swapped in for use by the model. By changing the get_top_stories function, plus the prompt in run_conversation, you should be able to get the model to run your function without changing any of the other code.

Configuration

To use this, create a config.py file and add a variable with your OpenAI token:

@kordless
kordless / sample.py
Created June 14, 2023 19:28
Developing an OpenAI Functions Decorator
"""
Hacker News Top Stories
Author:
Date: June 12, 2023
Description:
This script fetches the top 10 stories from Hacker News using Algolia's search API. It retrieves the stories posted within the last 24 hours and prints their titles and URLs.
Dependencies:
- requests: HTTP library for sending API requests
import openai
import numpy as np
from openai.embeddings_utils import get_embedding
openai.api_key = "TOKEN"
def gpt3_embedding(content, engine='text-similarity-ada-001'):
content = content.encode(encoding='ASCII',errors='ignore').decode()
response = openai.Embedding.create(input=content,engine=engine)
vector = response['data'][0]['embedding'] # this is a normal list
State of AI Report
October 11, 2022
#stateofai
stateof.ai
Ian Hogarth
Nathan Benaich
About the authors
Nathan is the General Partner of Air Street Capital, a venture capital firm investing in AI-first technology and life science companies. He founded RAAIS and London.AI (AI community for industry and research), the RAAIS Foundation (funding open-source AI projects), and Spinout.fyi (improving university spinout creation). He studied biology at Williams College and earned a PhD from Cambridge in cancer research.
Nathan Benaich
@kordless
kordless / README.md
Last active September 28, 2022 15:56
Analyzing 5 Billion Games of Set with FeatureBase

Analyzing 5 Billion Games of Set with FeatureBase

FeatureBase is a binary-tree database built on Roaring Bitmaps. This makes it suitable for running analytics on massive data sets in real time. If you've never used FeatureBase before, you can get it running locally in about 5 minutes.

Today, we're going to take a look at using FeatureBase to simulate and analyze a very large number of Set games in real-time.

Set (the game)

Set is a card game designed by Marsha Falco in 1974 and published by Set Enterprises in 1991. The deck consists of 81 unique cards that vary in four features across three possibilities for each kind of feature: number of shapes (one, two, or three), shape (diamond, squiggle, oval), shading (solid, striped, or open), and color (red, green, or purple).

In a game of Set, the cards are shuffled and then 12 cards are drawn from the top of the deck and placed on the table. Game play then com

@kordless
kordless / README.md
Last active October 6, 2022 04:10
Set Up a FeatureBase Binary Index in 5 Minutes

FeatureBase in 5 Minutes

FeatureBase is a B-tree database built on Roaring Bitmaps. This makes it suitable for running analytics on massive data sets in real time. It's also perfect for use in machine learning applications, where a fast feature store is desired during training or inference. FeatureBase itself may be considered a type of machine learning model which is trained on large amounts of other model's inference data, over time.

This guide is designed to get you started using FeatureBase on a Mac or Linux/UNIX based system. It covers downloading and starting the FeatureBase server as well as ingesting and querying a small amount of data.

You may also want to reference the documentation for FeatureBase after you finish running through this guide.

Install

Start by heading over to the downloads on the Github repo and select the buil

import openai
import numpy as np
from openai.embeddings_utils import get_embedding
openai.api_key = ""
def gpt3_embedding(content, engine='text-similarity-ada-001'):
content = content.encode(encoding='ASCII',errors='ignore').decode()
response = openai.Embedding.create(input=content,engine=engine)
vector = response['data'][0]['embedding'] # this is a normal list
// google docs app
var line = "{{line}}";
if ("{{text}}" == "" && "{{view}}" == "") {
// just nothing
url = "https://docs.google.com/";
} else if ("{{text}}" == "" && "{{view}}" != ""){
// view
var view = "{{view}}".substring(1); // trim the | off (fix this)
if (view == "sheets") {