Skip to content

Instantly share code, notes, and snippets.

View paolodina's full-sized avatar
🔋
always on

pdina paolodina

🔋
always on
  • 05:23 (UTC +02:00)
View GitHub Profile
@karljuhlpep
karljuhlpep / dspy_codegen.py
Last active April 24, 2024 04:45
DSPy Module - CodeGen + Debugging
import subprocess
import dspy
### Note this code is not tested, and likely includes errors that need to be refined.
class IterativeCodeRefinement(dspy.Module):
def __init__(self):
super().__init__()
self.generate_pseudocode = dspy.ChainOfThought("task -> pseudocode")
@seanchatmangpt
seanchatmangpt / model_maker.py
Created February 23, 2024 00:48
Simplest pydantic instance creator.
import ast
import inspect
import dspy
from typing import Type
from pydantic import BaseModel
class User(BaseModel):
name: str
@seanchatmangpt
seanchatmangpt / gen_pydantic_instance.py
Last active April 14, 2024 20:11
Convert your prompt into a pydantic instance.
import ast
import logging
import inspect
from typing import Type, TypeVar
from dspy import Assert, Module, ChainOfThought, Signature, InputField, OutputField
from pydantic import BaseModel, ValidationError
logger = logging.getLogger(__name__)
logger.setLevel(logging.ERROR)
@elitan
elitan / utils.ts
Created November 5, 2023 10:13
Parse Open AI function calls JSON response with JavaScript/TypeScript
function escapeNewLines(str: string) {
return str.replace(/\n/g, '\\n');
}
function fixOpenAiNewLineResponse(str: string) {
return str
.split('"')
.map((chunk, index) => {
// Only replace \n inside the JSON string values, which are in every other index after splitting by "
if (index % 2 === 1) {
@342b45
342b45 / magic_link.ts
Last active June 26, 2023 06:46
Magic Link Implementation using lucia auth
@pmuens
pmuens / DB.test.ts
Created February 21, 2022 19:24
SQLite as a Graph Database
import DB from './DB'
describe('DB', () => {
let db: DB
const data = { name: 'Tom Cook', type: ['person', 'CEO'] }
beforeEach(() => {
db = new DB()
db.addNode('1', { name: 'Apple Computer Company', type: ['company', 'start-up'], founded: 'April 1, 1976' })
@dsebastien
dsebastien / svelte.config.cjs
Last active December 25, 2022 03:55
Svelte config that loads the postcss config
const sveltePreprocess = require('svelte-preprocess');
module.exports = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: sveltePreprocess({
// WARNING: Mandatory for the postcss config (postcss.config.js) and Tailwind to be loaded
postcss: {}, // <------ this is the important part :)
}), // can pass the options here using { }, but we use svelte.preprocess.config.js for that (gives us more context)
};

IRC friends, enemies and others,

Control of freenode has recently been seized by the proprietors of Freenode Limited, a holding company established by a previous head of freenode and a third party as part of a deal with a corporate sponsor. The terms of that deal were not disclosed, and remain unknown to me.

At the time, we, freenode's volunteer staff, were given informal guarantees that staff retained operational control of the network. The same guarantees were repeated after leadership was passed on to a new head of staff. I don't

@sindresorhus
sindresorhus / esm-package.md
Last active May 24, 2024 02:36
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@mingderwang
mingderwang / hardhat.config.js
Created January 14, 2021 06:42
hardhat.config.js use ganache as default network (example)
/**
* @type import('hardhat/config').HardhatUserConfig
*/
require('@nomiclabs/hardhat-ethers');
require('@openzeppelin/hardhat-upgrades');
module.exports = {
defaultNetwork: "ganache",
networks: {
ganache: {
url: "http://172.17.144.1:7545",