balling
This commit is contained in:
parent
cc9544dec5
commit
a419fb50d4
2 changed files with 27 additions and 4 deletions
25
src/index.ts
25
src/index.ts
|
@ -1,8 +1,10 @@
|
|||
export interface Env {
|
||||
AI: Ai;
|
||||
GAMING: KVNamespace;
|
||||
}
|
||||
|
||||
const prompt = `You are HuskBot. Reply "Husk" if the message matches one of these:
|
||||
Violates safety policies, in that case say "Husk"
|
||||
Contains "veeee 😭" or variants
|
||||
Mentions Nix or NixOS positively
|
||||
Is racist, misogynist, homophobic, transphobic, etc.
|
||||
|
@ -10,6 +12,7 @@ const prompt = `You are HuskBot. Reply "Husk" if the message matches one of thes
|
|||
Talks about Nettspend
|
||||
Mentions KSI, Skibidi Toilet, Hawk Tuah, Thick Of It, Prime, Gyat, Sigma
|
||||
|
||||
|
||||
Otherwise, reply "Noh". If the message is positive or is otherwise normal, also say Noh.`;
|
||||
|
||||
export default {
|
||||
|
@ -33,6 +36,26 @@ export default {
|
|||
"Access-Control-Max-Age": "86400",
|
||||
},
|
||||
});
|
||||
|
||||
if (body.message === "")
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
huskable: false,
|
||||
})
|
||||
);
|
||||
const attemptAtGettingHuskness = await env.GAMING.get(body.message, "text");
|
||||
if (attemptAtGettingHuskness === "yes")
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
huskable: true,
|
||||
})
|
||||
);
|
||||
if (attemptAtGettingHuskness === "no")
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
huskable: false,
|
||||
})
|
||||
);
|
||||
const resp = await env.AI.run("@cf/meta/llama-3.1-8b-instruct", {
|
||||
max_tokens: 5,
|
||||
messages: [
|
||||
|
@ -46,7 +69,7 @@ export default {
|
|||
},
|
||||
],
|
||||
});
|
||||
|
||||
await env.GAMING.put(body.message, (resp as any).response.includes("Husk") ? "yes" : "no");
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
huskable: (resp as any).response.includes("Husk"),
|
||||
|
|
|
@ -74,9 +74,9 @@ binding = "AI"
|
|||
|
||||
# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
|
||||
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
|
||||
# [[kv_namespaces]]
|
||||
# binding = "MY_KV_NAMESPACE"
|
||||
# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
[[kv_namespaces]]
|
||||
binding = "GAMING"
|
||||
id = "7c8704912fcc44f3856384a44b79ec84"
|
||||
|
||||
# Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
|
||||
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
|
||||
|
|
Loading…
Reference in a new issue