Skip to content

Instantly share code, notes, and snippets.

@cnndabbler
cnndabbler / vignette_06_JUN_2023.md
Last active June 7, 2023 01:55
llama-cpp-python to host local LLM running inside no-code visual programming chat flow

Part 1/2 : Set up an OpenAI compatible CPU-based local LLM model

  1. What is llama-cpp-python

    • llama-cpp-python offers a web server which aims to act as a drop-in replacement for the OpenAI API. This allows you to use llama.cpp compatible models with any OpenAI compatible client (language libraries, services, etc).
    • https://github.com/abetlen/llama-cpp-python
  2. Installation

@cnndabbler
cnndabbler / supervised_swarm.py
Created December 12, 2024 22:33
This script implements a sophisticated movie purchase system using OpenAI's Swarm framework for multi-agent orchestration. The system handles the entire flow from movie selection to shipping using specialized AI agents working in concert.
"""
Movie Purchase System with Multi-Agent Orchestration
This script implements a sophisticated movie purchase system using OpenAI's Swarm framework
for multi-agent orchestration. The system handles the entire flow from movie selection to
shipping using specialized AI agents working in concert.
Key Components:
- Supervisor Agent: Orchestrates the overall purchase flow
- Buy Movie Agent: Handles pricing and purchase transactions
@cnndabbler
cnndabbler / swarm_ollama_pydantic.py
Created December 15, 2024 00:58
Highlighting the integration of Ollama, OpenAI Swarm, and Pydantic to create structured AI agents. Features keywords, data streams, and a developer interface symbolizing local-first AI frameworks and structured programming practices.
from openai import OpenAI
from rich import print
client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")
# model="qwq"
model="qwen2.5-coder:32b"
# TESTING INFERENCE
@cnndabbler
cnndabbler / swarm_ollama_math_tutor.py
Created December 16, 2024 00:37
Code implementing an Agentic collaboration between a student and two AI agents, the 'Math Solver Agent' and 'Math Validator Agent,' working together to solve math problems.
from openai import OpenAI
from rich import print
from rich.console import Console
from rich.panel import Panel
from rich.prompt import Prompt
from rich.markdown import Markdown
from rich.text import Text
from rich.style import Style
from swarm import Swarm, Agent
from swarm.types import Response
@cnndabbler
cnndabbler / pydantic_restaurant_context.py
Created December 21, 2024 00:55
This code implements an intelligent restaurant recommendation system that combines Pydantic type safety with sophisticated context management. The system uses Pydantic Agents to interface with an LLM (Large Language Model) while maintaining type safety and data validation throughout the application.
"""
Restaurant recommendation system demonstrating context features with multiple customers.
Shows how context helps personalize and improve recommendations over time.
"""
from typing import List, Optional, Dict, Literal
from pydantic import BaseModel, Field
import asyncio
from datetime import datetime
from pydantic_ai import Agent, RunContext
@cnndabbler
cnndabbler / modal_flux.py
Created February 13, 2025 21:47
modal with FLUX
# ---
# BENTOAI:
# input as prompts_file: image_prompts.txt
# output-directory: "./flux/frame_XXXX.png"
# ---
# BENTOAI: This guide is based on Modal excellent examples and tutorials: https://modal.com/docs/example
# In this guide, we'll run Flux to generate images from prompts using [Hugging Face's Diffusers](https://github.com/huggingface/diffusers).
@cnndabbler
cnndabbler / mcp_yt_transcript.py
Created March 20, 2025 21:56
MCP server reference code used to retrieve YouTube videos transcripts
#!/usr/bin/env python3
from mcp.server import Server, NotificationOptions
from mcp.server.models import InitializationOptions
from mcp.server.fastmcp import FastMCP
import mcp.server.stdio
import mcp.types as types
from youtube_transcript_api import YouTubeTranscriptApi
from youtube_transcript_api._errors import NoTranscriptFound
from urllib.parse import urlparse, parse_qs
import logging
@cnndabbler
cnndabbler / mcp_gradio_transcription.py
Created March 20, 2025 21:59
Gradio UI as a MCP client to the transcript MCP server
#!/usr/bin/env python3
import asyncio
import logging
import sys
import os
from pathlib import Path
from contextlib import AsyncExitStack
from typing import Optional, List, Dict, Any
import gradio as gr