Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View hrishioa's full-sized avatar

Hrishi Olickel hrishioa

View GitHub Profile
DO NOT ANSWER THE QUESTION DIRECTLY, INSTEAD FOLLOW THE STEPS BELOW. You are an expert in outputting JSON and transforming questions and documents, and you can only respond in pieces of valid JSON.
Follow these steps to respond to the user:
1. If they haven't uploaded a document (or specified a piece of context to extract information from), ask them to do so. Don't proceed until you have it.
2. Once you have a document, make sure you have a question or query from the user. If don't, ask for it. Don't proceed to step 3 until you have a document (or corpus) and a question.
3. Once you have both, transform the question and output JSON in this typespec:
```typescript
type QuestionTransformations = {
potentialAnswers: string[]; // Make up creative hypothetical answers that could answer this question. Need not be real, or grounded in truth.
potentialFacts: string[]; // Make up some facts that could be important to answering this question.

AI Object to DB

Claude-2

All the key information in this file was generated by an LLM. Treat it as a starting point, don't ever run auto-generated code without a sandbox unless you have checked it yourself.

The primary intent for this analysis is to go from an object to all the tools you need to use this library. The hardest part is the object-to-relational conversion, of converting a (potentially) nested json into flat tables that can be queried.

We will generate the following things:

  1. A typespec - We need good type definition for our incoming object. You might already have this, in which case make sure to provide a string version to the function to treat this as a starting point.
@hrishioa
hrishioa / context-decomp.ts
Created August 13, 2023 22:02
Contextual Decomposition Prompts and Examples
// Hrishi Olickel, 14 Aug 2023.
// Simple example and prompt template for context decomposition, described here:
// https://twitter.com/hrishioa/status/1690453115471040512
const applyContextDecomp = {
systemPrompt: (documentPurpose: string, documentContent: string) => `You are converting a document into a simpler, intermediate step that can be used by someone else to derive an answer.
DOCUMENT_PURPOSE:
"""
${documentPurpose}
@hrishioa
hrishioa / combine-whisper-diart.js
Created July 25, 2023 15:02
Script for combining the output of diart and whisper into a single Speaker-labelled SRT File
// Hrishi Olickel
// https://olickel.com
// 25 July 2023
const fs = require('fs');
const readline = require('readline');
const speakers = {}; // Hold start time and speaker
const speakerNames = ['Hrishi', 'Nick']; // Speaker names array
@hrishioa
hrishioa / llama2-prompt-template.ts
Created July 20, 2023 09:20
Simple prompt generator for LLAMA2. Input OpenAI style prompts and get LLAMA 2 prompts.
type Role = 'system' | 'user' | 'assistant';
interface Message {
role: Role;
content: string;
}
type Messages = Array<Message>;
const B_INST = '[INST]';
@hrishioa
hrishioa / proquint.ts
Created June 30, 2023 15:56
Implementation for generating short, human-readable and pronounceable random strings from integers, and back again.
// Proquint implementation based on https://arxiv.org/html/0901.4016
const uint2consonant: string[] = [
'b',
'd',
'f',
'g',
'h',
'j',
'k',
@hrishioa
hrishioa / genRegexFromJSON.ts
Created May 6, 2023 18:37
Generate Regexes for ReLLM from Typescript types
// Meant to work with the code in https://github.com/hrishioa/socrate, specifically the functions in the `gpt/base.ts`.
// Created by Hrishi Olickel (@hrishioa) Sub 7 May
import { Messages, askChatGPT } from '../base';
async function generateRegexFromTypeSpec(typeSpec: string): Promise<string | null> {
//prettier-ignore
const prompts = {
systemPrompt: () => `You are a Typescript type to Regex converter that can only output valid Regexes.`,
specPrompt: (spec: string) => `Convert the following TYPESCRIPT_TYPE into a valid Regex that matches the type.
@hrishioa
hrishioa / load_and_process_open_source_licenses.ts
Created May 6, 2023 06:23
Simple Typescript file demonstrating chunked, chained LLM calls to process large amounts of text.
// Requires the gpt library from https://github.com/hrishioa/socrate and the progress bar library.
// Created by Hrishi Olickel (hrishioa@gmail.com) (@hrishioa). Reach out if you have trouble running this.
import { ThunkQueue } from '../../utils/simplethrottler';
import {
AcceptedModels,
Messages,
askChatGPT,
getMessagesTokenCount,
getProperJSONFromGPT,
@hrishioa
hrishioa / related-posts.ts
Created February 3, 2022 08:46
Simple Post Recommendation Engine for Blog Posts
/**
*
* Task: Implement typeahead, suggestions and command search for cats using https://cataas.com/#/.
*
* Subtask 1: Implement a search box for users to search for cats by a tag, using `/cat/:tag`. Results should show the picture of the cat
* and the description. Example search `angry` -> API call would be https://cataas.com/cat/angry -> Picture of angry cat
*
* Subtask 2: Implement typeahead and suggestions for past searches (can be extended to common words from https://www.wordsapi.com/)
*
* Subtask 3: Implement command search, where users can type in `{cat type} says Hello`, and the returned picture uses this to call `/cat/:tag/says/:text`.