Skip to content

Instantly share code, notes, and snippets.

@iankelk
iankelk / 01-install.py
Created January 4, 2024 20:38
Databricks integration
pip install clarifai-pyspark
@iankelk
iankelk / 1-data.py
Last active December 18, 2023 19:51
RAG with Clarifai and langchain
# 1. Data Organization: chunk documents
@st.cache_resource(ttl="1h")
def load_chunk_pdf(uploaded_files):
# Read documents
documents = []
temp_dir = tempfile.TemporaryDirectory()
for file in uploaded_files:
temp_filepath = os.path.join(temp_dir.name, file.name)
with open(temp_filepath, "wb") as f:
f.write(file.getvalue())
@iankelk
iankelk / 01-install.sh
Last active November 6, 2023 21:09
Building an AI App with Clarifai-Python SDK
pip install -U clarifai
@iankelk
iankelk / 1-install.py
Created October 21, 2023 17:22
Clarifai YAML Workflows
pip install -U clarifai
@iankelk
iankelk / create_app.py
Last active September 13, 2023 15:19
Developer Preview: Clarifai Python SDK
# Create app
app = client.create_app(app_id="demo_app", base_workflow="Universal")
@iankelk
iankelk / A-1-1-create-conda
Last active September 1, 2023 21:36
Streamlit LLM App
conda create --name llm-text-adventure python=3.8
@iankelk
iankelk / generator.c
Last active May 9, 2023 17:35
CS265 generator.c fixed for 2023
/**
* ================================================
* = Harvard University | CS265 | Systems Project =
* ================================================
* ========== LSM TREE WORKLOAD GENERATOR =========
* ================================================
* Contact:
* ========
* - Kostas Zoumpatianos <kostas@seas.harvard.edu>
* - Michael Kester <kester@eecs.harvard.edu>
@iankelk
iankelk / blocking.cpp
Last active April 27, 2023 14:36
mutexes
// Locks to ensure exclusive or shared access to the LSM tree
std::unique_lock<std::shared_mutex> exclusiveLock;
std::shared_lock<std::shared_mutex> sharedLock;
// put, delete, load, benchmark, and quit operations are exclusive
if (op == 'p' || op == 'd' || op == 'l' || op == 'b' || op == 'q') {
exclusiveLock = std::unique_lock<std::shared_mutex>(sharedMtx);
// get, range, printStats, and info operations are shared
} else if (op == 'c' || op == 'g' || op == 'r' || op == 's' || op == 'i') {
@iankelk
iankelk / evaluate.py
Created April 3, 2023 15:55
Fixed workload evaluator in python for 2023
# ================================================
# = Harvard University | CS265 | Systems Project =
# ================================================
# ========== LSM TREE WORKLOAD EVALUATOR =========
# ================================================
# Contact:
# ========
# - Kostas Zoumpatianos <kostas@seas.harvard.edu>
# - Michael Kester <kester@eecs.harvard.edu>
@iankelk
iankelk / 1-install.py
Last active September 1, 2023 21:26
Clarifai Image Predictions Quick Start
!pip install -q clarifai-grpc && pip install --upgrade --no-deps -q protobuf