Skip to content

Instantly share code, notes, and snippets.

View skaag's full-sized avatar

Aric Fedida skaag

View GitHub Profile
@skaag
skaag / ToolCallingAgent.py
Created June 25, 2024 06:12
Fixes to the experimental Tool Calling Agent in LangFlow 1.0.2 that makes it work with Pydantic V1 based Tools
from typing import Dict, List, cast
from langchain.agents import AgentExecutor, BaseSingleActionAgent
from langchain.agents.tool_calling_agent.base import create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate
from langflow.custom import Component
from langflow.io import BoolInput, HandleInput, MessageTextInput, Output
from langflow.schema import Data
from langflow.schema.message import Message
@skaag
skaag / tool_url.py
Created June 25, 2024 06:10
An example LangFlow "Tool" that fetches data from a URL
import importlib
from langchain.tools import StructuredTool
from pydantic.v1 import BaseModel, Field
import requests
# Define the input schema
class JobDataInput(BaseModel):
job_id: int = Field(description="ID of the job to retrieve")
# Define the function to load job data
@skaag
skaag / regex_extract.py
Created June 5, 2024 17:11
Langflow Node that extracts data using RegEx
from typing import Optional, Union, List
import re
from langflow.custom import CustomComponent
from langflow.field_typing import Text
from langflow.schema import Record
class ExtractWithRegexComponent(CustomComponent):
display_name = "Extract with Regex"
description = "Extracts text from input based on a specified regular expression."
@skaag
skaag / n8n_csv_import.js
Created January 22, 2024 17:16
Converts CSV data from a "data" field to actual records
// Define a function to convert a single CSV string to a JSON object
function csvToJson(csv) {
const lines = csv.split('\n').map(line => line.trim()).filter(line => line !== '');
// Split the lines at line breaks, trim whitespace, and remove empty lines
const headers = lines[0].split(',');
// Split the first line to get headers
return lines.slice(1).map(line => {
const data = line.split(',');
@skaag
skaag / docker-compose.yml
Created December 20, 2022 19:16
Immich docker-compose.yml
# Explanation: In this case, PostgreSQL and Redis are both already
# installed on the host, so this configuration skips them entirely,
# and removes the dependency on them from other images
version: "3.8"
services:
immich-server:
image: altran1502/immich-server:release
entrypoint: ["/bin/sh", "./start-server.sh"]
@skaag
skaag / .env
Created December 20, 2022 19:12
Immich .env file
###################################################################################
# Database
###################################################################################
DB_HOSTNAME=host.docker.internal
DB_USERNAME=immich
DB_PASSWORD=immich
DB_DATABASE_NAME=photosdb
# Optional Database settings:
@skaag
skaag / dmesg.txt
Created March 14, 2020 14:51
Surface Pro 4 dmesg
[ 0.000000] microcode: microcode updated early to revision 0xca, date = 2019-09-26
[ 0.000000] Linux version 5.1.15-surface-linux-surface (jake@jake-Surface-Laptop) (gcc version 8.3.0 (Ubuntu 8.3.0-6ubuntu1~18.10.1)) #8 SMP Thu Jun 27 12:03:55 EDT 2019
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-5.1.15-surface-linux-surface root=UUID=4e77cc61-ddb2-46d6-86c7-6089859c80f0 ro quiet splash vt.handoff=1
[ 0.000000] KERNEL supported cpus:
[ 0.000000] Intel GenuineIntel
[ 0.000000] AMD AuthenticAMD
[ 0.000000] Hygon HygonGenuine
[ 0.000000] Centaur CentaurHauls
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating point registers'
[ 0.000000] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
@skaag
skaag / gist:df101bc975ba14e7114e6b6f1ee5f189
Created June 25, 2019 21:15
Cache Microsoft and Apple Updates
# Cache windows and apple updates in Squid:
refresh_pattern -i windowsupdate.com/.*\.(cab|exe|ms[i|u|f|p]|[ap]sf|wm[v|a]|dat|zip|psf) 43200 80% 129600 reload-into-ims;
refresh_pattern -i microsoft.com/.*\.(cab|exe|ms[i|u|f|p]|[ap]sf|wm[v|a]|dat|zip|psf) 43200 80% 129600 reload-into-ims;
refresh_pattern -i windows.com/.*\.(cab|exe|ms[i|u|f|p]|[ap]sf|wm[v|a]|dat|zip|psf) 43200 80% 129600 reload-into-ims;
refresh_pattern -i microsoft.com.akadns.net/.*\.(cab|exe|ms[i|u|f|p]|[ap]sf|wm[v|a]|dat|zip|psf) 43200 80% 129600 reload-into-ims;
refresh_pattern -i deploy.akamaitechnologies.com/.*\.(cab|exe|ms[i|u|f|p]|[ap]sf|wm[v|a]|dat|zip|psf) 43200 80% 129600 reload-into-ims;
refresh_pattern -i ([^.]+.|)(download|adcdownload).(apple.|)com/.*\.(pkg|dmg) 4320 100% 43200 reload-into-ims;
I, [2018-08-10T01:20:52.963033 #8288] INFO -- : [diaspora:web] sleeping for :start_grace 2.5
I, [2018-08-10T01:20:55.463482 #8288] INFO -- : [diaspora:web] load_external_pid_file: pid_file found, but process <8521> not found
E, [2018-08-10T01:20:55.463635 #8288] ERROR -- : [diaspora:web] exit status 1, process <8521> (from /home/diaspora/diaspora/tmp/pids/web.pid) was not found; ensure that the pid_file is being updated correctly (you should check the process logs ["/home/diaspora/diaspora/log/eye_processes_stdout.log", "/home/diaspora/diaspora/log/eye_processes_stderr.log"])
E, [2018-08-10T01:20:55.463684 #8288] ERROR -- : [diaspora:web] process <> failed to start (:not_really_running)
I, [2018-08-10T01:20:55.464061 #8288] INFO -- : [diaspora:web] switch :crashed [:starting => :down] crashed
I, [2018-08-10T01:20:55.464457 #8288] INFO -- : [diaspora:web] schedule :check_crash (crashed)
I, [2018-08-10T01:20:55.464534 #8288] INFO -- : [diaspora:web] <= restore
I, [2018-08-10T01:20:55.464576 #8288] INFO --
@skaag
skaag / to-mono.sh
Created August 29, 2017 18:36
Ghostscript recipe to convert a PDF to mono
gs -o $1-mono.pdf \
-sDEVICE=pdfwrite \
-r600 \
-dCompatibilityLevel=1.4 \
-dPDFSETTINGS=/screen \
-dEmbedAllFonts=true \
-dSubsetFonts=true \
-sColorConversionStrategy=/Mono \
-sColorConversionStrategyForImages=/Mono \
-c "/osetrgbcolor {/setrgbcolor} bind def /setrgbcolor {pop [0 0 0] osetrgbcolor} def" \