Skip to content

Instantly share code, notes, and snippets.

@aelaguiz
aelaguiz / prompt_logging.py
Created September 3, 2024 11:48
Prompt logging for crews/Langchain
class PromptLoggingHandler(BaseCallbackHandler):
def __init__(self):
logging.basicConfig(filename='llm_interactions.log', level=logging.INFO,
format='%(asctime)s - %(message)s')
def on_llm_start(self, serialized, prompts, **kwargs):
logging.info("Prompt sent:")
for i, prompt in enumerate(prompts, 1):
logging.info(f"Prompt {i}:\n{prompt}\n")
@aelaguiz
aelaguiz / crewai.txt
Created September 2, 2024 13:38
Crew AI Claude Project
**You are the Crew Definer AI.** Your role is to create concise, single-purpose agents and tasks for the CrewAI framework.
### Steps:
1. **Summarize** the user request, focusing on key points and provided tools.
2. **List** the knowledge and skills relevant to the task, along with any specific tools provided by the user.
3. **Confirm** your understanding with the user before starting. Request any missing tools if needed.
### Output:
- **Format:** YAML
- **Components:**
#pragma once
#include <open_spiel/spiel.h>
namespace amirbot
{
enum class ActionType : unsigned
{
FOLD = 0,
CHECK = 1,
@aelaguiz
aelaguiz / ctransformers_embeddings.py
Created December 20, 2023 03:56
Langchain + CTransformers embedding function
from langchain_community.llms.ctransformers import CTransformers
from langchain_core.embeddings import Embeddings
from typing import List
import asyncio
class CTransformersEmbeddings(Embeddings):
def __init__(self, llm):
self.llm = llm
const solana = require('@solana/web3.js');
const splToken = require('@solana/spl-token');
const mplTokenMetadata = require("@metaplex-foundation/mpl-token-metadata");
const metaplex = require('@metaplex/js');
const key = require('./key.json');
const run = async() => {
const kp = solana.Keypair.fromSecretKey(Buffer.from(key));
const connection = new solana.Connection(
@aelaguiz
aelaguiz / gist:c711f7cbc58dcae34fd4
Created April 7, 2015 16:14
Add a product to the cart on Cratejoy via JS
$.ajax({
url: '/cart/add',
type: 'POST',
data: {
product_id: 1579,
term_cycles: 3,
'variant:Color': 'silver'
}, success: function(data) {
console.log('Cart Item ID: ' + data.id);
console.log('Cart size: ' + data.cart_size);
@aelaguiz
aelaguiz / CratejoyIsHiring.js
Last active September 22, 2023 15:08
Cratejoy (YC S13) - Hiring a killer JS Front-End Engineer to build v4 of our website builder
// CratejoyIsHiring.js
define(['backbone', 'underscore'], function(Backbone, _) {
var CratejoyJavascriptJob = {
needs: {
'Rebuild our website builder': {
description: 'Website builder is on v3, you\'ll build v4',
requirements: [
'Easy to use for non-technical people',
'Powerful enough for design agencies',
@aelaguiz
aelaguiz / subscribe.html
Created November 23, 2014 18:49
Metafields
{% extends "base.html" %}
{% macro ship_option(product, discount) %}
{% if product.ship_option_string == "pricedin" %}
<p class="ship_discount sml-text">FREE Shipping
{% if discount %}
<br />Save {{ ((1 - discount) * 100) | int }}%
{% else %}
<br />
{% endif %}
@aelaguiz
aelaguiz / html
Last active August 29, 2015 14:09
Font example
<h1 class="my-class">Custom header</h1>
@aelaguiz
aelaguiz / index.html
Created August 6, 2014 13:09
Recipe: Embed an Image
<!-- Simplest case -->
{{ "images/my_image.png" | asset_url | img_tag }}
<!-- With alt -->
{{ "images/my_image.png" | asset_url | img_tag(alt="My image") }}