parseImportMetaproject1 match
20}
2122export function parseProject(url: string): Project {
23const pattern = /^https:\/\/esm\.town\/v\/([^/]+)\/([^@]+)@(\d+)-(.+?)(\/.*)?$/;
24const match = url.match(pattern);
1import { email } from "https://esm.town/v/std/email?v=13";
23export default async function(interval: Interval) {
4console.log(`math problem`);
5email({
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
45function LinkInBio() {
6const links = [
7{
57}
5859function client() {
60createRoot(document.getElementById("root")).render(<LinkInBio />);
61}
62if (typeof document !== "undefined") { client(); }
6364export default async function server(request: Request): Promise<Response> {
65return new Response(`
66<html>
148export interface ToolDefinition {
149type: string;
150function: {
151name: string;
152description: string;
162id: string;
163type: string;
164function: {
165name: string;
166arguments: string;
178id: string;
179type: string;
180function: {
181name: string;
182arguments: string;
213`;
214215export function createBot(bot: BotBase<ValTownCtx>): { handleRequest: Handler } {
216async function handleRequest(req: Request): Promise<Response> {
217const reqBody = await req.json().catch(e => null);
218if (!reqBody) {
228let settingsResponse = await Promise.resolve()
229.then(() => {
230if (typeof bot.settings === "function") {
231return bot.settings(body, { req });
232}
244const stream = new ReadableStream({
245start(controller) {
246(async function() {
247for await (const event of bot.handleMessage(body, { req }, { events, sleep })) {
248if (typeof event === "string") {
276}
277278export function sleep(timeInMs: number) {
279return new Promise(resolve => setTimeout(resolve, timeInMs));
280}
281282function encodeEvent(event: string, data: any = {}) {
283return new TextEncoder().encode(`event: ${event}\ndata: ${JSON.stringify(data)}\n\n`);
284}
285286export default function serve(bot: BotBase<ValTownCtx>): Handler {
287return createBot(bot).handleRequest;
288}
291* Forwards a query to a poe hosted bot, like "GPT-4o"
292*/
293export async function* forward(
294{ query, toBotName, accessKey }: { query: QueryRequest; toBotName: string; accessKey: string },
295): AsyncIterable<PoeBotServerSentEvent> {
309}
310311async function* fetchEventSource(request: Request): AsyncIterable<{ event: string; data: any }> {
312const response = await fetch(request);
313
rumsey_roulettemain.tsx4 matches
45};
4647async function getRandomObject() {
48const result = await sqlite.execute(`
49SELECT data FROM ${tableName} ORDER BY RANDOM() LIMIT 1
54}
5556function parseData(ndjson: string) {
57return ndjson.split(/[\r\n]+/)
58.filter((line) => line)
60}
6162function createChunks(arr: any[]) {
63let chunks = new Array();
64for (let i = 0; i < arr.length; i += chunkSize) {
69}
7071export default async function(req: Request): Promise<Response> {
72const method = req.method;
73const searchParams = new URL(req.url).searchParams;
chatAgentWithCustomPromptmain.tsx3 matches
4import { OpenAI } from "https://esm.town/v/std/openai";
56export default async function chatAgentWithCustomPrompt(input?: string) {
7const model = new ChatOpenAI({
8temperature: 0,
31}
3233// Test function to demonstrate usage
34export async function testChatAgent() {
35// Test with default input
36console.log("Default Test:");
1export default async function (interval: Interval) {
2
3}
youthfulCyanSheepmain.tsx2 matches
2import { retryFill } from "https://esm.town/v/alexwein/gridRetryFill";
34export async function fabw() {
5// Import d3 and Plot with a server-side compatible approach
6const d3 = await import("https://cdn.jsdelivr.net/npm/d3@7/+esm");
61}
6263export default async function(request: Request) {
64return await fabw();
65}
13];
1415function App() {
16const [noClicks, setNoClicks] = useState(0);
17const [isValentine, setIsValentine] = useState(false);
98}
99100function client() {
101createRoot(document.getElementById("root")).render(<App />);
102}
103if (typeof document !== "undefined") { client(); }
104105export default async function server(request: Request): Promise<Response> {
106return new Response(
107`
13];
1415function App() {
16const [noClicks, setNoClicks] = useState(0);
17const [isValentine, setIsValentine] = useState(false);
98}
99100function client() {
101createRoot(document.getElementById("root")).render(<App />);
102}
103if (typeof document !== "undefined") { client(); }
104105export default async function server(request: Request): Promise<Response> {
106return new Response(
107`