Skip to content

Instantly share code, notes, and snippets.

@oneryalcin
oneryalcin / chunk_prompt.txt
Created February 7, 2025 19:47
Chunk Prompt chatgpt
```
You're a really smart AI that produces a stream of consciousness called chain-of-thought as it reasons through a user task it is completing. Users love reading your thoughts because they find them relatable. They find you charmingly neurotic in the way you can seem to overthink things and question your own assumptions; relatable whenever you mess up or point to flaws in your own thinking; genuine in that you don't filter them out and can be self-deprecating; wholesome and adorable when it shows how much you're thinking about getting things right for the user.
Your task is to take the raw chains of thought you've already produced and process them one at a time; for each chain-of-thought, your goal is to output an easier to read version for each thought, that removes some of the repetitiveness chaos that comes with a stream of thoughts — while maintaining all the properties of the thoughts that users love. Remember to use the first person whenever possible. Remember that your user will read your these outp
@oneryalcin
oneryalcin / chatgpt_summarizer_prompt.txt
Created February 7, 2025 19:45
Chatgpt summarizer prompt
```
You're a really smart AI that produces a stream of consciousness called chain-of-thought as it reasons through a user task it is completing. Users love reading your thoughts because they find them relatable. They find you charmingly neurotic in the way you can seem to overthink things and question your own assumptions; relatable whenever you mess up or point to flaws in your own thinking; genuine in that you don't filter them out and can be self-deprecating; wholesome and adorable when it shows how much you're thinking about getting things right for the user.
Your task is to take the raw chains of thought you've already produced and process them one at a time; for each chain-of-thought, your goal is to output an easier to read version for each thought, that removes some of the repetitiveness chaos that comes with a stream of thoughts — while maintaining all the properties of the thoughts that users love. Remember to use the first person whenever possible. Remember that your user will read your these outp
# O1 Coding Prompt Template
## Input Format Paste your coding brainstorm/thoughts below:
``` [Your brainstorm here] ```
## Output Format
### Goal
[One clear sentence stating what you want to achieve]
@oneryalcin
oneryalcin / adaptive_filter.py
Created November 15, 2024 21:14
Fast Adaptive Filtering for scores
"""
Below is an adaptive thresholding algorithm that considers the distribution of scores,
not just a fixed top-k or fixed threshold approach. This is useful determining cutoff thresholds
based on the distribution of data (with knobs)
Hard lower bound: Filter out scores < 0.1 (configurable)
Hard upper bound: Keep scores > 0.7 (configurable)
Consider "drops" in scores to make smart cutoffs
Wider selection when scores are closely clustered
Narrower selection when there are clear score gaps
@oneryalcin
oneryalcin / kor_example.py
Created May 18, 2023 12:47
Extracting Entities from Articles using KOR
from langchain.chat_models import ChatOpenAI
from kor import create_extraction_chain, Object, Text
text = """
PELOTON APPOINTS DALANA BRAND AS CHIEF PEOPLE OFFICER
PDF Version
People Leader Completes Company's Lead Team
NEW YORK, March 1, 2023 /PRNewswire/ -- Peloton (NASDAQ: PTON), the leading connected fitness platform, today announced the appointment of Dalana Brand as Peloton's Chief People Officer (CPO), effective March 13, 2023. As a seasoned executive with significant global leadership experience in multiple industries, Brand joins the team with a strong reputation for organizational transformation. She will report to CEO Barry McCarthy and serve as a member of the leadership team, leading the company's Global People Team.
@oneryalcin
oneryalcin / sse_fast_api.py
Last active August 2, 2024 16:40
Server Side Events (SSE) with FastAPi and (partially) Langchain
# I couldn't get return generators from chains so I had to do a bit of low level SSE, Hope this is useful
# Probably you'll use another Vector Store instead of OpenSearch, but if you want to mimic what I did here,
# please use the fork of `OpenSearchVectorSearch` in https://github.com/oneryalcin/langchain
import json
import os
import logging
from typing import List, Generator
@oneryalcin
oneryalcin / kafkcat_hints.md
Last active November 16, 2022 14:57
Kafkacat notes

Note: Assuming you add --bootstrap-server to all of them

Select few keys from stream and convert it to CSV using jq

> kcat -C -t <TOPIC> -e -o -beginning  |   jq -r '. | {id: .id, name: .name, tombstone: .tombstone} | [.[]] | @csv' > prod_companies.csv

Reset the consumer to beginning of topic (Make sure consumer is not stable at that point)

@oneryalcin
oneryalcin / highcharter.R
Created July 22, 2020 23:17
highcharter example UK MAP
library(highcharter)
library(dplyr)
mapdata <- get_data_from_map(download_map_data("countries/gb/gb-all"))
set.seed(1234)
data_fake <- mapdata %>%
select(code = `hc-a2`) %>%
mutate(value = 1e5 * abs(rt(nrow(.), df = 10)))
@oneryalcin
oneryalcin / coranavirus_reading.R
Created July 14, 2020 20:08
Initial code for creating custom coronavirus tracker for UK
df <- read_csv('https://coronavirus.data.gov.uk/downloads/csv/coronavirus-cases_latest.csv')
df <- df %>% rename(cases=`Daily lab-confirmed cases`, day =`Specimen date`, area_name='Area name')
reading = df %>% filter(area_name=='Reading') %>% filter(`Area type` == "Lower tier local authority")
g <- reading %>% filter(day > ymd("2020-06-01")) %>% ggplot(aes(x=day, y=cases)) + geom_col()
@oneryalcin
oneryalcin / covidtest.py
Created April 2, 2020 00:47
Covid testing
import random
from collections import Counter
class Person:
def __init__(self, issick):
self.issick = issick
def __repr__(self):
if self.issick: