11const client = new OpenAI({ apiKey: Deno.env.get("OPENAI_API_KEY") });
12
13async function main() {
14 const stream = client.beta.chat.completions.stream({
15 model: "gpt-4o-mini",
11}
12
13function formatTweetText(text: string): string {
14 // Remove any URLs from the text
15 text = text.replace(/https?:\/\/\S+/g, "");
32}
33
34export async function twitterSearch({
35 query,
36 maxResults = 4,
21);
22
23function App() {
24 const [landSize, setLandSize] = useState(1000);
25 const [sections, setSections] = useState(5);
124}
125
126function client() {
127 createRoot(document.getElementById("root")).render(<App />);
128}
132}
133
134export default async function server(request: Request): Promise<Response> {
135 return new Response(`
136 <!DOCTYPE html>
9}
10
11export async function hackerNewsSearch({
12 query = "Artificial Intelligence",
13 pages = 3,
101}
102
103async function scrapePageThreads(page) {
104 const scrollToBottom = async () => {
105 await page.evaluate(async () => {
122 await scrollToBottom();
123
124 return page.evaluate(async (dateConverterFunctionString) => {
125 const convertDateInBrowser = async (relativeDate) => {
126 try {
127 // Reconstruct the date converter function from its string representation
128 const dateConverterFunction = eval(`(${dateConverterFunctionString})`);
129 const result = await dateConverterFunction({ relativeDate });
130
131 // Check if the result is a Response object (from a potential fetch call)
172 // Return the array of thread data
173 return threads;
174 }, convertRelativeDateToString.toString()); // Pass the string representation of the original function
175}
176
177async function goToNextPage(page, currentPage) {
178 // Scroll to the bottom of the page
179 await page.evaluate(async () => {
18}
19
20function MicroReact({
21 id,
22 reactions = "12345",
54}
55
56function App() {
57 return (
58 <div>
76}
77
78function client() {
79 createRoot(document.getElementById("root")).render(<App />);
80}
84}
85
86export default async function server(request: Request): Promise<Response> {
87 return new Response(`
88 <html>
18 const inputClass = "p-2 border rounded w-full";
19 const labelClass = "w-full text-sm font-bold uppercase text-emerald-800 [&>span]:pl-0.5 flex flex-col gap-2";
20 function parseCookies(cookie: string) {
21 const out: Record<string, string> = {};
22 const c = cookie.split(";");
72 <label class=${labelClass} for="description">
73 <span>Description</span>
74 <input required class=${inputClass} id="description" name="description" type="text" placeholder="Function to return a random number" autocomplete="off" />
75 </label>
76 <button class="p-2 bg-emerald-500 text-white rounded" type="submit">Generate!</button>
1import { Buffer } from "node:buffer";
2
3export async function pngTest(req: Request): Promise<Response> {
4 var { default: pnglib } = await import("npm:pnglib");
5 const w = 64;
2import { Buffer } from "node:buffer";
3
4export function png(
5 { width, height, depth = 256 }: {
6 width: number;
19 }) => void | Promise<void>,
20) {
21 return async function(req: Request) {
22 var img = await png64(
23 { width, height, depth },
10const clearBtn = document.getElementById('clearBtn');
11
12function detectDate() {
13 const inputText = inputEl.value;
14 const parsedResults = parse(inputText);
36}
37
38function clearAll() {
39 inputEl.value = '';
40 outputEl.innerHTML = '';
42}
43
44function formatDate(date) {
45 if (!date) return '';
46 return date.toLocaleString('en-US', {
3import process from "node:process";
4
5export default async function server(req: Request): Promise<Response> {
6 let responseBody = "{}";
7
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.