Skip to content

Commit

Permalink
Google API --> error codes added.
Browse files Browse the repository at this point in the history
  • Loading branch information
JasminDreasond committed Jan 31, 2025
1 parent 0d3a9f4 commit 53864cb
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 27 deletions.
52 changes: 26 additions & 26 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
<link rel="stylesheet" href="./css/cryptofont/cryptofont.min.css">
<link rel="stylesheet" href="./css/bootstrap.min.css">

<link rel="stylesheet" href="./css/dark.css?v=292">
<link rel="stylesheet" href="./css/main.css?v=292">
<link rel="stylesheet" href="./css/carousel.css?v=292"./>
<link rel="stylesheet" href="./css/dark.css?v=293">
<link rel="stylesheet" href="./css/main.css?v=293">
<link rel="stylesheet" href="./css/carousel.css?v=293"./>

<link rel="stylesheet" href="./photoswipe/photoswipe.css">
<link rel="stylesheet" href="./photoswipe/default-skin/default-skin.css">

<!-- Manifest -->
<link rel="manifest" href="./manifest.json?v=292">
<link rel="manifest" href="./manifest.json?v=293">

<!-- Page Info -->
<meta content="Homepage" property="og:title">
Expand All @@ -46,7 +46,7 @@
<meta content="The dimension of lost creatures and the home of hope." property="description">

<!-- Embed -->
<link href="./oEmbed/index.json?v=292" rel="alternate" title="oEmbed JSON Profile" type="application/json+oembed">
<link href="./oEmbed/index.json?v=293" rel="alternate" title="oEmbed JSON Profile" type="application/json+oembed">
<meta content="./oEmbed/index.png" property="og:image">

<link href="https://ponydriland.com" rel="canonical">
Expand All @@ -63,29 +63,29 @@
<meta property="twitter:site" content="Pony Driland">

<!-- Base -->
<script src="./js/files/Notification.js?v=292"></script>
<script src="./js/files/Notification.js?v=293"></script>
<script src="./js/events.js"></script>
<script src="./js/jquery.min.js"></script>

<!-- AI -->
<script src="./js/ai/google.js?v=292"></script>
<script src="./js/ai/templates.js?v=292"></script>
<script src="./js/ai/TinyAiManager.js?v=292"></script>
<script src="./js/ai/google.js?v=293"></script>
<script src="./js/ai/templates.js?v=293"></script>
<script src="./js/ai/TinyAiManager.js?v=293"></script>

<!-- Web3 -->
<script src="./js/bignumber.min.js"></script>
<script src="./crypto/ethers.umd.min.js"></script>
<script src="./crypto/walletconnect.v1.js"></script>
<script src="./crypto/web3.js?v=292"></script>
<script src="./crypto/web3.js?v=293"></script>

<!-- Script -->
<script>var fileVersion = '?v=415';</script>
<script src="./js/qrcode.js"></script>
<script src="./chapters/config.js?v=292"></script>
<script src="./crypto/config.js?v=292"></script>
<script src="./chapters/sound.js?v=292"></script>
<script src="./chapters/characters.js?v=292"></script>
<script src="./chapters/counter.js?v=292"></script>
<script src="./chapters/config.js?v=293"></script>
<script src="./crypto/config.js?v=293"></script>
<script src="./chapters/sound.js?v=293"></script>
<script src="./chapters/characters.js?v=293"></script>
<script src="./chapters/counter.js?v=293"></script>

<script src="./js/base64.js"></script>
<script src="./js/clone.min.js"></script>
Expand All @@ -102,21 +102,21 @@
<script src="./js/md5.js"></script>
<script src="./js/FileSaver.min.js"></script>

<script src="./js/tinyLib.js?v=292"></script>
<script src="./js/tinyLib.js?v=293"></script>

<script src="./js/photoswipe.min.js"></script>
<script src="./js/photoswipe-ui-default.min.js"></script>

