7
8// Función para manejar solicitudes HTTP
9export default async function handler(req) {
10 // Configuración CORS para permitir solicitudes desde cualquier origen
11 const headers = {
74
75// Función para llamar a la API de OpenAI
76async function callOpenAI(apiKey, prompt, model, temperature, maxTokens) {
77 const url = 'https://api.openai.com/v1/chat/completions';
78
109
110// Función para llamar a la API de Claude (Anthropic)
111async function callClaude(apiKey, prompt, model, temperature, maxTokens) {
112 const url = 'https://api.anthropic.com/v1/messages';
113
146// UI para pruebas (solo para referencia, se debe implementar como una val separada en ValTown)
147// Esta función no se exporta para evitar conflictos con la exportación predeterminada
148function ui() {
149 return `
150 <!DOCTYPE html>
339 });
340
341 function addOption(select, value, text) {
342 const option = document.createElement('option');
343 option.value = value;
2import { email } from "https://esm.town/v/std/email";
3
4async function weather(): string {
5 var weather = await blob.getJSON(Deno.env.get("WEATHER_BLOB"));
6 weather = weather.forecast;
9}
10
11async function wikitext(): string {
12 const randomArticle = await fetch(
13 "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=extracts&exintro&explaintext&redirects=1&generator=random&formatversion=2&grnnamespace=0&grnlimit=3",
23}
24
25export default async function(interval: Interval) {
26 var emailText = "";
27 emailText = emailText + await weather();
4import { TABLE_NAME } from "./updateTable";
5
6export default async function(req: Request): Promise<Response> {
7 // body contains:
8 // - id (number)
4import { TABLE_NAME } from "./updateTable";
5
6export default async function(req: Request): Promise<Response> {
7 // body contains:
8 // - title (string)
2
3export const TABLE_NAME = "pondiverse_creations_v5";
4export default async function(req: Request): Promise<Response> {
5 await sqlite.execute(
6 `CREATE TABLE IF NOT EXISTS ${TABLE_NAME} (
18const lruCache = new LRUCache(ttlOptions);
19
20export default async function(req: Request): Promise<Response> {
21 const searchParams = new URL(req.url).searchParams;
22 const discussionId = searchParams.get("discussion");
79}
80
81async function getDiscussionPosts(discussionId: string): Promise<PostT[]> {
82 // Used to get the list of post id's for the discussion.
83 const discussionRes = await fetch(`${server}/api/discussions/${discussionId}`);
117
118// This takes an array and chunks it.
119function chunkArray<T>(array: T[], chunkSize: number): T[][] {
120 const chunks: T[][] = [];
121 for (let i = 0; i < array.length; i += chunkSize) {
1export default async function (req: Request): Promise<Response> {
2 return Response.json({ ok: true })
3}
1export default async function(req: Request): Promise<Response> {
2 return Response.json({
3 image_url: "https://jon.bo/IMG_9387.png",
4import { TABLE_NAME } from "./updateTable";
5
6export default async function(req: Request): Promise<Response> {
7 const url = new URL(req.url);
8 const id = url.searchParams.get("id");
48
49// Main handler for HTTP requests
50export default async function(req: Request): Promise<Response> {
51 console.log("🔍 Request received:", req.method, "URL:", req.url);
52 console.log("🔍 Headers:", JSON.stringify(Object.fromEntries([...req.headers])));
166
167// Extract issue numbers from PR body
168function extractIssueNumbers(body: string): number[] {
169 // Match common issue linking keywords
170 const patterns = [
191
192// Fetch issue details
193async function fetchIssue(repo: string, issueNumber: number): Promise<GitHubIssue> {
194 const token = Deno.env.get("GITHUB_TOKEN");
195
228
229// Add labels to PR
230async function addLabelsToPR(repo: string, prNumber: number, labels: string[]) {
231 const token = Deno.env.get("GITHUB_TOKEN");
232
A helper function to build a file's email
Simple functional CSS library for Val Town
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
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": "*",