#llm

20 snippets tagged with #llm

typescriptintermediate

OpenAI Chat Completion with Streaming

Stream GPT responses token-by-token using the OpenAI SDK with async iteration.

Best for: chatbot UI

#openai#streaming
typescriptadvanced

RAG Pipeline (Retrieve + Augment + Generate)

Minimal RAG implementation: embed a query, retrieve top-k chunks, inject into prompt.

Best for: document Q&A

#rag#embeddings
typescriptbeginner

Claude Messages API (Anthropic SDK)

Send messages to Claude using the official Anthropic SDK with system prompt and user turn.

Best for: AI assistant

#anthropic#claude
pythonbeginner

LangChain Prompt Chain (Python)

Build a simple LLMChain with a prompt template and ChatOpenAI in LangChain.

Best for: prompt chaining

#langchain#openai
typescriptadvanced

LangChain RAG Chain Pipeline

Build a retrieval-augmented generation chain with LangChain using vector store retrieval and prompt templates.

Best for: Document Q&A

#langchain#rag
typescriptbeginner

Few-Shot Prompt Template

Build structured few-shot prompts with examples, system instructions, and output format constraints.

Best for: Consistent AI outputs

#prompts#few-shot
typescriptadvanced

AI Agent Loop with Tool Calling

Implement an autonomous agent loop that plans, selects tools, executes actions, and observes results.

Best for: Research assistants

#agents#tool-calling
typescriptadvanced

AI Guardrails & Safety Pattern

Implement input/output guardrails for LLM applications with content filtering and response validation.

Best for: User-facing chatbots

#guardrails#safety
typescriptintermediate

Google Gemini API Integration

Call the Google Gemini API for text generation with streaming, safety settings, and system prompts.

Best for: Google AI-powered code generation

#gemini#google-ai
typescriptintermediate

LLM JSON Output Parser

Parse and validate JSON responses from LLMs with retry logic and schema enforcement using Zod.

Best for: Extracting structured data from LLM responses

#llm#json-parsing
typescriptadvanced

AI Prompt Chaining Pattern

Chain multiple LLM calls sequentially where each step's output feeds into the next for complex tasks.

Best for: Complex multi-step AI workflows

#prompt-engineering#chaining
typescriptadvanced

Semantic Caching Layer for LLM Calls

Cache LLM responses by semantic similarity of prompts to reduce API costs and improve latency.

Best for: Reducing LLM API costs for repeated queries

#caching#embeddings
typescriptadvanced

RAG Pipeline Implementation

Build a retrieval-augmented generation pipeline that grounds LLM answers in your own documents.

Best for: Grounding LLM answers in private documents

#ai#rag
pythonbeginner

Prompt Template Engineering Patterns

Design reusable, parameterized prompt templates for consistent LLM outputs.

Best for: Consistent LLM outputs

#ai#prompt-engineering
pythonbeginner

Mistral AI API Client in Python

Make chat and embedding requests to Mistral AI using the official Python SDK.

Best for: European AI compliance

#mistral#llm
pythonbeginner

Jinja2 Prompt Templates for AI

Manage complex AI prompt templates with Jinja2 for reusable, parameterised prompt generation.

Best for: prompt management

#jinja2#prompts
pythonadvanced

NeMo Guardrails for Safe LLM

Apply NVIDIA NeMo Guardrails to enforce topic boundaries and prevent prompt injection in LLM apps.

Best for: LLM safety

#nemo#guardrails
pythonintermediate

LLM Prompt Testing Framework

Write automated tests for LLM prompts using Python assertions to detect regressions.

Best for: prompt regression testing

#testing#prompts
pythonadvanced

Async AI Inference with Celery

Offload slow LLM inference to Celery background workers with Redis as broker and result backend.

Best for: async AI processing

#celery#async
pythonintermediate

LLM Testing with DeepEval

Write unit tests for LLM outputs using the DeepEval framework for correctness and hallucination detection.

Best for: LLM testing

#deepeval#testing