7 * Converts ::: type title\n content ::: to HTML callout divs
8 */
9export function remarkCallout() {
10 return function transformer(tree: Node) {
11 visit(tree, 'text', function visitor(node: any, index: number, parent: any) {
12 // Accept both with and without a title
13 const calloutRegex = /:::\s*([a-zA-Z-]+)(?:\s+(.*?))?\s*\n([\s\S]*?)\n?:::/g;
49
50// Remove rehypeCallout (no-op)
51export function rehypeCallout() {
52 return () => {};
53}
1import { OpenAI } from "https://esm.town/v/std/openai";
2
3export default async function anthropicCompletion(
4 prompt: string,
5) {
13
14// --------------------- Email Trigger ------------------------
15// Email triggers run the exported function with the email as the argument
16// Learn more about cron triggers: https://docs.val.town/vals/email/
17
18export default async function(e: Email) {
19 console.log(e);
20
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2
3export default async function fixTelegramChatsTable() {
4 console.log("Fixing telegram_chats table...");
5
35}
36
37// Run the function immediately
38fixTelegramChatsTable();
1import { email } from "https://esm.town/v/std/email";
2
3export default async function sendEmail(
4 to: string,
5 subject: string,
5// ---------------- Val Town Standard Library ----------------
6// Val Town provides limited free hosted services, including
7// functions for sending emails and using OpenAI
8import { email } from "https://esm.town/v/std/email";
9import { OpenAI } from "https://esm.town/v/std/OpenAI";
17
18// --------------------- Cron Trigger ------------------------
19// Cron triggers run the exported function on the specified timer
20// Edit the timer by clicking the clock icon 🕑 above
21// Learn more about cron triggers: https://docs.val.town/vals/cron/
22
23export default async function() {
24 // Use OpenAI provided by Val Town to get weather reccomendation
25 // Experiment with changing the prompt
1import { sqlite } from "https://esm.town/v/stevekrouse/sqlite";
2
3export default async function setupTelegramChatsTable() {
4 console.log("Setting up telegram_chats table...");
5
37}
38
39// Run the function immediately
40setupTelegramChatsTable();
6const tableName = "memories";
7
8export async function getAllMemories(): Promise<Memory[]> {
9 const result = await sqlite.execute(
10 `SELECT id, date, text, createdBy, createdDate, tags FROM ${tableName}
23}
24
25export async function createMemory(
26 memory: Omit<Memory, "id">,
27): Promise<Memory> {
51}
52
53export async function updateMemory(
54 id: string,
55 memory: Partial<Omit<Memory, "id">>,
70}
71
72export async function deleteMemory(id: string): Promise<void> {
73 await sqlite.execute(`DELETE FROM ${tableName} WHERE id = ?`, [id]);
74}
9 * @returns HTML string for the head section
10 */
11export function buildHead(title: string, desc: string, url: string, config: Config): string {
12 const pageTitle = title || config.title;
13 const pageDesc = desc || config.description;
2
3/**
4 * Helper function to resolve stylesheet paths
5 * @param path - Relative path to the stylesheet
6 * @returns Resolved URL string
7 */
8function resolveStylesheet(path: string): string {
9 return import.meta.resolve(`../styles/${path}`).replace("esm.town", "juicy.town");
10}
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.