Skip to content

Instantly share code, notes, and snippets.

View vacmar01's full-sized avatar

Marius Vach vacmar01

View GitHub Profile
# /// script
# dependencies = [
# "dspy",
# "rich"
# ]
# ///
import dspy
import os
import inspect
➜ random_experiments uv run agent.py
Reading inline script metadata from `agent.py`
Enter your message or type 'exit' to quit.
👨‍💻User: what is the biggest file in the current folder?
Reasoning: To find the biggest file in the current folder, I first need to list the files
in the current directory. Once I have the list, I can inspect each file's size and
determine which one is the largest. The `list_files` function will give me the names of the
files, and then I can use `run_cmd` with a command like `ls -l` or `du -h` to get their
sizes.
Selected Function: list_files
from fasthtml.common import (
fast_app,
serve,
Main,
H1,
Article,
Div,
Form,
Textarea,
NotStr,
from fasthtml.common import *
from dataclasses import make_dataclass, fields
import datetime
from pathlib import Path
import yaml
def create_dataclass_from_schema(schema_dict, cls_name="DynamicClass"):
str2type = {
"str": str,
@vacmar01
vacmar01 / install_lemp_droplet.md
Created June 14, 2023 18:42
Install LEMP Stack on DigitalOcean Droplet.

How to Install Nginx, MySQL and PHP on an Ubuntu Droplet from DigitalOcean

This is meant to be as a reminder to myself and as a quick and dirty reference to others (heavily inspired by: https://www.techalyst.com/posts/laravel-hosting-with-digital-ocean-droplet-step-by-step-tutorial). It assumes you want to install a Laravel app afterwards, but it should be easily adaptable to other PHP apps.

I know that there are probably much more things you could config in your nginx (and maybe you should), but this works for now for me. I might update this with new things I learn.

1. Create DigitalOcean droplet

Choose the region that is nearest to you.

@vacmar01
vacmar01 / interpreter.py
Last active November 20, 2022 12:41
A quick and dirty re-implemented a small subset of the fastai Interpretation class for computer vision
class Interpreter:
def __init__(self, model, dl):
self.model = model
self.dl = dl
if hasattr(model, "loss"):
self.loss_func = self.model.loss
self.losses = torch.empty(0)
self.model.eval()
for batch in tqdm.tqdm(self.dl):
x, y = batch
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How to create a validation set for image classification"
]
},
{