Skip to content

Instantly share code, notes, and snippets.

@evanreichard
Created April 11, 2024 01:07
Show Gist options
  • Save evanreichard/2d6dbf473017da90128c3034376bbafe to your computer and use it in GitHub Desktop.
Save evanreichard/2d6dbf473017da90128c3034376bbafe to your computer and use it in GitHub Desktop.
Auto Kagi LLM
// ==UserScript==
// @name Auto Kagi LLM
// @match https://kagi.com/assistant?mode=4*
// @grant none
// @version 1.0
// @author Evan Reichard
// ==/UserScript==
function doAutoLLM() {
let hashLocation = window.location.hash;
if (!hashLocation.startsWith("#query=")) return;
let query = decodeURIComponent(hashLocation.replace(/^#query=/, ''));
let inputEl = document.querySelector("textarea");
inputEl.value = query;
const keyboardEvent = new KeyboardEvent('keydown', {
code: 'Enter',
key: 'Enter',
charCode: 13,
keyCode: 13,
view: window,
bubbles: true
});
setTimeout(() => {
inputEl.dispatchEvent(keyboardEvent);
}, 100);
}
doAutoLLM()
// Example Usage:
// https://kagi.com/assistant?mode=4&sub_mode=1#query=%s
// LLMs:
// GPT35Turbo - https://kagi.com/assistant?mode=4&sub_mode=1
// GPT4 - https://kagi.com/assistant?mode=4&sub_mode=2
// GPT4Turbo - https://kagi.com/assistant?mode=4&sub_mode=7
// Claude3Haiku - https://kagi.com/assistant?mode=4&sub_mode=13
// Claude3Sonnet - https://kagi.com/assistant?mode=4&sub_mode=14
// Claude3Opus - https://kagi.com/assistant?mode=4&sub_mode=12
// MistralSmall - https://kagi.com/assistant?mode=4&sub_mode=10
// MistralLarge - https://kagi.com/assistant?mode=4&sub_mode=11
// Gemini15Pro - https://kagi.com/assistant?mode=4&sub_mode=8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment