WIP: Adding AI #6

Draft
unfunny wants to merge 1 commits from chromeai into master
4 changed files with 84 additions and 2 deletions

33
chromeAICheck.html Normal file
View File

@@ -0,0 +1,33 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- /\ you see this? this is the sum of those mobile optimizations. one line. yeah. you can leave now.-->
<meta property="og:title" content="Doofensmirtz ONLINE" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://doofensmirtzevil.neocities.org/" />
<meta property="og:image" content="https://doofensmirtzevil.neocities.org/newlogo.png" />
<title>DOOFENSMIRTZ ONLINE</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Libre+Barcode+39+Extended+Text&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Sono&display=swap" rel="stylesheet">
<link href="/normalbordem.css" rel="stylesheet" type="text/css" media="all">
<script src="/src/chromeaichk.js"></script>
<!--<script src="cdnewyear.js"></script> \
Fun Fact: It is not currently new years-->
</head>
<body>
<h1>Chrome AI Model check </h1>
<p>some features of this site use on-device AI to power assitant features and the upcoming infinite ikea.</p>
<br><img src="anibar.gif"><br>
<div id="throbber">Please Wait... Checking your device.</div>
<br><img src="anibar.gif"><br>
<a href=javascript:history.back()><img src="/eternalbliss/BLUEamnesiac'sWTV.gif" title="click me to go back"></img></a>
</body>
<script> aichk();</script>

View File

@@ -96,5 +96,6 @@ Current Viewers:<script language="javascript" type="text/javascript" src="//coun
<img src=anibar.gif>
<br>
<h6 style="color: grey">psst. if you get tired of all the flashy stuff, <a href=index2.html style="color: grey;">check out the lite version of this site</a>.</h6>
<h6 style="color: grey">Utilities<br><a href="chromeAICheck.html">ai check</a></h6>
<!--<h6 style="color: grey">brb, lite mode site is broken rn</h6>-->
</body>

View File

@@ -4,8 +4,10 @@ import http.server
import socketserver
import subprocess
import sys
import argparse
PORT = 8080
BIND_ADDRESS = "localhost" # Default to localhost for security
class Handler(http.server.SimpleHTTPRequestHandler):
def log_message(self, format, *args):
@@ -17,7 +19,21 @@ class Handler(http.server.SimpleHTTPRequestHandler):
super().end_headers()
if __name__ == "__main__":
with socketserver.TCPServer(("", PORT), Handler) as httpd:
print(f"Server running at http://localhost:{PORT}")
parser = argparse.ArgumentParser(description="Simple HTTP server for testing")
parser.add_argument("-b", "--bind", default="localhost",
help="Bind address (default: localhost). Use '0.0.0.0' to bind all interfaces")
parser.add_argument("-p", "--port", type=int, default=PORT,
help=f"Port number (default: {PORT})")
args = parser.parse_args()
# Convert "localhost" to "" for bind address, or use provided address
bind_addr = "" if args.bind == "0.0.0.0" else args.bind
print(f"Binding to: {args.bind}")
print(f"Port: {args.port}")
with socketserver.TCPServer((bind_addr, args.port), Handler) as httpd:
url = f"http://{'localhost' if args.bind == 'localhost' else args.bind}:{args.port}"
print(f"Server running at {url}")
sys.stdout.flush()
httpd.serve_forever()

32
src/chromeaichk.js Normal file
View File

@@ -0,0 +1,32 @@
// @ts-check
// Uh yeah this code is terrible, i DO NOT care
// womp womp
//also womp womp to the anti-ai people, wah the water wah it's on your localhost i do not care, your PC is not magically siphoning water from the nearest river
var nochromeai = false
async function aichk() {
// First check for ChromeAI
try {
const availability = await Summarizer.availability({outputLanguage: 'en'});
} catch (e) {
console.error("ChromeAI functions do not exist. Moving on, but I think you should know: ", e);
var nochromeai = true
}
if (nochromeai == true) {
document.getElementById("throbber").innerHTML = "Chrome AI API call failed. Check console for more details. <br> <h6>sucks to suck</h6>";
} else {
document.getElementById("throbber").innerHTML = "Chrome AI API exists!";
}
// Check Randomhack LLM reachability
// Last resort, cloud-based (as in, hosted by myself in a homelab
// a 401 is expected here.
await fetch("https://llmapi.randomhack.com/v1/models")
.then(r => { console.log("[LLM Ping] v1 reachable, status:", r.status); document.getElementById("throbber").innerHTML += "<br>Connection to Randomhack LLM service succeeded!"; })
.catch(e => { console.error("[LLM Ping] v1 unreachable:", e.message); document.getElementById("throbber").innerHTML += "<br>Connection to Randomhack LLM service failed.<br> AI Functionality will not be enabled.<br> <h6> looser</h6>"; });
if (nochromeai == true ) {
document.getElementById("throbber").innerHTML += "<br> <strong>AI will not be running on-device.</strong>";
} else {
document.getElementById("throbber").innerHTML += "<strong>аll systems go! <br> AI is fully functional, you are ready to explore doofonline to it's fullest</strong>";
}
}