Skip to content

Instantly share code, notes, and snippets.

View thorwhalen's full-sized avatar

Thor Whalen thorwhalen

View GitHub Profile

Code Generation Template Improvements

Summary

I've created three improved templates for your code generation use case, each with different levels of detail and structure. All are significant improvements over your original template.


Key Improvements Made

"""
Vector Processing Pipeline Service
This module provides a FastAPI service for text segment processing through various
stages including embedding, clustering, and dimensionality reduction (planarization).
The service allows for:
- Individual processing of segments through specific stages
- Pipeline processing that combines multiple stages efficiently
"""
This module defines a FastAPI application that demonstrates a simple pipeline
processing system. The system allows users to specify which stages they want
to include in the processing pipeline, and the system will automatically
compute and return the results for those stages.
"""
from fastapi import FastAPI, Depends, HTTPException
from pydantic import BaseModel
from typing import (
@thorwhalen
thorwhalen / github_raw_utils.py
Created November 28, 2024 10:48
github utils for raw sources
from urllib.parse import urlparse
import os
from functools import lru_cache
def ensure_raw_github_url(url):
"""
This function takes a GitHub URL and returns the raw version of the URL.
Args:
@thorwhalen
thorwhalen / acquire_content.py
Created November 8, 2024 10:46
A simple but flexible content acquisition (python) function
# Note, the only two third party packages your need are:
# pip install dol
# pip install request
import os
import requests
from typing import Dict, Union, MutableMapping, KT, VT, TypeVar, Callable, Any
from functools import partial
@thorwhalen
thorwhalen / Extract Dev Meeting Takeaways from Video, Audio or Text.md
Last active July 27, 2024 10:08
Code that contains tools to get from video or audio to text and key takeaways for developers. Also demos some `dol` and `oa` tools.

Extract Dev Meeting Takeaways from Video/Audio

The following code contains tools to get from video or audio to text and key takeaways for developers. Can be applied to video, audio or text, so can be used from meeting recordings, video demos, etc.

The following code is also meant to be a demo of the dol tools Pipe and written_key as well as the oa.prompt_function tool.

Requires dol, oa, speech_recognition and moviepy to be installed, though the last two are contained in functions and could be replaced.

@thorwhalen
thorwhalen / openai_api_costs.py
Last active December 6, 2023 10:32
OpenAI API Cost calculator
api_costs = {
'gpt-4-1106-preview': {"input": 0.01, "output": 0.03, "unit": "$/1K tokens"},
'gpt-4-1106-vision-preview': {"input": 0.01, "output": 0.03, "unit": "$/1K tokens"},
'gpt-4': {"input": 0.03, "output": 0.06, "unit": "$/1K tokens"},
'gpt-4-32k': {"input": 0.06, "output": 0.12, "unit": "$/1K tokens"},
'gpt-3.5-turbo-1106': {"input": 0.0010, "output": 0.0020, "unit": "$/1K tokens"},
'gpt-3.5-turbo-instruct': {"input": 0.0015, "output": 0.0020, "unit": "$/1K tokens"},
'gpt-3.5-turbo': {"training": 0.0080, "input": 0.0030, "output": 0.0060, "unit": "$/1K tokens"},
'davinci-002': {"training": 0.0060, "input": 0.0120, "output": 0.0120, "unit": "$/1K tokens"},
'babbage-002': {"training": 0.0004, "input": 0.0016, "output": 0.0016, "unit": "$/1K tokens"},
@thorwhalen
thorwhalen / Scrape Aix club addresses.ipynb
Created September 9, 2022 12:38
Scrape Aix club addresses
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thorwhalen
thorwhalen / empty_values_options.py
Created August 17, 2022 19:25
Options for a singleton "Empty" value with pickability and repr
from tested import validate_codec
Empty1 = type('Empty', (), {})()
print("\nEmpty1 = type('Empty', (), {})()")
print(f"{validate_codec(Empty1)=}")
_Empty2 = type('Empty', (), {})
_Empty2.__module__ = __name__
@thorwhalen
thorwhalen / Head of state salaries -- extraction and processing.py
Created August 11, 2022 15:59
Head of state salaries -- extraction and processing
# get raw df
import qo
df = qo.get_tables_from_url('https://en.wikipedia.org/wiki/List_of_salaries_of_heads_of_state_and_government')[3]
df = df.set_index('State')
# formatting and extracting salaries