<script src="./js/files/chapters.js?v=292"></script>
<script src="./js/files/start.js?v=292"></script>
<script src="./js/chapter_manager/updater.js?v=292"></script>
<script src="./js/chapter_manager/tts/tts.js?v=292"></script>
<script src="./js/chapter_manager/music/index.js?v=292"></script>
<script src="./js/chapter_manager/music/pizzicato.js?v=292"></script>
<script src="./js/chapter_manager/music/seamlessloop.js?v=292"></script>
<script src="./js/chapter_manager/music/vanilla.js?v=292"></script>
<script src="./js/chapter_manager/index.js?v=292"></script>
<script src="./crypto/main.js?v=292"></script>
<script src="./js/files/chapters.js?v=293"></script>
<script src="./js/files/start.js?v=293"></script>
<script src="./js/chapter_manager/updater.js?v=293"></script>
<script src="./js/chapter_manager/tts/tts.js?v=293"></script>
<script src="./js/chapter_manager/music/index.js?v=293"></script>
<script src="./js/chapter_manager/music/pizzicato.js?v=293"></script>
<script src="./js/chapter_manager/music/seamlessloop.js?v=293"></script>
<script src="./js/chapter_manager/music/vanilla.js?v=293"></script>
<script src="./js/chapter_manager/index.js?v=293"></script>
<script src="./crypto/main.js?v=293"></script>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js"></script>
Expand Down
96 changes: 95 additions & 1 deletion docs/js/ai/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,92 @@ const setGoogleAi = (
tinyGoogleAI.setApiKey(GEMINI_API_KEY);
tinyGoogleAI.setModel(MODEL_DATA);

// Error codes
const errorCodes = {
100: "Continue",
101: "Switching Protocols",
102: "Processing",
103: "Early Hints",
200: "OK",
201: "Created",
202: "Accepted",
203: "Non-Authoritative Information",
204: "No Content",
205: "Reset Content",
206: "Partial Content",
207: "Multi-Status",
208: "Already Reported",
226: "IM Used",
300: "Multiple Choices",
301: "Moved Permanently",
302: "Found",
303: "See Other",
304: "Not Modified",
305: "Use Proxy",
306: "Switch Proxy",
307: "Temporary Redirect",
308: "Permanent Redirect",
400: "Bad Request",
401: "Unauthorized",
402: "Payment Required",
403: "Forbidden",
404: "Not Found",
405: "Method Not Allowed",
406: "Not Acceptable",
407: "Proxy Authentication Required",
408: "Request Timeout",
409: "Conflict",
410: "Gone",
411: "Length Required",
412: "Precondition Failed",
413: "Payload Too Large",
414: "URI Too Long",
415: "Unsupported Media Type",
416: "Range Not Satisfiable",
417: "Expectation Failed",
418: "I'm a teapot",
421: "Misdirected Request",
422: "Unprocessable Entity",
423: "Locked",
424: "Failed Dependency",
425: "Too Early",
426: "Upgrade Required",
428: "Precondition Required",
429: "Too Many Requests",
431: "Request Header Fields Too Large",
451: "Unavailable For Legal Reasons",
500: "Internal Server Error",
501: "Not Implemented",
502: "Bad Gateway",
503: "Service Unavailable",
504: "Gateway Timeout",
505: "HTTP Version Not Supported",
506: "Variant Also Negotiates",
507: "Insufficient Storage",
508: "Loop Detected",
510: "Not Extended",
511: "Network Authentication Required",
520: "Web Server Returned an Unknown Error",
521: "Web Server Is Down",
522: "Connection Timed Out",
523: "Origin Is Unreachable",
524: "A Timeout Occurred",
525: "SSL Handshake Failed",
526: "Invalid SSL Certificate",
527: "Railgun Error",
530: "Site Frozen",
598: "Network Read Timeout Error",
599: "Network Connect Timeout Error",

// Nginx
444: "No Response",
494: "Request Header Too Large",
495: "SSL Certificate Error",
496: "SSL Certificate Required",
497: "HTTP Request Sent to HTTPS Port",
499: "Client Closed Request",
};

// Build Error
const buildErrorData = (result, finalData) => {
finalData.error = {
Expand Down Expand Up @@ -313,7 +399,15 @@ const setGoogleAi = (
else if (!res.ok)
reject(
new Error(
`Error ${typeof res.status === "number" ? `HTTP ${res.status}` : "UNKNOWN ERROR"}: ${typeof res.statusText === "string" ? (res.statusText.length > 0 ? res.statusText : "...") : "Unknown"}`,
`Error ${typeof res.status === "number" ? `HTTP ${res.status}` : "UNKNOWN ERROR"}: ${
typeof res.statusText === "string"
? res.statusText.length > 0
? res.statusText
: typeof errorCodes[Number(res.status)] === "string"
? errorCodes[Number(res.status)]
: "???"
: "Unknown"
}`,
),
);
// Streaming
Expand Down

0 comments on commit 53864cb

Please sign in to comment.