Skip to content

Instantly share code, notes, and snippets.

View owainlewis's full-sized avatar

Owain Lewis owainlewis

View GitHub Profile

AI Agents 101

In this short video I'll show you how to write an AI agent from scratch in Python using just a few lines of simple code. We'll learn how AI agents work.


The truth: An AI agent is just an LLM in a loop that can call functions.


(ns oci-generative-ai
(:import [com.oracle.bmc.auth ConfigFileAuthenticationDetailsProvider]
[com.oracle.bmc.generativeaiinference GenerativeAiInferenceClient]
[com.oracle.bmc.generativeaiinference.model ChatDetails
CohereChatRequest
OnDemandServingMode
ChatRequest]
[com.oracle.bmc.generativeaiinference.requests ChatRequest]))
(defn create-auth-provider
import tiktoken
from docling.document_converter import DocumentConverter
from docling_core.transforms.chunker.hybrid_chunker import HybridChunker
from docling_core.transforms.chunker.tokenizer.openai import OpenAITokenizer
def pdf_to_chunks(pdf_url_or_path: str, max_tokens: int = 500):
"""
Convert a PDF to text chunks ready for vector storage.
@owainlewis
owainlewis / oci_gen_ai.py
Created September 17, 2025 13:57
Calling OCI GenAI
import oci
from oci.generative_ai_inference import GenerativeAiInferenceClient
from oci.generative_ai_inference.models import (
ChatDetails,
CohereChatRequest,
OnDemandServingMode
)
# Initialize the client
@owainlewis
owainlewis / images.py
Created July 29, 2025 06:08
Parallel Image Requests (Python, OpenAI)
import aiohttp
import asyncio
import os
import time
import base64
import aiofiles
from pathlib import Path
class SimpleImageGenerator:
{
"name": "YouTube Research Agent",
"nodes": [
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-40,
-320
@owainlewis
owainlewis / setup.sh
Last active February 15, 2025 07:24
#!/usr/bin/env bash
sudo yum install -y git-core zlib zlib-devel gcc-c++ patch readline readline-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison curl sqlite-devel
cd
git clone git://github.com/sstephenson/rbenv.git .rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bash_profile
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: web
spec:
serviceName: "nginx"
replicas: 2
selector:
matchLabels:
app: nginx
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: example-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: hello-world.info
http:
@owainlewis
owainlewis / GPG.md
Last active April 18, 2019 08:12
GPG Tutorial

Quick Guide to using GPG

❯ gpg --gen-key

List keys

❯ gpg --list-keys