8const githubQuery = (query: string) => encodeURIComponent(`${query} repo:pomdtr/val-town-mirror path:vals/`);
9
10async function handler(req: Request) {
11 const url = new URL(req.url);
12
30 }
31
32 function form(query, type) {
33 return (
34 <form method="GET" action="/search">
7const dimensions = 1536;
8
9export default async function semanticSearchPublicVals(query) {
10 const client = new Client(Deno.env.get("NEON_URL_VALSEMBEDDINGS"));
11 await client.connect();
10// CREATE TABLE vals_embeddings (id TEXT PRIMARY KEY, embedding VECTOR(1536));
11
12export default async function() {
13 const dimensions = 1536;
14
24 );
25
26 function idForVal(val: any): string {
27 return `${val.author_username}!!${val.name}!!${val.version}`;
28 }
1import { db as allValsDb } from "https://esm.town/v/sqlite/db?v=9";
2
3export default async function getValCode(val) {
4 let code = undefined;
5 for (let attempt = 1; true; attempt++) {
60 <script type="module" src="https://esm.town/v/iamseeley/realtimeFormLogic"></script>
61 <script>
62 document.getElementById('generationType').addEventListener('change', function() {
63 const type = this.value;
64 if (type === 'regular') {
82`;
83
84export default async function handler(req: Request): Promise<Response> {
85 const url = new URL(req.url);
86
11 });
12
13 async function generateImages() {
14 resultDiv.innerHTML = ''; // Clear previous results
15
59 }
60
61 function appendImage(imageUrl, model) {
62 const imgElement = new Image();
63 imgElement.src = imageUrl;
1import { API_URL } from "https://esm.town/v/std/API_URL";
2
3export async function fetchAPI(
4 path: string,
5 options?: RequestInit & {
5import { Hono } from "npm:hono@3";
6
7function esmTown(url) {
8 return fetch(url, {
9 headers: {
92});
93
94export async function calorieEstimate(file: File) {
95 const dataURL = await fileToDataURL(file);
96 try {
1export async function fileToDataURL(file) {
2 // Read the file as an ArrayBuffer
3 const arrayBuffer = await file.arrayBuffer();
4 * @returns {string} - uploaded image url
5 */
6export async function uploadImage(image: Blob): Promise<string> {
7 const fd = new FormData();
8 fd.append(
23 return data.result.variants[0];
24}
25async function getUploadURL(): Promise<string> {
26 const data = await (await fetch("https://www.val.town/api/trpc/generateImageUploadUrl", {
27 "headers": {
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.