Skip to content

Instantly share code, notes, and snippets.

View Kjdragan's full-sized avatar

Kevin Dragan Kjdragan

  • Houston
  • 11:05 (UTC -06:00)
View GitHub Profile
from typing import Literal, Optional, List
from ollama import chat
from pydantic import BaseModel, Field
from utils import save_album_details_to_markdown
from models import Album, Song
import os
def process_album_image(path: str) -> Album:
import os
from models import Album
def save_album_details_to_markdown(album: Album, output_path: str = "album_details.md"):
"""
Save album details to a markdown file in the album_notes directory.
Args:
album: Album object containing the details
from openai import OpenAI
import openai
from pydantic import BaseModel
# Initialize OpenAI client with local Ollama endpoint
client = OpenAI(base_url="http://localhost:11434/v1", api_key="ollama")
class NER(BaseModel):
organizations: list[str]
@Kjdragan
Kjdragan / convert_to_dict_with_model_dumps.py
Last active December 24, 2024 02:29
pydantic eaqmples:
from pydantic import BaseModel
import requests
"""
This script demonstrates the use of Pydantic's `model_dump()` to convert a model
into a Python dictionary. Key points:
1. **Dot Notation**:
- Use dot notation (e.g., `person.name`) for accessing individual fields.
- Ideal when field names are known and operations are simple.
@Kjdragan
Kjdragan / gemini_image_inference.py
Last active December 20, 2024 15:55
gemini: text or image inference
import os
from dotenv import load_dotenv
from typing import List
from google import genai
from google.genai import types
load_dotenv()
GOOGLE_API_KEY = os.getenv('GOOGLE_API_KEY')
MODEL_ID = "gemini-2.0-flash-thinking-exp-1219" # @param ["gemini-2.0-flash-exp","gemini-1.5-flash-002","gemini-1.5-pro-002","gemini-2.0-flash-exp"] {"allow-input":true}
@Kjdragan
Kjdragan / code-editor-rules-file.md
Last active December 17, 2024 13:52
cursor rules file

[Project Name]

Every time you choose to apply a rule(s), explicitly state the rule(s) in the output. You can abbreviate the rule description to a single word or phrase.

Project Context

[Brief description ]

  • [more description]
  • [more description]
  • [more description]
@Kjdragan
Kjdragan / dowload_audio_from_google.py
Created December 14, 2024 18:40
Download google media locally
import requests
import pathlib
import os
# Prepare the file to be downloaded
PDF = "https://storage.googleapis.com/generativeai-downloads/data/Smoothly%20editing%20material%20properties%20of%20objects%20with%20text-to-image%20models%20and%20synthetic%20data.pdf" # @param {type: "string"}
# Specify the directory to download the file
DOWNLOAD_DIR = "./downloads" # Set your desired download directory here
@Kjdragan
Kjdragan / Claude MCP Windows.md
Created December 10, 2024 13:29
Setting up MCPs in Windows

Setting Up MCP Servers on Windows A step-by-step guide to setting up Model Context Protocol (MCP) servers for Claude Desktop on Windows.

Prerequisites Install Node.js (v18.x or later)

Download from: https://nodejs.org/ Verify installation by opening Command Prompt (CMD) and running: node --version npm --version

@Kjdragan
Kjdragan / metaprompt.xml
Last active December 10, 2024 05:36
Metaprompt
<purpose>
You are an expert prompt engineer, capable of creating detailed and effective prompts for language models.
Your task is to generate a comprehensive prompt based on the user's input structure.
Follow the instructions closely to generate a new prompt template.
</purpose>
<instructions>
<instruction>Analyze the user-input carefully, paying attention to the purpose, required sections, and variables.</instruction>
@Kjdragan
Kjdragan / regex
Created October 18, 2024 19:25
Regex by LLM - prompt
You are an expert regex string creator and understand how regex works. Your job is to convert the user's natural language queries and constraints in the form of regex. After generating the regex string, provide explanation in detail with a few examples. Then demonstrate its use in a python code.
User query:
Give me the regex equivalent of the following:
My requirements are:
I want my string to have 2-63 characters.
The string should be alphanumeric and can contain - also.