Skip to main content
Background

Build an Edge-Accelerated LLM Chatbot

Learn to build an LLM chatbot with Akamai Functions and GPU-powered inference, then deploy it globally.

Timestamped summary

Timestamped summary

[00:00–00:58] Introduction: Thorsten Hans introduces the tutorial on building an LLM-based chatbot application on Akamai Cloud using Linode GPU instances, Ollama, Spin, and Akamai Functions.

[00:58–02:22] Architecture overview: Explanation of the multitier system diagram, detailing the Linode instance with an NVIDIA GPU running Ollama, and Akamai Functions hosting the Spin application (Astro front end and TypeScript API) with a distributed key-value store.

[02:22–03:30] Spin and application components: Overview of Spin as a CNCF WebAssembly framework and an explanation of the two application components: the Astro front end and the TypeScript API.

[03:30–06:21] API logic and caching flow: Walkthrough of how the TypeScript API processes requests, queries the distributed key-value store to serve cached responses, applies prompt construction and guardrails for new queries, and caches generated responses.

[06:21–09:03] Infrastructure setup with Terraform: Deep dive into the Terraform configuration, showing the linode provider, instance provisioning with dedicated NVIDIA GPUs, and the null provider polling logic.

[09:03–10:05] Firewall and network configuration: Examination of the Linode firewall setup in Terraform, specifying rules for SSH access and Ollama HTTP API traffic on port 11434.

[10:05–12:26] Cloud-init and GPU driver installation: Analysis of linode.yaml cloud-init scripts that automate package updates, GPU driver installation, system reboots, and Ollama service initialization.

[12:26–14:49] Executing Terraform provisioning: Running terraform apply to construct the cloud infrastructure, followed by a fast-forward of the approximately five-minute provisioning process.

[14:49–16:07] Spin application manifest (spin.toml): Inspection of spin.toml, detailing HTTP triggers, component routing, environment variables, key-value store access, and outbound host permissions.

[16:07–17:53] API implementation and guardrails: Code walkthrough of index.ts, handler.ts, and guardrails.ts, explaining request validation, input length limits (500 characters), and regex pattern matching for prompt injection prevention.

[17:53–19:30] Session history and key-value caching: Explanation of cookie-based session tracking and implementation of kvService.ts for checking and returning cached query responses from the key-value store.

[19:30–20:54] LLM invocation via LangChain: Detailed examination of llaService.ts showing prompt assembly (system prompt, session history, user query) and LLM invocation using LangChain JS and Ollama packages.

[20:54–21:38] Package dependencies: Review of package.json highlighting Spin SDK and LangChain dependencies required for building the WebAssembly application.

[21:38–22:27] Compilation to WebAssembly: Executing spin build in the terminal to compile both front-end and API components into .wasm targets.

[22:27–23:59] Deploying to Akamai Functions: Authenticating via spin aka login and executing spin aka deploy with environmental variables to publish the WebAssembly application globally.

Share