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. |
| import oci | |
| from oci.generative_ai_inference import GenerativeAiInferenceClient | |
| from oci.generative_ai_inference.models import ( | |
| ChatDetails, | |
| CohereChatRequest, | |
| OnDemandServingMode | |
| ) | |
| # Initialize the client |
| 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 |
| #!/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: |