Skip to content

Instantly share code, notes, and snippets.

View JGalego's full-sized avatar
🤯
Fac ut gaudeam!

João Galego JGalego

🤯
Fac ut gaudeam!
View GitHub Profile
@JGalego
JGalego / jcvd_chat.py
Last active November 20, 2023 15:05
A simple Streamlit app to chat with JCVD (powered by Claude v2) using Amazon Bedrock
# pylint: disable=line-too-long
"""
JCVD Chat 🕺💬
A simple Streamlit app to chat with JCVD (powered by Claude v2) using Amazon Bedrock
https://aws.amazon.com/bedrock/claude/
> Adapted from Streamlit's Build conversational apps
https://docs.streamlit.io/knowledge-base/tutorials/build-conversational-apps
@JGalego
JGalego / meh.py
Last active December 12, 2023 18:03
MEH! 😒🐑 A simple conversational app powered by LangChain and Streamlit, featuring Amazon Translate and Amazon Polly
r"""
__ __ ______ _ _ _
| \/ | ____| | | | |
| \ / | |__ | |__| | |
| |\/| | __| | __ | |
| | | | |____| | | |_|
|_| |_|______|_| |_(_) My Expert Helper
## Overview
@JGalego
JGalego / Dockerfile
Created March 1, 2024 11:27
PyTorch CPU-only installation with uv ⚡️ and Docker 🐋
ARG TORCH_VERSION=2.2.1
FROM python:3.12@sha256:35eff340c0acd837b7962f77ee4b8869385dd6fe7d3928375a08f0a3bdd18beb AS basic
# Install uv
# https://github.com/astral-sh/uv
ENV VIRTUAL_ENV=/usr/local
ADD --chmod=755 https://astral.sh/uv/install.sh /install.sh
RUN /install.sh && \
rm install.sh
@JGalego
JGalego / interviewer.py
Last active May 7, 2024 01:37
Job interviewer 🧑🏻‍💼 powered by Amazon Bedrock / Claude
r"""
____ _ _
| _ \ | | | |
| |_) | ___ __| |_ __ ___ ___| | __
| _ < / _ \/ _` | '__/ _ \ / __| |/ /
| |_) | __/ (_| | | | (_) | (__| <
|____/ \___|\__,_|_| \___/ \___|_|\_\
|_ _| | | (_)
| | _ __ | |_ ___ _ ____ ___ _____ _____ _ __
| | | '_ \| __/ _ \ '__\ \ / / |/ _ \ \ /\ / / _ \ '__|
@JGalego
JGalego / demo.py
Last active March 8, 2024 14:38
A simple ConversationalRetrievalChain demo backed by Cohere Embed v3 and Claude 3 Sonnet via Amazon Bedrock 🏔️
"""
A simple ConversationalRetrievalChain demo
backed by Cohere Embed v3 and Claude 3 Sonnet
via Amazon Bedrock 🏔️
"""
import os
from urllib.request import urlretrieve
@JGalego
JGalego / bedrock_scraper.py
Last active May 13, 2024 10:21
Bedrock Scraper with ScrapeGraphAI 🕷️
r"""
Bedrock Scrapper with ScrapeGraphAI
/\ \ / /\
//\\ .. //\\
//\(( ))/\\
/ < `' > \
"""
import boto3
@JGalego
JGalego / describeforme.py
Last active May 22, 2024 17:41
DescribeForMe // Bedrock Edition ⛰️
"""
Describe for Me (Bedrock edition ⛰️)
Image ==> Bedrock -> Translate -> Polly ==> Speech
"""
import argparse
import base64
import json
@JGalego
JGalego / install_sam.sh
Last active June 27, 2024 10:46
Install AWS SAM
# Install
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html
curl -L https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip -o aws-sam-cli-linux-x86_64.zip
unzip aws-sam-cli-linux-x86_64.zip -d sam-installation
sudo ./sam-installation/install
# Clean
rm aws-sam-cli-linux-x86_64.zip
rm -rf sam-installation
@JGalego
JGalego / harvest_creds.sh
Last active June 27, 2024 10:52
Harvest AWS Credentials from IMDSv2
# Adapted from https://rhynorater.github.io/AWS-Metadata-Identity-Credentials
token=`curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600"` \
export AWS_DEFAULT_REGION=`curl -s -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/latest/meta-data/placement/region`
creds=`curl -s -H "X-aws-ec2-metadata-token: $token" http://169.254.169.254/latest/meta-data/identity-credentials/ec2/security-credentials/ec2-instance/`
export AWS_ACCESS_KEY_ID=`echo ${creds} | jq -r .AccessKeyId`
export AWS_SECRET_ACCESS_KEY=`echo ${creds} | jq -r .SecretAccessKey`
export AWS_SESSION_TOKEN=`echo ${creds} | jq -r .Token`
@JGalego
JGalego / slambda_chat.py
Last active June 27, 2024 12:16
Chat with a SLM running on AWS Lambda 🤏
r"""
_____ _ __ __ _ _ _____ _ _
/ ____| | | \/ | | | | / ____| | | |
| (___ | | __ _| \ / | |__ __| | __ _ | | | |__ __ _| |_
\___ \| | / _` | |\/| | '_ \ / _` |/ _` | | | | '_ \ / _` | __|
____) | |___| (_| | | | | |_) | (_| | (_| | | |____| | | | (_| | |_
|_____/|______\__,_|_| |_|_.__/ \__,_|\__,_| \_____|_| |_|\__,_|\__|
"""
import os