1import isMyWebsiteDown from "https://esm.town/v/weaverwhale/isMyWebsiteDown";
2
3export default async function(interval: Interval) {
4 const data = await isMyWebsiteDown("https://app.triplewhale.com");
5 console.log(data);
63
64// convert a timezone string like America/New_York to "EST"
65function shortenTimezoneString(timeZone: string) {
66 const string = new Date().toLocaleString("en-US", { timeZone, timeZoneName: "short" });
67 return string.split(" ").at(-1);
76};
77
78export async function compile(description: string, timezone: string) {
79 const { content } = await chat([
80 {
1import type { ChatCompletion, ChatCompletionCreateParamsNonStreaming, Message } from "npm:@types/openai";
2
3async function getOpenAI() {
4 // if you don't have a key, use our std library version
5 if (Deno.env.get("OPENAI_API_KEY") === undefined) {
14/**
15 * Initiates a chat conversation with OpenAI's GPT model and retrieves the content of the first response.
16 * This function can handle both single string inputs and arrays of message objects.
17 * It supports various GPT models, allowing for flexibility in choosing the model based on the application's needs.
18 *
21 * @returns {Promise<string>} A promise that resolves to the content of the first response from the completion.
22 */
23export async function chat(
24 input: string | Message[],
25 options?: Omit<ChatCompletionCreateParamsNonStreaming, "messages">,
1# OpenAI ChatGPT helper function
2
3This val uses your OpenAI token if you have one, and the @std/openai if not, so it provides limited OpenAI usage for free.
1import { API_URL } from "https://esm.town/v/std/API_URL";
2
3export async function api<T = any>(
4 path: string,
5 options?: RequestInit & {
4import process from "node:process";
5
6async function fetchCast({ fid, hash }: { fid: string; hash: string }) {
7 console.log("fetchCast", { fid, hash });
8 const res = await fetch(
27}
28
29async function runGlif({ inputs }: { inputs: string[] }): Promise<RunGlifResponse> {
30 const id = "cluu91eda000cv8jd675qsrby" as const;
31 const body = { id, inputs };
50}
51
52async function postCast({ text, replyToFid, replyToHash }: { text: string; replyToFid: string; replyToHash: string }) {
53 if (!process.env.FARCASTER_SIGNER_ID || !process.env.PINATA_JWT) {
54 throw new Error("missing required ENV vars");
90}
91
92async function runGlifAndPost({ inputs, cast }: { inputs: string[]; cast: { fid: string; hash: string } }) {
93 const glifRes = await runGlif({ inputs });
94 console.log({ glifRes });
98}
99
100export default async function(req: Request): Promise<Response> {
101 // console.log("req", req);
102 if (!process.env.GLIF_API_TOKEN) {
5type HandlerFunc = (req?: Request) => Response | Promise<Response>;
6
7export function indieauth(handler: HandlerFunc, params: {
8 clientID: string;
9}): HandlerFunc {
6import { sendMail } from "https://esm.town/v/tomas_padrieza/sendEmail";
7
8export function Email(props) {
9 const { url } = props;
10
14};
15
16export function sendMail(to, subject, html) {
17 transport.sendMail({ ...options, to, subject, html });
18
1Simple function to provide the Email sending capability. The internal is limited to the `Pro` version only.
A helper function to build a file's email
Simple functional CSS library for Val Town
import { OpenAI } from "https://esm.town/v/std/openai";
export default async function(req: Request): Promise<Response> {
if (req.method === "OPTIONS") {
return new Response(null, {
headers: {
"Access-Control-Allow-Origin": "*",
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.