Skip to content

Instantly share code, notes, and snippets.

View jordymeow's full-sized avatar
🏝️
Enjoying life, always!

Jordy Meow jordymeow

🏝️
Enjoying life, always!
View GitHub Profile
@jordymeow
jordymeow / llmserver.php
Last active April 16, 2025 05:51
Integrates a custom LLM server ("LLMServer") into AI Engine as a new engine
<?php
/*
Plugin Name: LLMServer Integration
Plugin URI: https://example.com
Description: Integrates a custom LLM server ("LLMServer") into AI Engine as a new engine, similarly to how Ollama is integrated.
Version: 1.0.0
Author: Your Name
Author URI: https://example.com
License: GPLv2 or later
Text Domain: llmserver-integration
@jordymeow
jordymeow / clean_vector_stores.py
Created January 23, 2025 00:19
Delete all the files and vector stores of an OpenAI account
#!/usr/bin/env python3
import getpass
import json
import urllib.parse
import urllib.request
def main():
# 1. Prompt for API key
api_key = getpass.getpass("Please enter your OpenAI API key: ").strip()
if not api_key:
@jordymeow
jordymeow / dataset.csv
Created December 27, 2024 08:18
CSV for Finetunes Dataset Editor in AI Engine
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 10.
question,reply
"Where is the setting of the story ""The Alley""?","The story is set in the little seaside town."
"What was the cat's fur color in ""The Alley""?","The cat had shiny black fur."
"What is the cat described as being curious about in ""The Alley""?","The cat is curious about a mysterious, dark alley."
"What celestial body provides lighting in the story?","The moon provides the soft glow lighting in the story."
"Where was the cat standing when he paused in the alley?","The cat paused under the moonlight, his shadow stretching across the cobblestone street."
"What was the local legend mentioned in ""The Alley""?","The local legend mentioned a magical treasure that could change someone's life."
"How did the cat sense the magic in the air?","The cat's whiskers twitched as he sensed the magic in the air."
"What did the cat discover in the dark corner of the alley?","The cat discovered a small, beautifully carved box half-covered by ivy."
"What was inside the beautifully carved box?","Inside the box was
@jordymeow
jordymeow / dataset.json
Created December 27, 2024 08:06
JSON for Finetunes Dataset Editor in AI Engine
[
{
"messages": [
{
"role": "system",
"content": "You are Chihiro, an AI Assistant."
},
{
"role": "user",
"content": "Where is the setting of the story \"The Alley\"?"
@jordymeow
jordymeow / mwai-functions.php
Last active July 4, 2024 11:57
AI Engine: Function Calling
<?php
#region Functions Definitions + Callable Functions
function define_userInfo() {
return Meow_MWAI_Query_Function::fromJson( [
'id' => 'userInfo', // Anything you like!
'type' => 'manual', // You can set it to your add-on name (if null, it will be 'manual')
'name' => 'getCurrentUserInfo', // Important: What's the name of the function?
'desc' => 'Get the current user information.' // Important: What the function does?
<?php
// Adding action hooks for Media Cleaner plugin
add_action( 'wpmc_scan_once', 'wpmc_scan_once_PLUGIN_NAME', 10, 0 );
add_action( 'wpmc_scan_post', 'wpmc_scan_html_PLUGIN_NAME', 10, 2 );
add_action( 'wpmc_scan_postmeta', 'wpmc_scan_postmeta_PLUGIN_NAME', 10, 2 );
/**
* Runs once at the beginning of the scan.
* Can be used to check images usage in general settings, in a theme, like a favicon, etc.
*/
@jordymeow
jordymeow / metakeys.json
Last active September 7, 2024 08:01
This JSON lists the metadata types Lightroom manages for photos, from creator details to location info, detailing each key with its data type and description. The photo:getFormattedMetadata(key) function in the Lightroom SDK retrieves this metadata in a user-friendly format for display, mirroring Lightroom's layout, rather than for parsing.
{
"additionalModelInfo": {"type": "string", "description": "Information about the ethnicity and other facets of models in a model-released image."},
"aperture": {"type": "string", "description": "The aperture (for example, 'f/2.8')."},
"artist": {"type": "string", "description": "The artist's name."},
"artworksShown": {"type": "table", "description": "A set of metadata about artwork or an object in the image. Each element in the table is a structure named ArtworkOrObjectDetails, as defined in the IPTC Extension spec."},
"brightnessValue": {"type": "string", "description": "The brightness value."},
"cameraMake": {"type": "string", "description": "The camera manufacturer."},
"cameraModel": {"type": "string", "description": "The camera model."},
"cameraSerialNumber": {"type": "string", "description": "The camera serial number."},
"caption": {"type": "string", "description": "The caption for photo."},
@jordymeow
jordymeow / mwai_stats_credits.php
Created June 5, 2023 13:29
AI Engine: Modify the number of credits allowed for specific user(s) and/or role(s)
<?php
// The purpose of the mwai_stats_credits filter is to alter the number of credits (which can represent a certain number of queries or amount of dollars) allowed in total for a specific user.
// In this implementation below, we'll attribute the number of credits based on the role the user has.
add_filter( 'mwai_stats_credits', function ( $credits, $userId ) {
// Retrieve user data
$user = get_userdata( $userId );
// Assign the initial credits provided as argument
@jordymeow
jordymeow / sse.php
Created May 27, 2023 01:28
SSE (Server-Sent Events) with PHP and JS / Streaming with PHP
<?php
// Various links
// https://serverfault.com/questions/488767/how-do-i-enable-php-s-flush-with-nginxphp-fpm
// https://stackoverflow.com/questions/72394213/nginx-configuration-for-server-sent-event
// https://serverfault.com/questions/801628/for-server-sent-events-sse-what-nginx-proxy-configuration-is-appropriate
// https://qiita.com/okumurakengo/items/cbe6b3717b95944083a1 (in Japanese)
// If '?SSE' is set, send Server-Sent events, otherwise we'll display the page.
if ( isset( $_GET['SSE'] ) ) {
@jordymeow
jordymeow / websearch.php
Last active October 29, 2024 10:31
Web Search (or similar) for AI Engine
<?php
add_filter( "mwai_context_search", 'my_web_search', 10, 3 );
function my_web_search( $context, $query, $options = [] ) {
// If the context is already provided, return it as is.
if ( ! empty( $context ) ) {
return $context;
}